TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

Two graphs G_1 and G_2 are said to be isomorphic
if we can find a one-to-one mapping of vertex index vG_1i --> vG_2map(i)
where haveEdgeG_1(i,j) = haveEdgeG_2(map(i),map(j)).
Your job is to figure out whether two given undirected graphs are isomorphic or not.

Input Format

The first line contains T<50, indicating the number of test cases.

Every case begins with n<50, m, where n denotes the number of vertices in both graphs and m denotes the number of edges in both graphs. Each of the following m lines contains 2 numbers a_1, a_2, denoting there is an edge between the two nodes a_1 and a_2 in graph G_1. The last m lines are of the same format but representing G_2.

Output Format

For each case, output "Yes" if the two graphs are isomorphic, or "No" otherwise.

Sample Input 1

2
3 2
0 1
0 2
2 0
2 1
4 4
0 1
1 2
2 3
3 0
0 1
1 2
2 3
2 0

Sample Output 1

Yes
No

Hints

Problem Source

Migrated from old NTUJ.

pP

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 65536 200