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