Detective Conan

No attempts yetTime limit1sMemory limit128 MB

Problem

Conan is a detective in the city of ACM. Not long ago a rare book was stolen from the library of ACM City University. On the day of the theft many students visited the library. Each student entered exactly once, stayed for a single continuous stretch of time, and then left.

We assume that whenever two students were in the library at the same time, at least one of them saw the other. Conan met every student who had been to the library that day and asked each of them whom they saw inside. He now wants to decide whether the testimony he collected could match some real set of visits under this assumption.

For example, suppose four students visited the library and gave this testimony:

  • Student 1 saw Student 4 and Student 2.
  • Student 2 saw Student 3.
  • Student 3 saw Student 2 and Student 4.
  • Student 4 saw Student 1.

This testimony cannot happen. Student 2 and Student 4 did not see each other, so their visits did not overlap and they were in the library at different times. Yet Student 1 saw both of them, so Student 1's visit had to overlap Student 2's visit and Student 4's visit; the same holds for Student 3. That forces Student 1 and Student 3 to have been present at the same moment, so at least one of them should have seen the other. Neither did, which is a contradiction.

For a second example, suppose three students visited and gave this testimony:

  • Student 1 saw Student 3 and Student 2.
  • Student 2 saw Student 1.
  • Student 3 saw Student 2.

This testimony is possible. It happens, for instance, if all three students were in the library at the same time.

Given such a testimony, write a program that decides whether the situation could really have occurred under the assumption above.

Input

The first line contains the number of test cases TT. Each test case has the following form.

The first line of a test case contains a single integer nn, the number of students, with 1n2001 \le n \le 200. The next nn lines describe the testimony. The ii-th of these lines begins with an integer kk, the number of students that Student ii says he saw, followed by the kk ids of those students. If Student ii saw no one, the line contains only 00. Students are numbered from 11 to nn, and the integers on each line are separated by spaces.

Output

For each test case print exactly one line. Print YES if the testimony could correspond to a real set of visits, and NO otherwise.