Airline Comparison

An 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. Given 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: • First line: the number N of flights in the catalog of the first company; • N subsequent lines: two uppercase alphabet characters separated by one space, for the names of the origin and destination cities of a flight; • Line N + 2: the number M of flights in the catalog of the second company; • M subsequent lines: two uppercase alphabet characters separated by one space, for the names of the origin and destination cities of a flight. Output For each test case, the output must follow the description below. The outputs of two consecutive cases will be separated by a blank line. One line containing ‘YES’ or ‘NO’ Sample Input 1 6 AB BE AE CF EC DA 7 AB DA EC CF DB BE DF

2/2 Sample Output YES