cho.sh
Notes
Loading...

Number of Drawings

Time limit

2s

Memory limit

128 MB

Problem

A polyline is a shape made by connecting several points in order with continuous line segments. The endpoint of one segment is the starting point of the next segment.

If two polylines share at least one point, they belong to the same drawing. A shared point may be a vertex, an intersection point on the segments, or any point in an overlapping segment.

Given T polylines, find the number of separate drawings.

Input

The first line contains the number of polylines T.

For each polyline, the first line contains N, the number of points in that polyline. The next N lines contain the point coordinates x y in order.

N may be 1. T is less than 1000, and N is less than 500. Every coordinate is an integer from 0 to 10000, inclusive.

Output

Print the number of drawings on the first line.