당신은 파이프 시스템을 제공하고 있습니다. 그것은 두 개의 행으로 구성되어, 각 행의 구성 N N 파이프. 왼쪽 상단 파이프 좌표 갖는 ( 1 , 1 ) - (1,1) 및 하부 우측 ( 2 , N ) (2, N)를.
직선 파이프의 두 가지 유형 및 곡선 파이프의 네 가지 유형 : 파이프의 여섯 종류가 있습니다. 다음은 모두 6 가지 유형의 예입니다 :
사용자는 주어진 파이프에 각각 회전 수 90 개 90 도로 시계 방향 또는 반 시계 방향으로 , 임의의가 (아마도, 제로) 시간 (수 있도록 유형 1 1 2 2는 서로 종류가 될 수있는 3 , 4 , 5 , 6 3,4,5 6)은 서로가 될 수있다.
당신은 물 흐름을 개시 할 수있는 방식으로 일부 파이프를 설정하려면 ( 1 , 0 ) (1,0) (왼쪽 상단 파이프의 왼쪽)에서 파이프로 이동 ( 1 , 1 ) (1, 1)으로 흘러 든 에서 파이프에 접속 된 파이프 ( 2 , N ) (2, n)은 오른쪽으로 흐른다 ( 2 , N + 1 ) ) (2, N + 1.
그들은 시스템의 인접과 끝이 연결되어있는 경우 파이프가 연결되어 있습니다. 여기에 연결 파이프의 예이다 :
의 몇 가지 예를 사용하여 문제를 설명하자 :
그리고 그 해결책은 다음과 같습니다 :
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)(1,2) 9090 degrees clockwise, the pipe at (2,3)(2,3) 9090 degrees, the pipe at (1,6)(1,6) 9090 degrees, the pipe at (1,7)(1,7) 180180 degrees and the pipe at (2,7)(2,7) 180180degrees. Then the flow of water can reach (2,n+1)(2,n+1) from (1,0)(1,0).
You have to answer qq independent queries.
The first line of the input contains one integer qq (1≤q≤1041≤q≤104) — the number of queries. Then qq queries follow.
Each query consists of exactly three lines. The first line of the query contains one integer nn (1≤n≤2⋅1051≤n≤2⋅105) — 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 nndigits from 11 to 66 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 nn over all queries does not exceed 2⋅1052⋅105.
For the ii-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)(2,n+1) from (1,0)(1,0), and "NO" otherwise.