cho.sh
Notes
Loading...

Cutting a Square

Time limit

2s

Memory limit

128 MB

Problem

On the coordinate plane, there is a square whose four vertices are (10, 10), (10, -10), (-10, -10), and (-10, 10).

You draw line segments whose two endpoints are both outside the square. These segments may divide the square into several regions. No three segments meet at the same point, and no two segments lie on the same line.

Given the number of segments N and the coordinates of both endpoints of each segment, determine how many regions the square is divided into by these segments.

Input

The first line contains the number of segments N.

Each of the next N lines contains four integers x1, y1, x2, and y2, describing the segment that connects (x1, y1) and (x2, y2).

N is a positive integer no greater than 100, and each of x1, y1, x2, and y2 is an integer between -1000 and 1000, inclusive. Both endpoints of every segment are outside the square.

Output

Print the number of regions into which the given segments divide the square.