#include <bits/stdc++.h>
enum { left1 = 0, left2 = 1, bottom1 = 2, top2 = 3, fail = 4 };
int tr[4][6] = {{left1, left1, top2, top2, top2, top2},
                {left2, left2, bottom1, bottom1, bottom1, bottom1},
                {fail, fail, left1, left1, left1, left1},
                {fail, fail, left2, left2, left2, left2}};
void proc() {
  int n;
  std::string r[2];
  std::cin >> n >> r[0] >> r[1];
  int state = left1;
  for (int i = 0; i < n && state != fail;) {
    int code = ((state == left1 || state == bottom1) ? r[0][i] : r[1][i]) - '1';
    state = tr[state][code];
    if (state == left1 || state == left2) i++;
  }
  if (state == left2)
    std::cout << "YES" << std::endl;
  else
    std::cout << "NO" << std::endl;
}
int main() {
  int q;
  std::cin >> q;
  while (q--) proc();
  return 0;
}
