#include <bits/stdc++.h>
using namespace std;
bool possible(string &a, string &b, int k, int n, int h) {
  if (n == 0 && h == true) {
    if (k == 0) return true;
    return false;
  }
  if (h == true) {
    if (k == 1) {
      if (b[n - 1] == '1' || b[n - 1] == '2')
        return possible(a, b, 1, n - 1, true);
      else
        return possible(a, b, 0, n, false);
    }
    if (k == 0) {
      if (a[n - 1] == '1' || a[n - 1] == '2')
        return possible(a, b, 0, n - 1, true);
      else
        return possible(a, b, 1, n, false);
    }
  }
  if (h == false) {
    if (k == 1) {
      if (b[n - 1] == '1' || b[n - 1] == '2')
        return false;
      else
        return possible(a, b, 1, n - 1, true);
    }
    if (k == 0) {
      if (a[n - 1] == '1' || a[n - 1] == '2')
        return false;
      else
        return possible(a, b, 0, n - 1, true);
    }
  }
  return false;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string a, b;
    cin >> a >> b;
    if (possible(a, b, 1, n, true))
      cout << "YES";
    else
      cout << "NO";
    cout << endl;
  }
  return 0;
}
