題目來源:judgegirl from ntu prof. pangfeng Liu
Task Description
National Taiwan University wants to enforce bicycle parking regulations by moving illegally parked bicycles to remote parking lots. There are parking lots for these illegally parked bicycles. The -th parking lot is located at and has a capacity of bicycles. The university moves an illegally parked bicycle to the nearest parking lot. The distance between a bicycle and a parking lot is the sum of their absolute value in and coordinates. For example, the distance between and is . If there are two nearest parking lots, we choose the one with a smaller coordinate. If the coordinates are the same, we choose the one with a smaller coordinate. If all nearest parking lots are full, that is, already have their capacity of bicycles, we move the bicycle to one of the second nearest parking lots, and so on. We assume that the total capacity of all parking lots is sufficient for all illegally parked bicycles. Given the locations and capacity of all parking lots, please determine the parking lots a sequence of illegally parked bicycles will go to.
Input
The first line of the input is the number of parking lots . Each of the following lines has the , coordinate, and the capacity of a parking lot. The next line has an integer , the number of illegally parked bicycles. Each of the next lines has the and coordinates of the bicycle. We move the bicycles according to the order in the input.
Output
The output has lines. The -th line is the number of bicycles in the -th parking lots after moving all bicycles to the parking lots.
Bounds
- is positive and no more than 10.
- is positive and no more than 100000.
- The and coordinates are all between -10000 and 10000.
Sample input
2
1 1 1
100 100 100
3
0 0
2 2
3 3
Sample output
1
2