|Source : ACM ICPC Central European Regional 1996|
|Time limit : 3 sec||Memory limit : 32 M|
Submitted : 79, Accepted : 49
Factory management needs to predict the number of holes in the plate at the end of the given sequence of cuts. Write a program that answers this question. Single segment cuts are not considered to be holes.
Here there are examples of some situations that can arise after cutting:
two holes two holes one hole one hole
The input consists of blocks of lines. Each block except the last describes one cutting process. In the first line of the block there is a number N <= 100 indicating the number of segment cuts in the cutting process. These cuts are defined by the following N lines. The line defining one segment cut has the form X1 Y1 X2 Y2 where X1 Y1 and X2 Y2 are the co-ordinates of the end points of the segment cut. They are separated by one space. The co-ordinates are integers and always define horizontal or vertical segment (i.e. segment parallel with x or y axis).
The last block consists of just one line containing 0.
The output contains the lines corresponding to the blocks in the input. Each such line contains the number of holes that remain in the tin plate after the execution of the corresponding cuts.
There is no line in the output corresponding to the last ``null'' block of the input.
4 0 1 1 1 1 1 1 0 1 0 0 0 0 0 0 1 2 0 1 2 1 1 2 1 0 0