You are given $n$ sets $S_1,S_2,\ldots,S_n$, where each element in the sets is an integer between $1$ and $m$.
You want to choose some of the sets (possibly none or all), such that every integer between $1$ and $m$ is included in at least one of the chosen sets.
You have to determine whether there exist at least three ways to choose the sets.
Input
Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.
The first line of each test case contains two integers $n$ and $m$ ($2 \leq n \leq 5\cdot 10^4$, $1\le m \leq 10^5$) — the number of sets and the upper bound of the integers in the sets.
Then $n$ lines follow, the $i$-th line first containing an integer $l_i$ ($1\le l_i\le m$) — the size of set $S_i$.
Then $l_i$ integers $S_{i,1}, S_{i,2}, \ldots, S_{i, l_i}$ follow in the same line ($1\le S_{i,1} \lt S_{i,2} \lt \cdots \lt S_{i, l_i}\le m$) — the elements of set $S_i$.
Let $L=\sum\limits_{i=1}^n l_i$. It is guaranteed that:
- The sum of
$n$over all test cases does not exceed$5\cdot 10^4$; - The sum of
$m$over all test cases does not exceed$10^5$; - The sum of
$L$over all test cases does not exceed$2\cdot 10^5$.
Output
For each test case, print "YES" if there exist at least three ways to choose the sets. Otherwise, print "NO".
You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.
Note
In the first test case, there are $5\ge 3$ possible ways to choose the sets:
$S_1$— both$1$and$2$are included in$S_1$;$S_1$and$S_2$—$1$is included in$S_1$and$S_2$, and$2$is included in$S_1$;$S_1$and$S_3$—$1$is included in$S_1$, and$2$is included in$S_1$and$S_3$;$S_2$and$S_3$—$1$is included in$S_2$, and$2$is included in$S_3$;$S_1$,$S_2$, and$S_3$—$1$is included in$S_1$and$S_2$, and$2$is included in$S_1$and$S_3$.
Note that it is invalid to choose $S_2$ only because $2$ is not included in $S_2$.
In the second test case, the only way is to choose all the sets.
In the third test case, $5$ does not appear in any of the sets, so there is no way to choose the sets.
In the fourth test case, choosing any non-empty collection of the sets is valid, so the number of ways is $2^5-1=31\ge3$.
样例
6
3 2
2 1 2
1 1
1 2
4 10
3 1 2 3
2 4 5
1 6
4 7 8 9 10
2 5
4 1 2 3 4
4 1 2 3 4
5 5
5 1 2 3 4 5
5 1 2 3 4 5
5 1 2 3 4 5
5 1 2 3 4 5
5 1 2 3 4 5
5 10
4 1 2 3 4
5 1 2 5 6 7
5 2 6 7 8 9
4 6 7 8 9
2 9 10
5 5
1 1
1 2
1 3
2 4 5
1 5
YES
NO
NO
YES
YES
NO
题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。