You are given a system of pipes. It consists of two rows, each row consists of $n$ pipes. The top left pipe has the coordinates $(1, 1)$ and the bottom right — $(2, n)$.

There are six types of pipes: two types of straight pipes and four types of curved pipes. Here are the examples of all six types:

 [Image] Types of pipes 

You can turn each of the given pipes $90$ degrees clockwise or counterclockwise arbitrary (possibly, zero) number of times (so the types $1$ and $2$ can become each other and types $3, 4, 5, 6$ can become each other).

You want to turn some pipes in a way that the water flow can start at $(1, 0)$ (to the left of the top left pipe), move to the pipe at $(1, 1)$, flow somehow by connected pipes to the pipe at $(2, n)$ and flow right to $(2, n + 1)$.

Pipes are connected if they are adjacent in the system and their ends are connected. Here are examples of connected pipes:

 [Image] Examples of connected pipes 

Let's describe the problem using some example:

 [Image] The first example input 

And its solution is below:  [Image] The first example answer 

As you can see, the water flow is the poorly drawn blue line. To obtain the answer, we need to turn the pipe at $(1, 2)$ $90$ degrees clockwise, the pipe at $(2, 3)$ $90$ degrees, the pipe at $(1, 6)$ $90$ degrees, the pipe at $(1, 7)$ $180$ degrees and the pipe at $(2, 7)$ $180$ degrees. Then the flow of water can reach $(2, n + 1)$ from $(1, 0)$.

You have to answer $q$ independent queries.


-----Input-----

The first line of the input contains one integer $q$ ($1 \le q \le 10^4$) — the number of queries. Then $q$ queries follow.

Each query consists of exactly three lines. The first line of the query contains one integer $n$ ($1 \le n \le 2 \cdot 10^5$) — the number of pipes in each row. The next two lines contain a description of the first and the second rows correspondingly. Each row description consists of $n$ digits from $1$ to $6$ without any whitespaces between them, each digit corresponds to the type of pipe in the corresponding cell. See the problem statement to understand which digits correspond to which types of pipes.

It is guaranteed that the sum of $n$ over all queries does not exceed $2 \cdot 10^5$.


-----Output-----

For the $i$-th query print the answer for it — "YES" (without quotes) if it is possible to turn some pipes in a way that the water flow can reach $(2, n + 1)$ from $(1, 0)$, and "NO" otherwise.


-----Example-----
Input
6
7
2323216
1615124
1
3
4
2
13
24
2
12
34
3
536
345
2
46
54

Output
YES
YES
YES
NO
YES
NO



-----Note-----

The first query from the example is described in the problem statement.

Difficulty: introductory

Starter code:

Solutions:
ans = []
for _ in range(int(input())):
    n = int(input())
    s = list(input())
    t = list(input())
    lvl = 0
    X = [s, t]
    f = 1
    for i in range(n):
        if s[i] in '3456' and t[i] in '3456':
            lvl = 1 - lvl
        elif X[lvl][i] in '3456':
            f = 0
            ans.append('NO')
            break
    if f and lvl == 1:
        ans.append('YES')
    elif f:
        ans.append('NO')
print('\n'.join(ans))


for _ in range(int(input())):
    n = int(input())
    a = list(map('12'.__contains__, input().strip()))
    b = list(map('12'.__contains__, input().strip()))
    u, d = True, False
    for i in range(n):
        if a[i]:
            if not b[i]:
                d = False
        else:
            if b[i]:
                u = False
            else:
                u, d = d, u
        if not (u or d):
            break
    print('YES' if d else 'NO')


for i in range(int(input())):
  n=int(input())
  s1,s2=input(),input()
  b=[[int(s1[i]),int(s2[i])]for i in range(n)][::-1]
  a=1
  ans="YES"
  for i in b:
    if i[a]>2:
      if i[a^1]<3:ans="NO"
      else:a^=1
  if a!=0:ans="NO"
  print(ans)

q = int(input())

I = {'1', '2'}
V = {'3','4','5','6'}

for case in range(q) :
    n = int(input())
    a = ['$'+input(), '$'+input()]

    dp = [ [False for _ in range(1+n)],  [False for _ in range(1+n)] ]

    dp[0][0] = True

    for i in range(1, 1+n) :
        # print(a[0][i], a[1][i] in I)

        if a[0][i] in I : dp[0][i] = dp[0][i-1]
        if a[1][i] in I : dp[1][i] = dp[1][i-1]

        if a[0][i] in V and a[1][i] in V :
            dp[0][i] = dp[0][i] or dp[1][i-1]
            dp[1][i] = dp[1][i] or dp[0][i-1]

    print( "YES" if dp[1][n] else "NO" )


import sys
input = sys.stdin.readline

q=int(input())
for testcases in range(q):
    n=int(input())
    MAP=[list(map(int,list(input().strip()))) for i in range(2)]

    X=0
    Y=0
    fr=0 # from left ,1 from up or down

    while True:
        if X==n and Y==1:
            print("YES")
            break
        if X==n:
            print("NO")
            break
        
        if MAP[Y][X]<=2:
            if fr==0:
                fr=0
                X+=1
                
            else:
                print("NO")
                break
            
        else:
            if fr==0:
                fr=1
                Y+=1
                Y%=2
            else:
                X+=1
                fr=0

    


for i in range(int(input())):
	n = int(input())
	s1 = input()
	s2 = input()
	a = [s1, s2]
	lvl = 0
	f = True
	for i in range(n):
		if '1' <= a[lvl][i] <= '2':
			continue
		elif '1' <= a[(lvl + 1) % 2][i] <= '2':
			f = False
			break
		else:
			lvl = (lvl + 1) % 2
	
	print("YES" if f and lvl == 1 else "NO")


t = int(input())
for i in range(t):
    n = int(input())
    tubes = []
    for j in range(2):
        tubes.append(list(map(int, list(input()))))
    r = [0, 0]
    fl_ord = False
    while True:
        if tubes[r[0]][r[1]] <= 2:
            if fl_ord:
                print('NO')
                break
            else:
                r[1] += 1
        else:
            if fl_ord:
                r[1] += 1
            else:
                r[0] = 1 - r[0]
            fl_ord = not(fl_ord)
        if r == [1, n]:
            print('YES')
            break
        elif r == [0, n]:
            print('NO')
            break

q = int(input())

for _ in range(q):
    n = int(input())
    row1 = input()
    row2 = input()
    pos = (0, 0)

    turn = '3456'
    straight = '12'

    while pos != (1,n) and pos[1] < n:
        if pos[0] == 0:
            if row1[pos[1]] in turn:
                if row2[pos[1]] in turn:
                    pos = (1, pos[1]+1)
                else:
                    break
            else:
                pos = (0, pos[1]+1)
        elif pos[0] == 1:
            if row2[pos[1]] in turn:
                if row1[pos[1]] in turn:
                    pos = (0, pos[1]+1)
                else:
                    break
            else:
                pos = (1, pos[1]+1)

    if pos == (1,n):
        print('YES')
    else:
        print('NO')


a = int(input())
for i in range(a):
    b = int(input())
    c = input()
    d = input()
    l = [c, d]
    k = 0
    ans = 1
    for i in range(b):
        if l[k][i] == '1' or l[k][i] == '2':
            pass
        else:
            if l[1 - k][i] == "3" or l[1 - k][i] == "4" or l[1 - k][i] == "5" or l[1 - k][i] == "6":
                k = 1 - k
            else:
                ans = 0 
    if k == 1 and ans == 1:
        print('YES')
    else:
        print('NO')

for q in range(int(input())):
    n=int(input())
    s=[None,None]
    s[0]=input()
    s[1]=input()
    poss="YES"
    r=0
    for i in range(n):
        if s[r][i] in '12':
            continue
        elif s[r^1][i] not in '12':
            r^=1
        else:
            poss="NO"
            break
    if r==0:
        poss="NO"
    print(poss)

straight = set([1, 2])
nstraight = set([3, 4, 5, 6])

for _ in range(int(input())):
    n = int(input())
    r1 = [int(x) for x in input().strip()]
    r2 = [int(x) for x in input().strip()]

    poss = [True, False]
    for i in range(n):
        possnew = [False, False]
        if poss[0] and r1[i] in straight:
            possnew[0] = True
        if poss[1] and r2[i] in straight:
            possnew[1] = True
        if r1[i] in nstraight and r2[i] in nstraight:
            if poss[0]:
                possnew[1] = True
            if poss[1]:
                possnew[0] = True
        poss = possnew
    if poss[1]:
        print("YES")
    else:
        print("NO")

q=int(input())
for i in range(q):
    n=int(input())
    tube=[[0]*2 for i in range(n+1)]
    a=[int(x) for x in list(input())]
    b=[int(x) for x in list(input())]
    k=0
    for i in range(n):
        if a[i]==1 or a[i]==2:
            tube[i][0]=1
        if b[i]==1 or b[i]==2:
            tube[i][1]=1
    for i in range(n):
        if tube[i][k]==0:
            if tube[i][(k+1)%2]==0:
                k=(k+1)%2
            else:
                print('NO')
                break
    else:
        if k==0:
            print('NO')
        else:
            print('YES')
                      


for _ in range(int(input())):
    n = int(input())
    plum = [list(map(int, list(input()))), list(map(int, list(input())))]
    h = 0
    answer = "YES"
    for i in range(n):
        if plum[h][i] > 2:
            if plum[(h + 1) % 2][i] > 2:
                h = (h + 1) % 2
            else:
                answer = "NO"
                break
    if h != 1:
        answer = "NO"
    print(answer)




for _ in range(int(input())):
    n = int(input())
    s = []
    s.append(input())
    s.append(input())

    k = 0
    for i in range(n):
        if s[k%2][i] in ('1', '2'):
            continue

        if s[(k+ 1) % 2][i] not in ('3','4','5','6'):
            print("NO")
            break

        k += 1
    else:
        if k % 2 == 1:
            print("YES")
        else:
            print("NO")


q = int(input())
for _ in range(q):
	n = int(input())
	up = input()
	down = input()
	pipe = []
	pipe.append(up)
	pipe.append(down)
	pos = 0
	can = True
	for i in range(n):
		if(pipe[pos][i] > "2"):
			pos ^= 1
			if(pipe[pos][i] <= "2"):
				can = False
				break
	if pos == 0:
		can = False
	if(can):
		print("YES")
	else:
		print("NO")



def main():
    Q = int(input())
    data = []
    for _ in range(Q):
        N = int(input())
        S1 = [int(a) for a in list(input())]
        S2 = [int(a) for a in list(input())]
        data.append((N, [S1, S2]))

    A = [3, 4, 5, 6]
    B = [1, 2]
    for N, S in data:
        dp = [[0, 0] for _ in range(N+1)]
        dp[0][0] = 1
        for n in range(N):
            if S[0][n] in A and S[1][n] in A:
                dp[n+1][0] = dp[n][1] 
                dp[n+1][1] = dp[n][0]
            elif S[0][n] in B and S[1][n] in A:
                dp[n+1][0] = dp[n][0]
                dp[n+1][1] = 0
            elif S[0][n] in A and S[1][n] in B:
                dp[n+1][0] = 0
                dp[n+1][1] = dp[n][1]
            else:
                dp[n+1][0] = dp[n][0]
                dp[n+1][1] = dp[n][1]
        if dp[N][1] == 1:
            print("YES")
        else:
            print("NO")

def __starting_point():
    main()
__starting_point()

import heapq
import math

import sys
input = sys.stdin.readline

def li():return [int(i) for i in input().rstrip('\n').split()]
def value():return int(input())

def typ(a):
    if a<3:
        return 1
    return 2
for _ in range(int(input())):
    n = int(input())
    a = list(map(int,input().rstrip('\n')))
    b = list(map(int,input().rstrip('\n')))
    for i in range(n):
        a[i] = [a[i],b[i]]
    ans = 1
    currline = 0
    for i in range(n):
        if typ(a[i][currline]) == 2:
            currline = not currline
            if typ(a[i][currline]) == 1:
                ans = 0
                break
    if currline == 0:
        ans = 0
    if ans:print("YES")
    else:print("NO")


Q = int(input())
for q in range(Q):
    n = int(input())
    arr1 = [int(i) for i in input()]
    arr2 = [int(i) for i in input()]

    error = False
    now_x = 0
    now_y = 0
    was_x = -1
    #was_y = 0
    while now_x < n:
        #print(now_x)
        if now_y == 0:
            now = arr1[now_x]
        else:
            now = arr2[now_x]

        if True:
            if now in {1, 2}:
                if was_x == now_x:
                    error = True
                    break
                else:
                    was_x, now_x = now_x, now_x + 1
            else:
                if was_x == now_x:
                    was_x = now_x
                    #was_y = now_y
                    now_x += 1
                else:
                    was_x = now_x
                    #was_y = now_y
                    now_y = (now_y + 1) % 2

    if now_y == 0:
        error = True

    if error:
        print('NO')
    else:
        print('YES')



t = int(input())
for _ in range(t):
    n = int(input())
    s1=input()
    s2=input()
    s=[s1,s2]
    tp1,tp2=['1','2'],['3','4','5','6']
    cur=0
    for i in range(n):
        if s[cur][i] in tp1:
            continue
        else:
            if s[1-cur][i] in tp2:
                cur = 1-cur
            else:
                print("NO")
                break
    else:
        if cur==1:
            print("YES")
        else:
            print("NO")