#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void chmin(ll &x, ll y) { x = min(x, y); }
void chmax(ll &x, ll y) { x = max(x, y); }
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
int n;
string m[2];
bool st(char c) { return (c == '1') || (c == '2'); }
bool isIN(int y, int x) { return (0 <= y && y <= 1 && 0 <= x && x < n); }
bool ok = true;
void rec(int y, int x, int py, int px) {
  if (!ok) return;
  char now = m[y][x];
  char p = m[py][px];
  bool type = st(now);
  if (py == 0 && y == 1) {
    if (type)
      ok = false;
    else
      m[y][x] = '6';
  } else if (py == 1 && y == 0) {
    if (type)
      ok = false;
    else
      m[y][x] = '3';
  } else {
    if (type)
      m[y][x] = '2';
    else if (y == 0)
      m[y][x] = '4';
    else if (y == 1)
      m[y][x] = '5';
  }
  int nx = x, ny = y;
  if (m[y][x] == '2' || m[y][x] == '3' || m[y][x] == '6') nx++;
  if (m[y][x] == '4') ny++;
  if (m[y][x] == '5') ny--;
  if (ny == 1 && nx == n) return;
  if (!isIN(ny, nx)) ok = false;
  if (ok)
    rec(ny, nx, y, x);
  else
    return;
}
void solve() {
  cin >> n;
  for (int i = 0; i < (int)(2); i++) cin >> m[i];
  ok = true;
  if (st(m[0][0]))
    m[0][0] = '2';
  else
    m[0][0] = '4';
  if (st(m[1][n - 1]))
    m[1][n - 1] = '2';
  else
    m[1][n - 1] = '6';
  rec(0, 0, 0, 0);
  if (ok)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
int main() {
  int q;
  cin >> q;
  for (int i = 0; i < (int)(q); i++) solve();
}
