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