Problem1187--Population

1187: Population

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 0  Solved: 1
[Submit] [Status] [Web Board] [Creator:]

Description

It is always exciting to see people settling in a new continent. As the head of the population management office, you are supposed to know, at any time, how people are distributed in this continent. The continent is divided into square regions, each has a center with integer coordinates (x,y). Hence all the people coming into that region are considered to be settled at the center position. Given the positions of the corners of a rectangle region, you are supposed to count the number of people living in that region.

Input

Each input file contains one test case. For each case, the character I in a line signals the coming in of new groups of people. In the following lines, each line contains three integers: X, Y, and N, where X and Y (1 ≤ X, Y ≤ 20000) are the coordinates of the region's center, and N (1 ≤ N ≤ 10000) is the number of people coming in. The character Q in a line signals the query of population. The following lines each contains four numbers: Xmin , Xmax , Ymin​ , Y​max , where (X​min ,Ymin ) and (Xmax ,Ymax ) are the integer coordinates of the lower left corner and the upper right corner of the rectangle, respectively. The character E signals the end of the test case.

Output

Each input file contains one test case. For each case, the character I in a line signals the coming in of new groups of people. In the following lines, each line contains three integers: X, Y, and N, where X and Y (1 ≤ X, Y ≤ 20000) are the coordinates of the region's center, and N (1 ≤ N ≤ 10000) is the number of people coming in. The character Q in a line signals the query of population. The following lines each contains four numbers: Xmin , Xmax , Ymin​ , Y​max , where (X​min ,Ymin ) and (Xmax ,Ymax ) are the integer coordinates of the lower left corner and the upper right corner of the rectangle, respectively. The character E signals the end of the test case.

Sample Input Copy

I
8 20 1
4 5 1
10 11 1
12 10 1
18 14 1
Q
8 10 5 15
E

Sample Output Copy

1

Source/Category