[Login|Register]
Problems

Status

Rank

Problem 1284
Large bitmap
Time Limit: 1000ms
Memory Limit: 65536kb
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.

For each test case, the first line contains two integers n and m, indicating the number rectangles and pixels(0 ≤ n,m ≤ 1000). 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 ≤ x1xx2 < 232, 0 ≤ y1yy2 < 232 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.

Output a blank line after each test case.

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
University of Science and Technology of China
Online Judge for ACM/ICPC
Processed in 1.6ms with 1 query(s).