#include <bits/stdc++.h>
using namespace std;
char a[5][200005];
int main() {
  for (int i = 1; i <= 100; ++i)
    ;
  for (int i = 1; i <= 100; ++i)
    ;
  for (int i = 1; i <= 100; ++i)
    ;
  int T;
  scanf("%d", &T);
  while (T--) {
    int f = 0;
    int l = 0;
    int n;
    scanf("%d", &n);
    getchar();
    scanf("%s%s", a[0], a[1]);
    for (int i = 0; i < n; i++) {
      if (a[l][i] == '1' || a[l][i] == '2')
        continue;
      else {
        if (a[!l][i] != '1' && a[!l][i] != '2') {
          l = !l;
        } else {
          f = 1;
          break;
        }
      }
    }
    if (f == 1 || l == 0) {
      printf("NO\n");
    } else {
      printf("YES\n");
    }
  }
  for (int i = 1; i <= 100; ++i)
    ;
  for (int i = 1; i <= 100; ++i)
    ;
  getchar();
  getchar();
  for (int i = 1; i <= 100; ++i)
    for (int i = 1; i <= 100; ++i)
      ;
  return 0;
}
