P20506 [HackerEarth] Energy resources were getting depleted on the planet Kepler and Xenny was the head of the Energy Saving Committee.
普及
题目描述

Energy resources were getting depleted on the planet Kepler and Xenny was the head of the Energy Saving Committee.

Xenny was in-charge of a large piece of land, which was square in shape. The land was of size N x N. He placed square-shaped solar cells (1 x 1) on the piece of land uniformly, all over the land. Just when Xenny finished placing all solar cells, each cell received a power of K units.

Xenny worked for D days as in-charge. On each day, he performed A actions.

In each action, he either measured the total solar power received by a set of solar cells (sub-rectangle) or set the orientation of a single cell such that its reception power became Z times the previous power.

Input:
First line contains D, the no. of days.
For each day, first line contains N and K - one side of the square piece land and initial value of reception power of each cell.
Second line contains A - no. of actions.

Actions:
1. m x1 y1 x2 y2 - Measure solar powerful from (x1, y1) to (x2, y2).
2. s x y Z- Set rotation of single cell (x, y), such that its reception power gets multiplied by a factor of Z.

Output:
Print the total reception power for every action in which "measurement" is done, modulo 10^9 + 7.

Constraints:
1 ≤ D ≤ 10
1 ≤ N ≤ 1000
1 ≤ K ≤ 100
1 ≤ A ≤ 10^4
1 ≤ x1, y1, x2, y2 ≤ N
x1 ≤ x2 and y1 ≤ y2
1 ≤ Z ≤ 100
(Note: x1, y1, x2, y2 are 1-indexed)

SAMPLE INPUT
1
3 1
3
m 1 1 1 3
s 1 2 3
m 1 1 1 3

SAMPLE OUTPUT
3
5

Explanation

Initial powers of solar cells:

1 1 1
1 1 1
1 1 1

Measured power of cells from (1, 1) to (1, 3) = 1 + 1 + 1 = 3

After setting orientation of (1, 2):

1 3 1
1 1 1
1 1 1

Measure power of cells from (1, 1) to (1, 3) = 1 + 3 + 1 = 5

输入格式

见题面

输出格式

见题面

样例输入
2 84 3 81 m 25 65 72 83 s 15 4 1 m 6 7 37 84 m 75 46 82 67 s 3 77 2 m 62 28 73 58 m 24 45 46 48 s 52 43 3 s 73 43 1 s 50 58 2 m 59 49 71 72 s 68 79 3 m 19 38 58 76 m 5 14 25 16 m 18 74 65 76 m 63 17 81 57 m 8 13 32 60 m 78 12 81 20 s 3 59 3 m 1 1 51 10 s 35 42 3 s 57 50 3 m 83 80 83 84 s 57 11 3 m 4 79 81 83 s 79 53 1 s 10 34 1 m 58 26 84 33 m 64 38 78 78 m 10 67 51 68 m 3 46 26 65 m 28 18 59 43 m 45 61 71 75 s 79 15 2 m 53 24 70 60 s 80 16 3 s 71 59 1 s 35 75 2 s 32 53 1 m 46 9 79 21 m 22 65 68 67 m 46 22 61 36 m 1 51 38 73 s 65 40 1 m 42 37 60 66 s 12 18 2 m 58 33 73 35 m 20 63 66 70 m 25 45 44 51 s 51 16 2 s 28 51 3 m 63 4 83 28 m 12 49 61 81 m 19 74 82 77 m 57 30 80 68 s 75 47 2 m 10 19 30 52 m 30 66 67 76 s 62 48 3 m 45 76 84 83 m 74 16 84 53 m 30 6 79 71 m 63 29 77 61 m 20 66 39 76 m 22 50 27 74 m 42 77 71 78 m 80 36 84 83 m 29 11 40 25 s 38 39 1 s 19 40 1 m 75 72 77 74 m 36 25 82 42 s 43 71 2 m 52 59 68 65 m 6 81 65 81 s 57 63 2 m 32 29 74 39 m 8 79 30 79 m 66 46 75 57 s 3 26 1 m 77 21 77 82 72 2 32 m 4 40 28 51 m 10 22 25 34 s 49 23 2 m 64 58 66 69 m 7 36 50 63 m 14 58 54 63 s 44 31 1 m 62 13 67 67 m 51 10 62 29 m 41 66 59 71 s 8 71 1 m 47 17 68 43 s 55 54 2 m 23 22 51 41 m 51 2 58 3 m 55 36 67 51 s 17 8 2 m 58 34 65 36 s 66 24 2 m 22 14 72 27 s 71 24 2 m 41 52 63 60 m 2 66 8 68 m 17 34 35 67 m 58 50 60 67 m 26 14 54 52 m 28 12 32 23 m 4 16 55 32 m 41 57 68 66 m 41 55 55 72 m 26 44 40 48 m 15 29 31 41
样例输出
2736 7488 528 1116 276 936 4689 189 432 2337 3600 108 1530 15 1176 648 1845 252 1446 2508 1215 2004 1335 423 720 2628 1725 144 1128 420 1584 4968 771 2814 2148 1257 966 1263 9942 1488 663 450 180 720 540 27 2538 357 180 1419 69 363 186 600 416 72 2464 492 660 480 228 1190 1162 32 416 48 1432 416 42 1292 108 2264 120 1770 560 540 150 442