LogiQuest

396. Same Tree

EasyRecursion

Print YES if the two binary trees are identical in structure and values, else NO.

Input format

Line 1: n1 Line 2: tree 1 in level order Line 3: n2 Line 4: tree 2 in level order

Output format

YES or NO

Example 1

Input

3
1 2 3
3
1 2 3

Output

YES

Example 2

Input

2
1 2
3
1 -1 2

Output

NO

Constraints

1 ≤ nodes ≤ 10⁴

Read input from standard input and print the answer to standard output. Your code is judged against 3 test cases, most of them hidden.

Loading the MyLoginn IDE…