#include <bits/stdc++.h>
using namespace std;
int main() {
  long long q;
  cin >> q;
  while (q--) {
    long long n;
    cin >> n;
    string s1, s2;
    cin >> s1;
    cin >> s2;
    int t = 1;
    long long x = 0;
    long long tmp = 0;
    while (x < n) {
      if (t == 1) {
        char ch = s1[x];
        s1[x] = 'v';
        if (s2[x] == 'v') {
          if (ch == '1' || ch == '2') {
            break;
          } else
            x++;
        } else {
          if (ch == '1' || ch == '2') {
            x++;
          } else
            t = 2;
        }
      } else if (t == 2) {
        char ch = s2[x];
        s2[x] = 'v';
        if (s1[x] == 'v') {
          if (ch == '1' || ch == '2') {
            break;
          } else
            x++;
        } else {
          if (ch == '1' || ch == '2') {
            x++;
          } else
            t = 1;
        }
      }
    }
    if (t == 2 && x == n) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}
