#P1015. Merging the Sets —— 合并集合

Merging the Sets —— 合并集合

Statement

You are given nn sets S1,S2,,SnS_1,S_2,\ldots,S_n, where each element in the sets is an integer between 11 and mm.

You want to choose some of the sets (possibly none or all), such that every integer between 11 and mm 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

The first line of each test case contains two integers nn and mm (2n51042 \leqslant n \leqslant 5\cdot 10^4, 1m1051\leqslant m \leqslant 10^5) — the number of sets and the upper bound of the integers in the sets.

Then nn lines follow, the ii-th line first containing an integer lil_i (1lim1\leqslant l_i\leqslant m) — the size of set SiS_i.

Then i\ell_i integers Si,1,Si,2,,Si,iS_{i,1}, S_{i,2}, \ldots, S_{i, \ell_i} follow in the same line ($1\leqslant S_{i,1} < S_{i,2} < \cdots < S_{i, \ell_i}\leqslant m$) — the elements of set SiS_i.

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.

Samples

3 2
2 1 2
1 1
1 2
YES
4 10
3 1 2 3
2 4 5
1 6
4 7 8 9 10
NO
2 5
4 1 2 3 4
4 1 2 3 4
NO
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
YES
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
YES
5 5
1 1
1 2
1 3
2 4 5
1 5
NO

Note

In the first test case, there are 535\geqslant 3 possible ways to choose the sets:

  • S1S_1 — both 11 and 22 are included in S1S_1;
  • S1S_1 and S2S_211 is included in S1S_1 and S2S_2, and 22 is included in S1S_1;
  • S1S_1 and S3S_311 is included in S1S_1, and 22 is included in S1S_1 and S3S_3;
  • S2S_2 and S3S_311 is included in S2S_2, and 22 is included in S3S_3;
  • S1S_1, S2S_2, and S3S_311 is included in S1S_1 and S2S_2, and 22 is included in S1S_1 and S3S_3.

Note that it is invalid to choose S2S_2 only because 22 is not included in S2S_2.

In the second test case, the only way is to choose all the sets.

In the third test case, 55 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 251=3132^5-1=31\geqslant 3.