#P8252. Simulated Contest Discussion Pair

    ID: 21431 Type: Default 1000ms 256MiB

Simulated Contest Discussion Pair

Simulated Contest Discussion Pair

There are \( n \) participants in a simulated contest, and the contest has \( n \) problems. For each participant \( i \), let \( S_i \) be the set of problems that person solved. Two persons \( x \) and \( y \) will discuss if and only if both know at least one common problem (i.e. \( S_x \cap S_y \neq \varnothing \)) and neither's set is a subset of the other's (i.e. \( S_x \nsubseteq S_y \) and \( S_y \nsubseteq S_x \)).

Your task is to find a pair of participants that will discuss, or determine that no such pair exists.

Note: The participants are numbered from 1 to \( n \).

inputFormat

The first line contains an integer \( n \) (the number of participants and problems).

Each of the next \( n \) lines begins with an integer \( k \) (the number of problems solved by that participant), followed by \( k \) space-separated integers representing the problem IDs that the participant solved.

outputFormat

If there exists a valid pair of participants \( (x, y) \) that will discuss, print two integers \( x \) and \( y \) (1-indexed). Otherwise, print -1.

sample

3
3 1 2 3
2 2 4
2 3 5
1 2