cho.sh
Notes
Loading...

Polygon Count

Time limit

2s

Memory limit

128 MB

Problem

Given line segments whose endpoints have integer coordinates, draw all of them on paper. Compute how many polygons are formed using only those segments.

A polygon here means one simple closed figure made from at least three line segments. New regions that appear only because two polygons overlap or cross are not counted as polygons. Only closed figures made directly from the input segments are recognized.

Also, if a line segment that is not part of a closed figure is connected to that figure, the closed figure is not considered a polygon.

Input

The first line contains the number of line segments N, where 1 <= N <= 60.

Each of the next N lines describes one segment. A line contains, in order, the x-coordinate and y-coordinate of one endpoint, followed by the x-coordinate and y-coordinate of the other endpoint.

All coordinates are non-negative integers not greater than 10000.

Output

Print the number of polygons on the first line.