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