#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, j, k, x, q, dir, o = 0;
  cin >> q;
  string s1, s2;
  int b[q];
  int Q = q;
  while (q--) {
    cin >> n;
    int a[2][n];
    cin >> s1;
    cin >> s2;
    for (i = 0; i < n; i++) {
      a[0][i] = (int)(s1[i] - 48);
    }
    for (i = 0; i < n; i++) {
      a[1][i] = (int)(s2[i] - 48);
    }
    for (i = 0; i < 2; i++) {
      for (j = 0; j < n; j++) {
        if (a[i][j] == 1 || a[i][j] == 2)
          a[i][j] = 1;
        else
          a[i][j] = 2;
      }
    }
    i = 0;
    j = 0;
    dir = 1;
    while (0 <= i && i < 2 && 0 <= j && j < n) {
      if (i == 0) {
        if (dir == 1) {
          if (a[i][j] == 1) {
            j++;
            dir = 1;
          } else if (a[i][j] == 2) {
            i++;
            dir = 2;
          }
        } else if (dir == 3) {
          if (a[i][j] == 1) {
            i--;
          } else if (a[i][j] == 2) {
            j++;
            dir = 1;
          }
        }
      } else if (i == 1) {
        if (dir == 1) {
          if (a[i][j] == 1) {
            j++;
            dir = 1;
          } else if (a[i][j] == 2) {
            i--;
            dir = 3;
          }
        } else if (dir == 2) {
          if (a[i][j] == 1) {
            i++;
          } else if (a[i][j] == 2) {
            j++;
            dir = 1;
          }
        }
      }
    }
    if (i == 1 && j == n) {
      b[o] = 1;
      o++;
    } else {
      b[o] = 0;
      o++;
    }
  }
  for (i = 0; i < Q; i++) {
    if (b[i])
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
