//新生训练
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
using PII = pair<int, int>;
const int N = 2e5 + 5;
const int inf = 0x3f3f3f3f;
int n, m;
int l;
string s[2];
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
bool check(int ix, int iy)
{
return ix >= 0 && ix < 2 && iy >= 0 && iy < n;
}
bool b[2][N];
void bfs()
{
memset(b, 0, sizeof b);
queue<PII> q;
q.emplace(0, 0);
while (!q.empty())
{
PII t = q.front();
q.pop();
int x = t.first, y = t.second;
for (int i = 0; i < 4; ++i)
{
int ix = x + dx[i], iy = y + dy[i];
if (check(ix, iy))
{
if (s[ix][iy] == '>')
++iy;
else
--iy;
}
if (!check(ix, iy) || b[ix][iy])
continue;
q.emplace(ix, iy);
b[ix][iy] = 1;
}
}
cout << (b[1][n - 1] ? "YES" : "NO") << '\n';
}
void solve()
{
cin >> n;
cin >> s[0] >> s[1];
bfs();
}
signed main()
{
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
int t = 1;
cin >> t;
while (t--)
{
solve();
}
return 0;
}
//笔者练习DFS 和 BFS 也有一段时间了,虽然还不是太明白,但也算略知一二了;
//告一段落
~~~//仅当笔者个人备忘录使用。