P8252 [NOI Online 2022 Senior] Discussion

Background

**After consideration by the administrators, we plan to store the community testdata separately in the last Subtask. The score of these test points is 0, but failing any of these test points will be considered as not passing this problem.** **In this problem, there is an issue where the test point numbers in judge records appear disordered. This is caused by a naming conflict in the community testdata. However, we guarantee that their relative order is not messed up.** Community testdata provider: @AutumnKite, strengthened by @tiger2005.

Description

There are $n$ people taking a mock contest, and the mock contest has $n$ problems. Two people will discuss only when there are problems that both of them can solve, and neither person’s set of solvable problems contains the other’s. (Define the set of problems that person $i$ can solve as $S_i$. That is, when $S_x\cap S_y\neq\varnothing\land S_x\not\subseteq S_y\land S_y\not\subseteq S_x$, person $x$ and person $y$ will discuss.) To make the mock contest more effective, please find a pair of people who will discuss, or determine that none exist.

Input Format

The first line contains a positive integer $T$, the number of test cases. For each test case: The first line contains a positive integer $n$, the number of people and the number of problems. Then follow $n$ lines. In the $i$-th line, the first natural number $k_i$ indicates that the $i$-th person can solve $k_i$ problems. Then there are $k_i$ positive integers; each integer $x$ means that the $i$-th person can solve problem $x$.

Output Format

For each test case: If there is no pair of people who will discuss, output `NO`. Otherwise, output `YES` on the first line, and output two positive integers $x$ and $y$ on the second line, indicating that person $x$ and person $y$ will discuss. If there are multiple solutions, output any one.

Explanation/Hint

**[Sample 2]** See `discuss/discuss2.in` and `discuss/discuss2.ans` in the attachment. **[Constraints and Hints]** For all test points: let $m=\sum k_i$ in a test case. Then $1\le T\le 5$, $1\le \sum n\le {10}^6$, $1\le \sum m\le 2\times {10}^6$, and $0\le k_i\le n$. The specific limits for each test point are shown in the table below: ![](https://cdn.luogu.com.cn/upload/image_hosting/zmkoxviw.png) Translated by ChatGPT 5