#include <bits/stdc++.h>
using namespace std;
int n, q, adj[4][200123];
int vis[4][200123];
void show() {
  for (int i = 1; i <= 2; ++i) {
    for (int j = 1; j <= n; ++j) {
      cout << adj[i][j] << ' ';
    }
    cout << endl;
  }
}
int dfs(int i, int j, char v) {
  if (i == 2 and (j == (n + 1))) return 1;
  if (i <= 0 or i > 2 or j <= 0 or j > n) return 0;
  if (vis[i][j]) return 0;
  vis[i][j] = 1;
  if ((adj[i][j] == 1 or adj[i][j] == 2) and (v == 'e')) {
    return dfs(i, j + 1, 'e');
  } else if (adj[i][j] == 1 or adj[i][j] == 2) {
    return 0;
  }
  if (v == 'e') {
    return dfs(i + 1, j, 'c') or dfs(i - 1, j, 'b');
  } else if (v == 'c') {
    return dfs(i, j + 1, 'e');
  } else if (v == 'b') {
    return dfs(i, j + 1, 'e');
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  char c;
  string s;
  cin >> q;
  while (q--) {
    cin >> n;
    cin >> s;
    for (int i = 0; i < n; ++i) {
      adj[1][i + 1] = s[i] - '0';
    }
    cin >> s;
    for (int i = 0; i < n; ++i) {
      adj[2][i + 1] = s[i] - '0';
    }
    cout << (dfs(1, 1, 'e') ? "YES\n" : "NO\n");
    for (int i = 1; i <= 2; ++i) {
      for (int j = 1; j <= n; ++j) {
        vis[i][j] = 0;
      }
    }
  }
  return 0;
}
