Problem1065--The same pairs

1065: The same pairs

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 128 MiB

Description

Given a 2 x N grid board, on each grid, there is a number from 0 to 9, you want to know if it is possible to choose 2 x 1 or 1 x 2 pairs from the board such that no pairs
are repeated -- that is, such that no pairs consist of the same integers in either order (so [1,2] is the same as [2,1]). For example:
given N = 3 and the board:
421
312 
The answer is YES  (you can make the pairs (4 2) (3 1) and (1 2) 
given N = 4 and the board:
4245
1362
The answer is YES ( one way is (4 1) (2 4) (5 2) (3 6) )
given N = 4 and the board:
4241
1824
The answer is NO


Input

The first line is one integer N   ( 1 <= N <= 25 )
the second and third line each contains N integers 

Output

YES or NO

Sample Input Copy

4
4245
1362

Sample Output Copy

YES

Source/Category