#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
bool prime(long long int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
bool subsequence_checker(string str1, string str2, long long int m,
                         long long int n) {
  if (m == 0) return true;
  if (n == 0) return false;
  if (str1[m - 1] == str2[n - 1])
    return subsequence_checker(str1, str2, m - 1, n - 1);
  return subsequence_checker(str1, str2, m, n - 1);
}
long long int inv(long long int a) {
  long long int p = 998244353;
  long long int b = p - 2, ans = 1;
  for (; b > 0; a = a * a % p, b >>= 1)
    if (b & 1) ans = ans * a % p;
  return ans;
}
long long int ncr(long long int n, long long int m) {
  long long int p = 998244353;
  if (m > n) return 0;
  long long int up = 1, down = 1;
  for (int i = n - m + 1; i < n + 1; i++) up *= i, up %= p;
  for (int i = 1; i < m + 1; i++) down *= i, down %= p;
  return up * inv(down) % p;
}
long long int countDigit(long long int n) { return floor(log10(n) + 1); }
long long int a_pow_b(long long int a, long long int b) {
  long long int p = 1000000007;
  long long int ans = 1;
  for (; b > 0; a = a * a % p, b >>= 1)
    if (b & 1) ans = ans * a % p;
  return ans;
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}
bool isPerfectSquare(long long int x) {
  long double sr = sqrt(x);
  return ((sr - floor(sr)) == 0);
}
long long int nor(long long int n, long long int k) {
  if (k == 1) {
    return n;
  }
  if (k == 2) {
    return n * (n - 1) / 2;
  }
  if (k == 3) {
    return n * (n - 1) * (n - 2) / 6;
  }
}
void solve() {
  long long int n;
  cin >> n;
  string a[2];
  cin >> a[0] >> a[1];
  long long int flag = 0;
  long long int i;
  for (i = 0; i < n; i++) {
    if (a[flag][i] == '1' || a[flag][i] == '2')
      continue;
    else if (a[1 - flag][i] == '1' || a[1 - flag][i] == '2')
      break;
    else
      flag = 1 - flag;
  }
  if (i == n && flag == 1)
    cout << "YES";
  else
    cout << "NO";
  return;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int t;
  cin >> t;
  while (t--) {
    solve();
    cout << "\n";
  }
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
