Pyragrid

The great innovators of the great pyramid have another great new idea. They are now planning to build pyragrids — number of pyramid like stuffs assorted on a grid. What makes it even more interesting is the item they are making the grid with — bamboo. They have a huge field that can be treated as a 2D Cartesian plane. Let’s assume the lower left corner of the field has co-ordinate (−100, −100) while the upper right corner is (100,100). A number of bamboo sticks (You can safely assume that even on that land of ideas, none has tried the weird idea of bending a bamboo stick. So, the sticks will be always straight) are placed on this field. There are two mechanical restrictions which must be met while placing bamboos. Firstly, the endpoint of a bamboo stick must be put on a grid point. Second, the sticks must be either lie parallel or form a 45 degree angle with one of the axes. These sticks intersect at different points and form a criss-crossed grid of irregular shaped cells. By the way, two bamboo sticks can overlap i.e. one stick can be placed on top of another one. I forgot to tell you, these new pyargrids have triangle shaped base, unlike the square shaped bases of the original pyramid. So, you can build a pyragrid on a cell only if the cell has triangular shape. You need to determine the number of possible cells on the grid where a pyragrid can be built. Input First line of each test case contains an integer N (1 ≤ N ≤ 100), the number of bamboo sticks. Each of the next N lines has 4 integers, x1, y1, x2 & y2 (−100 ≤ x1, y1, x2, y2 ≤ 100), where (x1, y1) are the co-ordinates of one end point of the bamboo stick while (x2,y2) are that of the other end. A stick will have length greater than 0. The end of input will be denoted by a case with N = 0. This case should not be processed. Output For every test case except the last one, print one line of the form ‘Case X: Y ’, where X is the serial of output (starting from 1) and Y is the number of possible unique cells where a pyragrid can be placed. Sample Input 3 0050 0055 0550 5 0022 1133 0020 1120 2220 0 Sample Output Case 1: 1 Case 2: 3