#include <bits/stdc++.h>
using namespace std;
signed main() {
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    string a, b;
    cin >> a;
    cin >> b;
    if (n == 1) {
      if (a[0] == '1' || a[0] == '2')
        cout << "NO\n";
      else if (b[0] == '1' || b[0] == '2')
        cout << "NO\n";
      else
        cout << "YES\n";
      continue;
    }
    a = a + b;
    int i = 0;
    bool dir = false;
    while (i != 2 * n - 1) {
      if (!dir) {
        if (a[i] == '1' || a[i] == '2') {
          i++;
          if (i == n) break;
          dir = false;
        } else {
          if (i < n)
            i = i + n;
          else
            i = i - n;
          dir = true;
        }
      } else {
        if (a[i] == '1' || a[i] == '2') {
          break;
        } else {
          i++;
          dir = false;
        }
      }
    }
    if (i != 2 * n - 1)
      cout << "NO\n";
    else {
      if (!dir) {
        if (a[i] == '2' || a[i] == '1')
          cout << "YES\n";
        else
          cout << "NO\n";
      } else {
        if (a[i] == '2' || a[i] == '1')
          cout << "NO\n";
        else
          cout << "YES\n";
      }
    }
  }
}
