#include <bits/stdc++.h>
using namespace std;
string sys[2];
int n;
bool go(bool row, int ind, bool up) {
  if (ind == n && row) return 1;
  if (ind == n) return 0;
  if (up && sys[row][ind] <= '2') return 0;
  if (up && sys[row][ind] > '2') return go(row, ind + 1, 0);
  if (sys[row][ind] > '2') return go(!row, ind, 1);
  return go(row, ind + 1, 0);
}
int main() {
  int q;
  cin >> q;
  while (q--) {
    cin >> n >> sys[0] >> sys[1];
    if (go(0, 0, 0))
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
