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