#include <bits/stdc++.h>
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const long long int int_max = 1e18;
const long long int int_min = -1e18;
using namespace std;
void solve() {
  long long int n;
  cin >> n;
  string s, s1;
  cin >> s >> s1;
  long long int a[n + 3], b[n + 2];
  for (int i = 0; i <= n - 1; i++) {
    a[i] = s[i] - '0';
  }
  for (int i = 0; i <= n - 1; i++) {
    b[i] = s1[i] - '0';
  }
  int flg = 0;
  int prev = -1;
  vector<long long int> pp;
  for (int i = 0; i <= n - 1; i++) {
    if (flg == 0) {
      if (prev != -1) {
        if (prev == 2) {
          if (a[i] <= 2) {
            cout << "NO" << '\n';
            return;
          } else {
            prev = 1;
            pp.push_back(prev);
            flg = 0;
          }
        } else {
          if (a[i] <= 2) {
            prev = 1;
            pp.push_back(prev);
            flg = 0;
          } else {
            i--;
            flg = 1;
            prev = 1;
            pp.push_back(prev);
          }
        }
      } else {
        if (a[i] <= 2) {
          prev = 1;
          flg = 0;
          pp.push_back(prev);
        } else {
          prev = 1;
          pp.push_back(prev);
          flg = 1;
          i--;
        }
      }
    } else {
      if (prev == 1) {
        if (b[i] <= 2) {
          cout << "NO" << '\n';
          return;
        } else {
          flg = 1;
          prev = 2;
          pp.push_back(prev);
        }
      } else {
        if (b[i] <= 2) {
          prev = 2;
          pp.push_back(prev);
          flg = 1;
        } else {
          flg = 0;
          i--;
          prev = 2;
          pp.push_back(prev);
        }
      }
    }
  }
  if (flg == 0) {
    cout << "NO" << '\n';
    return;
  }
  long long int m = pp.size();
  cout << "YES" << '\n';
}
int main() {
  ios::sync_with_stdio(false), cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
