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