#include <bits/stdc++.h>
using namespace std;
int way_possible(int curr_row, string &s1, string &s2, int ind, int way) {
  if (ind == s1.size()) {
    if (curr_row == 0)
      return 0;
    else if (way == 0) {
      return 1;
    } else
      return 0;
  }
  if (curr_row == 0) {
    if (s1[ind] == '1' || s1[ind] == '2') {
      if (way_possible(curr_row, s1, s2, ind + 1, 0) && way == 0) return 1;
    } else {
      if (way == 0)
        if (way_possible(1 ^ curr_row, s1, s2, ind, 1)) return 1;
      if (way == -1)
        if (way_possible(curr_row, s1, s2, ind + 1, 0)) return 1;
    }
  } else {
    if (s2[ind] == '1' || s2[ind] == '2') {
      if (way == 0)
        if (way_possible(curr_row, s1, s2, ind + 1, 0) && way == 0) return 1;
    } else {
      if (way == 0)
        if (way_possible(1 ^ curr_row, s1, s2, ind, -1) && way == 0) return 1;
      if (way == 1)
        if (way_possible(curr_row, s1, s2, ind + 1, 0) && way == 1) return 1;
    }
  }
  return 0;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string r1, r2;
    cin >> r1;
    cin >> r2;
    int curr = 0;
    if (way_possible(curr, r1, r2, 0, 0)) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
