#include <bits/stdc++.h>
using namespace std;
long long po(long long a, long long x, long long m) {
  if (x == 0) {
    return 1;
  }
  long long ans = 1;
  long long k = 1;
  while (k <= x) {
    if (x & k) {
      ans = ((ans * a) % m);
    }
    k <<= 1;
    a *= a;
    a %= m;
  }
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    string a, b;
    cin >> a >> b;
    bool f[n + 1][2];
    for (long long i = 0; i < n; i++) {
      if (a[i] == '1' || a[i] == '2')
        f[i][0] = false;
      else
        f[i][0] = true;
      if (b[i] == '1' || b[i] == '2')
        f[i][1] = false;
      else
        f[i][1] = true;
    }
    long long bll = 0;
    bool flag = true;
    bool k = false;
    for (long long i = 0; i < n; i++) {
      if (i != n && !f[i][bll]) {
        continue;
      }
      if (i != n && (f[i][0] && !f[i][1]) || (f[i][1] && !f[i][0])) {
        flag = false;
        break;
      }
      bll ^= 1;
    }
    if (flag && bll == 1)
      cout << "YES"
           << "\n";
    else
      cout << "NO"
           << "\n";
  }
  return 0;
}
