RAIN1  November Rain
Contemporary buildings can have very complicated roofs. If we take a vertical section of such a roof it results in a number of sloping segments. When it is raining the drops are falling down on the roof straight from the sky above. Some segments are completely exposed to the rain but there may be some segments partially or even completely shielded by other segments. All the water falling onto a segment as a stream straight down from the lower end of the segment on the ground or possibly onto some other segment. In particular, if a stream of water is falling on an end of a segment then we consider it to be collected by this segment.
For the purpose of designing a piping system it is desired to compute how much water is down from each segment of the roof. To be prepared for a heavy November rain you should count one liter of rain water falling on a meter of the horizontal plane during one second.
Task
Write a program that:
 reads the description of a roof,
 computes the amount of water down in one second from each segment of the roof,
 writes the results.
Input
The input begins with the integer t, the number of test cases. Then t test cases follow.
For each test case the first line of the input contains one integer n (1 <= n < = 40000) being the number of segments of the roof. Each of the next n lines describes one segment of the roof and contains four integers x_{1}, y_{1}, x_{2}, y_{2} (0 <= x_{1}, y_{1}, x_{2}, y_{2} < = 1000000, x_{1} < x_{2}, y_{1}<>y_{2}) separated by single spaces. Integers x_{1}, y_{1} are respectively the horizontal position and the height of the left end of the segment. Integers x_{2}, y_{2} are respectively the horizontal position and the height of the right end of the segment. The segments don't have common points and there are no horizontal segments. You can also assume that there are at most 25 segments placed above any point on the ground level.
Output
For each test case the output consists of n lines. The ith line should contain the amount of water (in liters) down from the ith segment of the roof in one second.
Example
Sample input: 1 6 13 7 15 6 3 8 7 7 1 7 5 6 5 5 9 3 6 3 8 2 9 6 12 8 Sample output: 2 4 2 11 0 3Warning: large Input/Output data, be careful with certain languages
hide comments
Daniel Siladji:
20120415 18:03:45
@sava: "...The segments don't have common points..." 

sava:
20120412 17:39:16
can roofs go trough each other? 
Added by:  adrian 
Date:  20040626 
Time limit:  2.742s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All 
Resource:  ACM Central European Programming Contest, Warsaw 2003 