#C744. Cow Race

    ID: 51311 Type: Default 1000ms 256MiB

Cow Race

Cow Race

You are given data for n cows. Each cow follows a path defined by a series of (x, y) coordinates representing the positions it visits during a race. The cow that visits the maximum number of unique positions wins. If more than one cow visits the same maximum number of unique positions, the cow with the smallest 1-indexed position is declared the winner.

More formally, let \(S_i\) be the set of distinct positions visited by the \(i^\text{th}\) cow. You need to determine the index \(i\) (with \(1 \leq i \leq n\)) for which \(|S_i|\) is maximized, and in case of a tie, choose the smallest such \(i\).

inputFormat

The input is read from stdin and has the following format:

  • The first line contains one integer \(n\) (the number of cows).
  • For each cow, the first line contains an integer \(k\) representing the number of positions in that cow's path.
  • This is followed by \(k\) lines, each containing two integers \(x\) and \(y\), representing a position visited by the cow.

outputFormat

Output a single integer to stdout — the 1-indexed number of the cow that has visited the maximum number of unique positions. If there is a tie, output the smallest index among those.

## sample
3
4
1 1
2 2
1 1
3 4
3
5 6
5 6
5 6
5
7 8
7 8
8 9
9 10
10 11
3

</p>