题目描述
You are asked by iPhone map service to help diagnose iPhone maps location diagrams to identify instances of MULTIPATH in a map. The following example illustrates MULTIPATH property. There are four location(Places):A, B, C and D. An arrow pointing from X to Y indicates that Location X can be reached from location Y.
In this map diagram, D can be reached from both B and C, B can be reached from A, and C also can be reached from A. An MULTIPATH from X to Y is defined as a sequence of mapes X, C1, C2, C3, ..., Cn, Y where X can be reached from C1, Ci can be reached from Ci + 1 for 1 < ≤ i < ≤ n - 1, and Cn can be reached from Y. There are two paths from D to A in the example above. The first path is D, B, A and the second path is D, C, A.
A map diagram is said to contain a multipath if there exists a pair of mapes X and Y such that there are at least two different paths from X to Y. The above map diagram is a classic example of multipath. Your task is to determine whether or not a given map diagram contains a MULTIPATH.
Input
The first line of the input gives the number of test cases, T. T test cases follow, each specifies a map diagram.
The first line of each test gives the number (Integer) of location or places in this diagram, N. The locations are numbered from 1 to N. N lines follow. The ith line starts with a non-negative integer Mi indicating the number of location that map i can be reached from. This is followed by Mi distinct positive integers each from 1 to N representing those locations. You may assume that:
If there is a path from X to Y then there is no path from Y to X.
A location will never be reached from itself.
Output
For each diagram, output one line containing "#x:y", where x is the number (starting from 1) and y is "Yes" if the map diagram contains a MULTIPATH, "No" otherwise.
Limits
1 ≤ T ≤ 50.
0 ≤ Mi ≤ 10.
dataset
1 ≤ N ≤ 1,000.
small testcase file updated
SAMPLE INPUT
3
3
1 2
1 3
0
5
2 2 3
1 4
1 5
1 5
0
3
2 2 3
1 3
0
SAMPLE OUTPUT
1:No
2:Yes
3:Yes
输入格式
见题面
输出格式
见题面