Of Circles and Squares

We have placed a number of circles and squares on an infinite stretch of a 2D plane. These circles and squares come in various sizes and colors. But when we place more than one ob- ject together, the color in the common region of those objects becomes a mixture of the origi- nal color. We define the color of each geometric object by the 8 bit value of the Red, Green and Blue components. For example, a circle drawn in pure red would have the color (255,0,0). The borderline of each geometric object is drawn in black (0,0,0), and the empty spaces are always white (255,255,255). Given a number of such geometric objects and some points in the 2D plane, your task is to determine the color of the points. The color of a point is computed as the average red, average green and average blue values of the geometric objects that this point falls into. If the point is on the borderline of any of the geo- metric object, then its color would be black; if it falls in the empty space, the color of the point would be white. Input The first line of input gives you the number of test cases T (T ≤ 100) to follow. Each test case starts with two integers, R and P. R (R ≤ 100) is the number of geometric objects and P (P ≤ 100) is the number of query points. Then there will be R lines describing the objects. The description of each geometric object follows the object_type px py length r g b format. object_type is the type of the geometric object, which can be ‘CIRCLE’ or ‘SQUARE’. px and py (−1000 ≤ px, py ≤ +1000) are two integers giving you the x and y coordinate of the center of the circle or the lower left corner of the square depending on the object type. length (0 ≤ length ≤ 2000) is the radius of the circle or the length of a side if it is a square. The r, g and b (0 ≤ r,g,b ≤ 255) values are integers giving you the color of the object. The description of the query points starts after the description of the objects. Each query point is denoted by an integer pair px and py (−1000 ≤ px, py ≤ 1000) giving you the x and y coordinate of that point. Output For each test case, print the serial number of the test case first. Then for each of the query points, print the color of that point in one line. All the colors are to be rounded to the nearest integer (for example: 128.3 will be rounded to 128, 128.5 will be rounded to 129 and 128.7 will also be rounded to 129). There must be a blank line separating two test cases. Please consult the sample input/output section for the exact format. Sample Input 2

2/2 11 SQUARE 0 0 5 0 0 0 05 33 CIRCLE 0 0 5 10 10 10 SQUARE 1 1 5 255 10 10 CIRCLE 5 5 3 0 0 0 56 65 85 Sample Output Case 1: (0, 0, 0) Case 2: (0, 0, 0) (0, 0, 0) (0, 0, 0)