#include <bits/stdc++.h>
using namespace std;
int q, n;
bool k[2], kk[2];
short id[] = {1, 1, 2, 2, 2, 2}, a[2][200002];
int main() {
  scanf("%d", &q);
  char u;
  while (q--) {
    scanf("%d", &n);
    for (short z = 0; z < 2; ++z) {
      for (int i = 1; i <= n; ++i) scanf(" %c", &u), a[z][i] = id[u - '1'];
    }
    k[0] = true;
    k[1] = false;
    for (int i = 1; i <= n; ++i) {
      kk[0] = kk[1] = false;
      for (short z = 0; z < 2; ++z)
        if (k[z]) {
          if (a[z][i] == 1)
            kk[z] |= 1;
          else if (a[0][i] == 2 && a[1][i] == 2) {
            kk[z ^ 1] |= 1;
          }
        }
      k[0] = kk[0];
      k[1] = kk[1];
    }
    puts(k[1] ? "YES" : "NO");
  }
}
