#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long int q;
  cin >> q;
  while (q--) {
    long long int n;
    cin >> n;
    string a, b;
    cin >> a >> b;
    long long int up = 1;
    long long int down = 0;
    bool check = true;
    for (long long int i = 0; i < n; i++) {
      if (up == 1) {
        if (a[i] == '4' || a[i] == '5' || a[i] == '6' || a[i] == '3') {
          if (b[i] == '1' || b[i] == '2') {
            check = false;
            break;
          } else {
            down = 1;
            up = 0;
          }
        }
      } else if (down == 1) {
        if (b[i] == '4' || b[i] == '5' || b[i] == '6' || b[i] == '3') {
          if (a[i] == '1' || a[i] == '2') {
            check = false;
            break;
          } else {
            down = 0;
            up = 1;
          }
        }
      }
    }
    if (check && down) {
      cout << "YES" << endl;
    } else
      cout << "NO" << endl;
  }
}
