#include <bits/stdc++.h>
using namespace std;
long long max(long long b, long long a) {
  if (b > a)
    return b;
  else
    return a;
}
long long min(long long b, long long a) {
  if (b < a)
    return b;
  else
    return a;
}
long long Abs(long long b) { return max(b, -b); }
void print(vector<pair<long long, long long> > &v) {
  for (long long i = 0; i < v.size(); i++)
    cout << v[i].first << " " << v[i].second << endl;
  cout << endl;
}
void print(long long arr[], long long n) {
  for (long long i = 0; i < n; i++) cout << arr[i] << " ";
  cout << endl;
}
bool sortbysec(const pair<pair<long long, long long>, long long> &a,
               const pair<pair<long long, long long>, long long> &b) {
  return (a.first.second < b.first.second);
}
int32_t main() {
  long long q;
  cin >> q;
  while (q--) {
    long long n;
    cin >> n;
    string arr[2];
    cin >> arr[0] >> arr[1];
    long long k = 0, l = 0, fl = 0;
    long long cnt = 1;
    long long f2 = 1;
    for (; l < n;) {
      if (arr[k][l] == '1' || arr[k][l] == '2')
        l++;
      else if (arr[k][l] == '3' || arr[k][l] == '4' || arr[k][l] == '5' ||
               arr[k][l] == '6') {
        if (cnt % 2 == 0) {
          l++;
          cnt++;
          continue;
        }
        if (k == 0)
          k = 1;
        else
          k = 0;
        if (arr[k][l] - '2' <= 0) {
          cout << "NO" << endl;
          f2 = 0;
          break;
        }
        cnt++;
      }
    }
    if (f2) {
      if (k == 1 && l == n)
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    }
  }
}
