#include <bits/stdc++.h>
using namespace std;
string s1, s2;
int main() {
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    cin >> s1 >> s2;
    bool t[n], b[n];
    for (int i = n - 1; i >= 0; i--) {
      if (i == s1.size() - 1) {
        t[i] = (s1[i] - '0' > 2 && s2[i] - '0' > 2);
      } else if (s1[i] - '0' < 3) {
        t[i] = t[i + 1];
      } else {
        if (s2[i] - '0' < 3) {
          t[i] = false;
        } else {
          t[i] = b[i + 1];
        }
      }
      if (i == s1.size() - 1) {
        b[i] = (s2[i] - '0' < 3);
      } else if (s2[i] - '0' < 3) {
        b[i] = b[i + 1];
      } else {
        if (s1[i] - '0' < 3) {
          b[i] = false;
        } else {
          b[i] = t[i + 1];
        }
      }
    }
    if (t[0]) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  }
}
