#include <bits/stdc++.h>
using namespace std;
inline void R_P(vector<int> &vec) {
  int temp;
  cin >> temp;
  vec.push_back(temp);
}
inline bool checkMax(int &base, int test) {
  return (test > base) ? base = test, true : false;
}
inline bool checkMin(int &base, int test) {
  return (test < base) ? base = test, true : false;
}
template <class T>
void test(vector<T> &vec, const string &warn) {
  cout << warn << '\n';
  for (int i = (0); i < (vec.size()); i++) cout << vec[i] << ' ';
  cout << "\nTest end..............\n";
}
void solve() {
  int n;
  cin >> n;
  vector<bool> vec[2];
  for (int i = (0); i < (2); i++) {
    string str;
    cin >> str;
    for (char &X : str) vec[i].push_back(((X - '0' <= 2) ? true : false));
  }
  int row = 0, col = 0;
  int past = 1;
  bool ok = true;
  while (ok) {
    if (vec[row][col]) {
      if (past != 1) {
        ok = false;
        break;
      }
      col++;
    } else {
      switch (past) {
        case 1:
          (row == 0) ? row++, past = 3 : row--, past = 2;
          break;
        case 2:
        case 3:
          col++;
          past = 1;
          break;
      }
    }
    if (row == 1 && col == n)
      break;
    else if ((row != 0 && row != 1) || col >= n) {
      ok = false;
      break;
    }
  }
  cout << ((ok) ? "YES\n" : "NO\n");
}
int main() {
  int t;
  cin >> t;
  for (int i = (0); i < (t); i++) solve();
  return 0;
}
