Dating
시간 제한3초메모리 제한2048 MB
각 사용자가 좋아하는 활동 집합이 주어질 때, 공통 활동이 있으면서 서로가 상대만 좋아하는 활동을 하나씩 가진 두 사용자를 찾아 출력한다.
문제
You are the developer of a dating app which ignores gender completely. The app has users, indexed from to . Each user’s profile features a list of the activities they enjoy doing. There are possible activities, indexed from to .
A match between two users is good if they share at least one activity and, at the same time, both of them like at least one activity that the other user does not like.
Find a good match if it exists.
입력
The first line contains two integers and (, ) — the number of users and the number of activities.
Each of the following lines contains a number () — the number of activities that user likes — followed by distinct integers from to — the activities user likes.
It is guaranteed that does not exceed .
출력
Print YES if a good match exists. Otherwise, print NO.
If a good match exists, on the next line print two integers — the indexes of two users that make a match.