#include <bits/stdc++.h>
using namespace std;
int main() {
  int q, n;
  cin >> q;
  for (int z = 0; z < q; z++) {
    cin >> n;
    string arr[2];
    cin >> arr[0];
    cin >> arr[1];
    int j = 0;
    bool k = 0;
    while (j < n) {
      if (arr[k][j] < '3') {
        j++;
      } else {
        if (arr[1][j] > '2' && arr[0][j] > '2') {
          j++;
          k = !k;
        } else
          break;
      }
      if (j == n && k == 1) break;
    }
    if (j == n && k == 1)
      cout << "YES" << endl;
    else
      cout << "NO\n";
  }
}
