#include <bits/stdc++.h>
using namespace std;
int q;
int main() {
  cin >> q;
  while (q--) {
    string s[2];
    int n;
    cin >> n >> s[0] >> s[1];
    int row = 0, pos = 0;
    for (pos = 0; pos < n; ++pos) {
      if (s[row][pos] >= '3') {
        if (s[row ^ 1][pos] >= '3') {
          row ^= 1;
        } else {
          break;
        }
      }
    }
    if (row == 1 && pos == n) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  }
}
