#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double eps = (1e-10);
int isGreater(long double x, long double y) {
  if (abs(x - y) < eps) return 0;
  if (x > y) return 1;
  return -1;
}
bool f(char i) { return i == '1' || i == '2'; }
void solve() {
  int n;
  cin >> n;
  vector<string> s(2);
  cin >> s[0] >> s[1];
  int i = 0, j = 0;
  while (j < n) {
    if (f(s[i][j]))
      ++j;
    else {
      int nxt = (i + 1) % 2;
      if (f(s[nxt][j])) break;
      i = nxt;
      j++;
    }
  }
  if (i == 1 && j == n)
    cout << "YES\n";
  else
    cout << "NO\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tc;
  cin >> tc;
  while (tc--) solve();
  return 0;
}
