The Partition of a Cake

Time Limit: 10 Seconds    Memory Limit: 32768 KB

There is a 1000*1000 square cake. We use knife to cut the cake. The problem is after a series of cutting, how many partitions the cake will has.


The number of the cutting will be no more than 8.

After the cutting, the length of any edge of the partition will no less than 1.

The vertex coordinates of the cake are (0,0)(0,1000)(1000,1000)(1000,0).

The intersections of the cut line and the cake edge are two.

The following Graph is a sample partition. The number of the partitions is 10.


The first line of the input is the number of the cutting. The following lines contain the information of the cut lines. Each line has 4 integer number, which represent the coordinate of the intersection of the line and the cake edge. After last cake is 0.


The output is the number of the partitions of the cake.

Sample Input

0 0 1000 1000
500 0 500 1000
0 500 1000 500
0 0 1000 1000

Sample Output


Source: Asia 1996, Shanghai (Mainland China)