#include <bits/stdc++.h>
using namespace std;
int main() {
  int q, n;
  string pipe_str;
  int row, col;
  char my_dir;
  cin >> q;
  while (q--) {
    vector<vector<int>> pipe(2);
    cin >> n;
    cin >> pipe_str;
    for (char& c : pipe_str) {
      pipe[0].push_back(c - '0');
    }
    cin >> pipe_str;
    for (char& c : pipe_str) {
      pipe[1].push_back(c - '0');
    }
    row = 0;
    col = 0;
    my_dir = 'r';
    while (col != n) {
      if (my_dir == 'r') {
        if (pipe[row][col] < 3) {
          col++;
        } else {
          if (row == 0) {
            my_dir = 'd';
            row = 1;
          } else {
            my_dir = 'u';
            row = 0;
          }
        }
      } else if (my_dir == 'd') {
        if (pipe[row][col] < 3) {
          break;
        } else {
          my_dir = 'r';
          col++;
        }
      } else {
        if (pipe[row][col] < 3) {
          break;
        } else {
          my_dir = 'r';
          col++;
        }
      }
    }
    if (row == 1 && col == (n)) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
