文理学院程序设计在线练习


Large bitmap

Time Limit: 1 Second(s)    Memory Limit: 32 MB

Total Submission(s): 9   Accepted Submission(s): 4
Problem Description

Rectangle is the most beautiful shape in the world!
Your task is to designed a tool to draw rectangles on a large bitmap. The bitmap is initially white(r = g = b = 255). Your tool should draw n rectangles in given order. Since the bitmap is too large to output, you are only required to output the color of a few pixels.

Input

The input consists of multiple test cases(<=10).
For each test case, the first line contains two integers n and m, indicating the number rectangles and pixels(0 <= n,m <=100). The next n lines each contains 7 integers x1, y1, x2, y2, r, g, b, indicating that pixel (x, y) should be painted with color RGB(r, g, b), where 0 <= x1 <= x2 < 2^32, 0 <= y1 <= y2 < 2^32 and 0 <= r,g,b <= 255. The last m lines each contains two integers x and y, indicating the pixel queried.
A test case with n = m = 0 indicates the end of input.

Output

For each test case, output "Case x:" in a single line first, where x is the case number. Then output m lines, each of which contains three integers separated by exact one space, indicating the RGB color of queried pixels.

Sample Input
1 2
0 0 2 3 127 196 200
1 2
3 0
2 3
8 16 32 64 0 255 128
8 48 32 64 255 0 0
12 47
13 48
14 64
0 0
Sample Output
Case 1:
127 196 200
255 255 255
Case 2:
0 255 128
255 0 0
255 0 0
Source

中国科大百分点科技杯ACM除夕挑战赛 2012