Airline Comparison
BackgroundAn airline catalog consists of a list of flights between pairs of cities. A trip may be built by sequencing flights. Two airline companies are equivalent if they offer connections between the same pairs of cities, irrespective of the number of scales in between.
ProblemGiven the catalogs of two airline companies, determine if they are equivalent or not.
Input The input begins with a single positive integer on a line by itself indicating the number of the cases following, each of them as described below. This line is followed by a blank line, and there is also a blank line between two consecutive inputs.
The input contains:
One line containing YES or NO
Sample Input
1
6
A B
B E
A E
C F
E C
D A
7
A B
D A
E C
C F
D B
B E
D F
Sample Output
YES