#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int tc;
  long long a, n, arr[2][200020];
  char x;
  bool cek[2][200020];
  memset(cek, false, sizeof cek);
  cin >> tc;
  while (tc--) {
    cin >> n;
    for (int i = 0; i < 2; i++) {
      for (int j = 1; j <= n; j++) {
        cin >> x;
        arr[i][j] = x - '0';
      }
    }
    cek[0][0] = true;
    int y = 1;
    for (int y = 1; y <= n; y++) {
      cek[0][y] = 0;
      cek[1][y] = 0;
      if (arr[0][y] == 1 || arr[0][y] == 2) cek[0][y] = cek[0][y - 1];
      if (arr[1][y] == 1 || arr[1][y] == 2) cek[1][y] = cek[1][y - 1];
      if ((arr[1][y] != 1 && arr[1][y] != 2) &&
          (arr[0][y] != 1 && arr[0][y] != 2)) {
        cek[0][y] = cek[1][y - 1];
      }
      if ((arr[1][y] != 1 && arr[1][y] != 2) &&
          (arr[0][y] != 1 && arr[0][y] != 2)) {
        cek[1][y] = cek[0][y - 1];
      }
    }
    if (cek[1][n])
      cout << "YES" << '\n';
    else
      cout << "NO" << '\n';
  }
}
