Speleology

No attempts yetTime limit3sMemory limit512 MB

Problem

A team of speleologists holds a training session in the Great Cave of the Byte Mountains. During the training, each speleologist explores one route from the Top Chamber to the Bottom Chamber. A speleologist may move downward only: every chamber along a route must lie strictly below the previous one.

In addition, each speleologist must leave the Top Chamber through a different corridor, and each of them must enter the Bottom Chamber through a different corridor. The corridors in between may be used by more than one speleologist. What is the maximum number of speleologists that can train at the same time?

Write a program that:

  • reads the description of the cave from standard input,
  • computes the maximum number of speleologists that can train simultaneously,
  • writes the result to standard output.

Input

The first line contains one integer nn (2n2002 \le n \le 200), the number of chambers in the cave. The chambers are numbered from 11 to nn from top to bottom: a chamber with a larger number lies lower (at a lower level), the Top Chamber is number 11, and the Bottom Chamber is number nn. Every corridor always leads from a lower-numbered chamber to a higher-numbered one, that is, downward.

Each of the next n1n-1 lines (lines 22 through nn) describes one chamber: line i+1i+1 describes chamber ii. It begins with an integer mm (0mni+10 \le m \le n-i+1), the number of corridors leaving chamber ii, followed by the numbers of the mm chambers those corridors lead to. All of these numbers are greater than ii.

Output

Print a single integer on one line: the maximum number of speleologists that can train simultaneously.

Hint