2674. Webby Subway

单点时限: 5.0 sec

内存限制: 256 MB

You are an ocer of the Department of Land and Transport in Oykot City. The department has a plan to uild a subway network in the city central of Oykot.

In the plan, n subway lines are built, and each line has two or more stations. Because of technical roblems, a rail track between two stations should be straight and should not have any slope. To make hings worse, no rail track can contact with another rail track, even on a station. In other words, two ubways on the same floor cannot have any intersection.

Your job is to calculate the least number of required floors in their plan.

输入格式

The input consists of multiple datasets. Each dataset is formatted as follows:

N

Line1

Line2

: : :

LineN

Here, N is a positive integer that indicates the number of subway lines to be built in the plan (N <= 22) ,and Linei is the description of the i-th subway line with the following format:

S

X1 Y1

X2 Y2

: : :

XS YS

S is a positive integer that indicates the number of stations in the line (S <= 30), and (Xi; Yi) indicates the coordinates of the i-th station of the line (-10000 <= Xi, Yi <= 10000). The rail tracks are going to be built between two consecutive stations in the description. No stations of the same line have the same

coordinates.

The input is terminated by a dataset of N = 0, and it should not be processed.

输出格式

For each dataset, you should output the least number of required floors.

样例

Input
2
2
0 0
10 0
2
0 10
10 10
2
2
0 0
10 10
2
0 10
10 0
3
2
0 0
10 10
2
0 10
10 0
2
1 0
1 10
0
Output
1
2
3

2 人解决,2 人已尝试。

2 份提交通过,共有 5 份提交。

8.2 EMB 奖励。

创建: 15 年,2 月前.

修改: 7 年,2 月前.

最后提交: 11 年前.

来源: Japan

题目标签