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.

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

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

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

4

4

>><<

>>><

2

><

><

4

>>><

>><<

6

>><<><

><>>><

Output:

YES

YES

NO

YES

Explanation:

Example is self explanatory