#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
string s[3];
bool vis[3][N];
int n;
void dfs(int r, int c, char ch) {
  if (r < 0 || r > 1 || c < 0 || c > n || vis[r][c] == 1) return;
  vis[r][c] = 1;
  if (c > n - 1) return;
  if (ch == 'R') {
    if (s[r][c] == '1' || s[r][c] == '2')
      dfs(r, c + 1, 'R');
    else {
      dfs(r + 1, c, 'D');
      dfs(r - 1, c, 'U');
    }
  } else if (ch == 'D') {
    if (s[r][c] == '1' || s[r][c] == '2') return;
    dfs(r, c + 1, 'R');
  } else {
    if (s[r][c] == '1' || s[r][c] == '2') return;
    dfs(r, c + 1, 'R');
  }
}
int main() {
  int T, i, j;
  cin >> T;
  while (T--) {
    cin >> n;
    for (i = 0; i < 2; ++i) {
      cin >> s[i];
    }
    memset(vis, 0, sizeof(vis));
    dfs(0, 0, 'R');
    if (vis[1][n])
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
