#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t = 1;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long l1[2][n];
    string s;
    cin >> s;
    for (int i = 0; i < n; i++) l1[0][i] = s[i] - '0';
    cin >> s;
    for (int i = 0; i < n; i++) l1[1][i] = s[i] - '0';
    long long ok = 1, x = 0;
    for (int i = 0; i < n; i++) {
      if (l1[x][i] == 1 || l1[x][i] == 2) {
        ;
      } else if (l1[1 - x][i] != 1 && l1[1 - x][i] != 2)
        x = 1 - x;
      else {
        ok = 0;
        break;
      }
      if (x == 0 && i == n - 1) {
        ok = 0;
        break;
      }
    }
    if (ok)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}
