#include <bits/stdc++.h>
using namespace std;
const int N = 2000 * 100 + 7;
int pipe[2][N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    string p[2];
    cin >> p[0] >> p[1];
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < n; j++) {
        if (p[i][j] == '1' || p[i][j] == '2')
          pipe[i][j] = 0;
        else
          pipe[i][j] = 1;
      }
    }
    int r = 0, c = 0, in = 1;
    while (c < n) {
      if (r == 1 && c == n - 1) break;
      if (r == 0) {
        if (in == 1) {
          if (pipe[r][c] == 0) {
            c++;
            continue;
          }
          if (pipe[r][c] == 1) {
            r++;
            in = 2;
            continue;
          }
        }
        if (in == 4) {
          if (pipe[r][c] == 0) {
            break;
          }
          if (pipe[r][c] == 1) {
            in = 1;
            c++;
            continue;
          }
        }
      }
      if (r == 1) {
        if (in == 1) {
          if (pipe[r][c] == 0) {
            c++;
            continue;
          }
          if (pipe[r][c] == 1) {
            in = 4;
            r--;
            continue;
          }
        }
        if (in == 2) {
          if (pipe[r][c] == 0) {
            break;
          }
          if (pipe[r][c] == 1) {
            in = 1;
            c++;
            continue;
          }
        }
      }
    }
    if (r == 1 && c == n - 1) {
      if (in == 1 && pipe[r][c] == 0)
        cout << "YES" << endl;
      else if (in == 2 && pipe[r][c] == 1)
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    } else
      cout << "NO" << endl;
  }
}
