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