프로그램 명: ceoi_race(special judge)
제한시간: 3 초
//sj가 아직...

The annual sailing race is organized on a round shape lake. There are N harbors, numbered from 1 to N around the lake counterclockwise. The race consists of several stages, where each stage runs on a straight line from one harbor to another, and the race track can only meet a harbor at most once. The organizers want to create a race track that contains the highest possible number of stages.

They must keep in mind that a sailboat at a given harbor may only go to some specific harbors on a direct route. Fortunately, for each harbor A they have the list of direct destinations from A, i.e. a list of other harbors to which a sailboat can go on a straight line from A. Generally, the race track consists of non-intersecting stages, to avoid the collision of sailboats. This year, however, a new technology is available, with which one crossing may be allowed if it lies on the first stage. So if the race track starts at harbor S and the next harbor in the track is T then at most one stage can cross the first stage S-T. The organizers may decide to allow a crossing like this, or rather choose the classical design with non-intersecting stages.

Task

You are to write a program that computes a race track of the given type containing the highest possible number of stages.

입력

출력

If there are multiple solutions, your program should output only one; it does not matter which one.

입출력 예

입력

7 1
5 0
5 0
7 0
3 0
4 0
4 3 0
2 1 0

출력

5
2


출처:ceoi 2012

[질/답] [제출 현황] [푼 후(0)]
[ 채 점 ] [홈으로]  [뒤 로]