4.3 Robot Navigation on an Arrow Grid 🤖
Score: 20pts
Time Limit: 5.00 sec
You have a 2×n grid with the following properties:
Rows are numbered 1 (top) and 2 (bottom).
Columns are numbered from 1 to n, left to right.
Each cell contains an arrow pointing either left or right, but never out of the grid.
A robot starts at position (1,1) and moves according to these rules every second:
First, the robot moves once in any cardinal direction (left, right, up, or down), but cannot leave the grid or stay still.
Then, the robot moves in the direction of the arrow in its current cell.
Determine if it's possible for the robot to reach cell (2,n) using these movement rules.

Constraints
t (1≤t≤10^4)
n(2≤n≤2⋅10^5)
n is even
There are no arrows pointing outside the grid
The sum of n over all test cases doesnt exceed 2.10^5

Input Format
The first line contains a single integer t — the number of test cases.
The first line of each test case contains a single integer - n
The second line contains a string consisting of exactly n characters < and/or > — the first row of the grid.
The third line contains a string consisting of exactly n characters < and/or > — the second row of the grid

Output Format
For each test case, print YES if the robot can reach the cell (2,n); otherwise, print NO

Example 1
Input:
4
4
>><<
>>><
2
><
><
4
>>><
>><<
6
>><<><
><>>><

Output:
YES
YES
NO
YES

Explanation:
Example is self explanatory

Log In to solve the Question