#include <bits/stdc++.h>
using namespace std;
int ans;
long t, i, j, k, n;
char a[3][200005];
void search(int x, int y, int mark) {
  if (x == 1 && y == 0) {
    ans = 1;
    return;
  }
  if (x < 1 || x > 2 || y < 1) return;
  if (mark == 0) {
    if (a[x][y] == '1' || a[x][y] == '2') {
      search(x, y - 1, 0);
    } else {
      if (x == 1)
        search(x + 1, y, 1);
      else
        search(x - 1, y, 2);
    }
  } else if (mark == 1) {
    if (a[x][y] == '1' || a[x][y] == '2')
      return;
    else
      search(x, y - 1, 0);
  } else if (mark == 2) {
    if (a[x][y] == '1' || a[x][y] == '2')
      return;
    else
      search(x, y - 1, 0);
  }
}
int main() {
  scanf("%d", &t);
  for (i = 0; i < t; i++) {
    ans = 0;
    scanf("%d", &n);
    getchar();
    for (j = 1; j <= 2; j++) {
      for (k = 1; k <= n; k++) scanf("%c", &a[j][k]);
      getchar();
    }
    search(2, n, 0);
    if (ans == 1)
      printf("YES\n");
    else
      printf("NO\n");
  }
}
