7117 - PB: DonDon's game   

Description

DonDon wants to design a game. In this game, there are many cities and many roads.

If the road is from city A to city B, you can only walk from A to B, but not B to A.

Since the map of the game is too large, can you write a program for DonDon to test whether there is a path from A to B?

Input

The first line of the input file contains an integer indicating the number of test cases to follow.

Then a blank line follows.

For each test case:

The first line contains 1 integer N. (0 < N < 500)

Then N lines follows. Each line is a name of a city. ( 0 < the length of city name < 10 )

After the N lines, the next line contains one integer M, which is the amount of roads, and then the starting city A and the destination B.

Then M lines follows. Each line contains 2 name of city, s and f, indicating that there is a road from city s to city f.

There is an blank line after each test case.

Output

For each test case output a single line.

If there is a way from the starting city A to the destination B, output "Yes".

Otherwise, "No".

Sample Input  Download

Sample Output  Download

Tags




Discuss