MLE '19 Contest 4 P10 - ISO

View as PDF

Points: 7
Time limit: 2.0s
Memory limit: 128M

Author:
Problem type

Given two bidirectional graphs and , can you determine if they are isomorphic?

Input Specification

The first line will contain two integers, , the number of nodes and edges in graph and graph , respectively.

The next lines will each contain two integers, , denoting nodes and are connected by an edge in graph . There may be self-loops and duplicate edges between two nodes.

The next lines will each contain two integers, , denoting nodes and are connected by an edge in graph . There may be self-loops and duplicate edges between two nodes.

Output Specification

Output 1 if graphs and are isomorphic. Otherwise, output 0.

Sample Input

5 4
1 2
2 3
3 4
4 5
5 4
4 3
3 2
2 1

Sample Output

1