#include <bits/stdc++.h>
using namespace std;
int n, a[400001], vis[400001];
bool ans;
void dfs(int x, int y) {
  if (x == n && y == 2 && a[x + n] == 2) {
    ans = 1;
    return;
  }
  if (a[x + (y - 1) * n] == 2) dfs(x + 1, y);
  if (a[x + (y - 1) * n] >= 3 && a[x + (y - 1) * n] <= 6) {
    if (y == 1) {
      if (a[x + n] >= 3 && a[x + n] <= 6) {
        if (x == n) {
          ans = 1;
          return;
        }
        dfs(x + 1, 2);
      }
    } else {
      if (a[x] >= 3 && a[x] <= 6) dfs(x + 1, 1);
    }
  }
}
int main() {
  int q;
  scanf("%d", &q);
  while (q--) {
    ans = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
      scanf("%1d", &a[i]);
      if (a[i] == 1) a[i] = 2;
    }
    for (int i = 1; i <= n; i++) {
      scanf("%1d", &a[i + n]);
      if (a[i + n] == 1) a[i + n] = 2;
    }
    dfs(1, 1);
    if (ans)
      printf("YES\n");
    else
      printf("NO\n");
  }
}
