Catch the Criminals
Time Limit: 1 Second Memory Limit: 32768 KB
Nowadays there are hundreds of thousands of computers and the connections between them are extremely complicated. This makes our life much more better but at the same time it is also used by criminals. It adds difficulties to the policemen because they don't know where do the criminals hide in.
Recently, the policemen got an important clue from the thieves act from inside. It includes all the personal relationships between the criminals and also tells that they only use computer network to communicate with each other and only use direct cable connection for the secrecy purpose.
The policemen quickly took out a map which includes all the positions of computers in the city and all the connections between them. They started to figure out whether a certain subset of computers probably be used by the criminals. After figuring out all the possible subsets, the policemen can decide which computers they have to raid inorder to catch all the criminals at once.
But they soon found out that it is too hard for them to do it manually. So they now ask you to help them.
Input
There are multiple testcases. The first line of input is T, the number of testcases, followed by T testcases. Each testcase consists of two sections. The first section begins with two integers C(1<=C<=20) and N, indicating the number of computers and the number of cable lines. Then followed by N lines, each of which consists of two integers a and b, indicating there is a connection between computer a and b(computers are named from 0 to C-1). Then follows the second section, which begins with two integers E(1<=E<=5) and M, indicating the number of criminals and the number of relationships. Then followed by M lines, each of which consists of two integers a and b, indicating there is a relationship between a and b(criminals are named from 0 to E-1).
Output
If none of possible subset was found, print "Wrong information." in one line, otherwize output the name of the computers that the policemen have to raid in ascending order. All the names should be in one line and separate them with exact one space.
Sample Input
1 7 8 0 1 0 3 1 2 2 3 2 4 2 5 4 6 5 6 4 4 0 1 1 2 2 3 3 0
Sample Output
0 1 2 3 4 5 6Submit
Source: ZOJ Monthly, February 2005