#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    int a[2][n];
    string s1, s2;
    cin >> s1 >> s2;
    for (int i = 0; i < s1.length(); i++) {
      a[0][i] = (s1[i] == '1' || s1[i] == '2') ? 1 : 2;
    }
    for (int i = 0; i < s2.length(); i++) {
      a[1][i] = (s2[i] == '1' || s2[i] == '2') ? 1 : 2;
    }
    bool above = true, pipes = true;
    for (int i = 0; i < n; i++) {
      if (i == n - 1) {
        if ((above && !(a[0][i] == 2 && a[1][i] == 2)) ||
            (!above && a[1][i] == 2)) {
          pipes = false;
          break;
        }
      }
      if (a[0][i] == 1 && a[1][i] == 2) {
        if (!above) {
          pipes = false;
          break;
        }
      } else if (a[0][i] == 2 && a[1][i] == 1) {
        if (above) {
          pipes = false;
          break;
        }
      } else if (a[0][i] == 2 && a[1][i] == 2)
        above = !above;
    }
    if (!pipes)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
}
