#C4365. Find Communicating Students

    ID: 47895 Type: Default 1000ms 256MiB

Find Communicating Students

Find Communicating Students

You are given (n) students. Each student is enrolled in a set of courses. Two students can communicate if they share at least one common course. Your task is to determine if there exists any pair of students with at least one course in common. If such a pair exists, output "YES" followed by the 1-indexed positions of the two students. Otherwise, output "NO".

Input Format: The first line contains an integer (n) representing the number of students. Each of the next (n) lines starts with an integer (m) denoting the number of courses the student is taking, followed by (m) space-separated integers representing the course IDs.

Output Format: If a pair of students sharing at least one common course exists, print "YES" and the indices of the two students (with a space separating the indices). If there is no such pair, print "NO".

Note: The condition for two students (i) and (j) to communicate can be mathematically represented in LaTeX as: [ \text{Courses}_i \cap \text{Courses}_j \neq \varnothing.]

inputFormat

The input is given via standard input. The first line contains a single integer (n) (the number of students). Each of the following (n) lines begins with an integer (m), denoting the number of courses the student is enrolled in, followed by (m) integers representing the course IDs.

outputFormat

Print a single line to standard output. If there exists any pair of students sharing at least one course, output "YES" followed by two space-separated integers indicating the 1-indexed positions of the students. Otherwise, print "NO".## sample

3
2 101 102
1 103
3 102 104 105
YES 1 3

</p>