Isomorphic?

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

You are given two undirected simple connected graphs GG and GG'. Each graph consists of NN vertices numbered from 11 to NN and NN edges.

Are these graphs isomorphic? In other words, is there a permutation (p_1,,p_N)(p\_1, \dots , p\_N) of (1,,N)(1, \dots , N) such that GG has an edge which connects two vertices uu and vv if and only if GG' has an edge which connects p_up\_u and p_vp\_v?

입력

The input consists of a single test case of the following format.

NN

a_1a\_1 b_1b\_1

\vdots

a_Na\_N b_Nb\_N

c_1c\_1 d_1d\_1

\vdots

c_Nc\_N d_Nd\_N

The first line contains a single integer NN (3N2×1053 ≤ N ≤ 2 \times 10^5), which represents the number of vertices of graphs GG and GG'. Each of the next NN lines contains two integers a_ia\_i and b_ib\_i (1a_i,b_iN1 ≤ a\_i, b\_i ≤ N), which represent that there is an undirected edge connecting vertices a_ia\_i and b_ib\_i of GG. Similarly, each of the next NN lines contains two integers c_ic\_i and d_id\_i (1c_i,d_iN1 ≤ c\_i, d\_i ≤ N), which represent that there is an undirected edge connecting vertices c_ic\_i and d_id\_i of GG'. You can assume that both GG and GG' are connected graphs and do not contain self-loops and double edges.

출력

Print “Yes" if GG and GG' are isomorphic. Print “No", otherwise.