#include <bits/stdc++.h>
using namespace std;
map<long long int, long long int> mp;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, i, x, y;
    cin >> n;
    string s[2];
    cin >> s[0] >> s[1];
    bool f = true;
    x = 0;
    for (i = 0; i < n; i++) {
      if (s[x][i] >= '3') {
        if (s[x ^ 1][i] <= '2') {
          f = false;
          break;
        } else {
          x ^= 1;
        }
      }
    }
    if (f && x && i == n)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
