#include <bits/stdc++.h>
using namespace std;
long long int n;
int dist[30][30];
vector<int> arr[100001];
int vis[1001][1001];
int graph[1001][1001];
int in[10001];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
vector<int> res;
int c = 0;
int a[101][101];
bool isPalindrome(string s) {
  if (s.size() == 1) return false;
  for (int i = 0; i < s.size() / 2; i++) {
    if (s[i] != s[s.size() - 1 - i]) {
      return false;
    }
  }
  return true;
}
bool isPrime(long long int n) {
  for (long long int i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
long long int fact(long long int n) {
  if (n == 1)
    return 1;
  else
    return n * fact(n - 1);
}
long long int comb(long long int n, long long int r) {
  return fact(n) / (fact(n - r) * fact(r));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  cin >> t;
  while (t-- > 0) {
    int n;
    cin >> n;
    string a[2];
    for (int i = 0; i < 2; i++) {
      cin >> a[i];
    }
    int i = 0;
    int j = 0;
    bool ok = true;
    int level = 0;
    while (i < 2 && j < n) {
      if (level == 1 && (a[i][j] == '1' || a[i][j] == '2')) {
        ok = false;
        break;
      }
      if (a[i][j] == '1' || a[i][j] == '2')
        j++;
      else if (level == 1)
        j++, level = 0;
      else {
        i = 1 - i;
        level = 1;
      }
    }
    if (!ok)
      cout << "NO" << endl;
    else if (i == 1 && j == n)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
