#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  while (q) {
    q--;
    long int n, i, j, count = 0, c = 1;
    cin >> n;
    char a[300000], b[300000];
    cin >> a;
    cin >> b;
    for (i = 0; i < n; i++) {
      if ((a[i] == '1') || (a[i] == '2')) {
        a[i] = '1';
      } else {
        a[i] = '3';
      }
    }
    for (i = 0; i < n; i++) {
      if ((b[i] == '1') || (b[i] == '2')) {
        b[i] = '1';
      } else {
        b[i] = '3';
      }
    }
    for (i = 0; i < n; i++) {
      if (c == 1) {
        if (a[i] == '1') {
          c = 1;
        } else if ((a[i] == '3') && (b[i] == '3')) {
          c = 2;
        } else {
          count = 1;
          break;
        }
      } else if (c == 2) {
        if (b[i] == '1') {
          c = 2;
        } else if ((b[i] == '3') && (a[i] == '3')) {
          c = 1;
        } else if ((b[i] == '3') && (a[i] == '1')) {
          count = 1;
          break;
        }
      }
    }
    if ((count == 0) && (c == 2)) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
