#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string str1, str2;
    cin >> str1 >> str2;
    int curr = 1;
    bool flag = true;
    for (int i = 0; i < n; i++) {
      if (curr == 1) {
        if (!(str1[i] == '1' || str1[i] == '2')) {
          if (str2[i] == '1' || str2[i] == '2') {
            flag = false;
            break;
          }
          curr = 2;
        }
      } else {
        if (!(str2[i] == '1' || str2[i] == '2')) {
          if (str1[i] == '1' || str1[i] == '2') {
            flag = false;
            break;
          }
          curr = 1;
        }
      }
    }
    if (!flag) {
      cout << "NO" << endl;
      continue;
    }
    curr == 2 ? cout << "YES"
                     << "\n"
              : cout << "NO"
                     << "\n";
  }
  return 0;
}
