#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    int a[2][n];
    string r1, r2;
    cin >> r1 >> r2;
    for (int i = 0; i < n; ++i) {
      if (r1[i] == '1' || r1[i] == '2')
        a[0][i] = 1;
      else
        a[0][i] = 2;
      if (r2[i] == '1' || r2[i] == '2')
        a[1][i] = 1;
      else
        a[1][i] = 2;
    }
    int p = 0;
    for (int i = 0; i < n; ++i) {
      if (a[p][i] == 1)
        continue;
      else if (a[p][i] == 2) {
        ++p;
        p %= 2;
        if (a[p][i] == 2)
          continue;
        else
          goto end;
      }
    }
    if (p == 1) {
      cout << "YES" << '\n';
      continue;
    } else {
      cout << "NO" << '\n';
      continue;
    }
  end:
    cout << "NO" << '\n';
  }
}
