#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, a[2][200005], sr, r, c;
  char ch;
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < n; j++) {
        cin >> ch;
        a[i][j] = ch - '0';
      }
    }
    r = 0;
    c = 0;
    sr = 0;
    while (c < n) {
      if (sr) {
        if (a[r][c] == 1 or a[r][c] == 2) {
          break;
        } else {
          c++;
          sr = 0;
        }
      } else {
        if (a[r][c] == 1 or a[r][c] == 2) {
          c++;
        } else {
          r = (r == 0) ? 1 : 0;
          sr = 1;
        }
      }
    }
    if (c == n and r == 1) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
