#include <bits/stdc++.h>
using namespace std;
vector<long long> adj[100002];
vector<long long> vis(100002, 0);
int main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  int t = 1;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    string s;
    cin >> s;
    string s1;
    cin >> s1;
    long long count = 0;
    long long flag = 0;
    long long i = 0;
    long long f = 1;
    while (i < n) {
      if (flag) {
        if (s1[i] >= '3' && s1[i] <= '6') {
          if (s[i] >= '3' && s[i] <= '6') {
            count++;
            flag = 0;
          } else {
            f = 0;
          }
        }
      } else if (s[i] >= '3' && s[i] <= '6' && flag == 0) {
        if (s1[i] >= '3' && s1[i] <= '6') {
          count++;
          flag = 1;
        } else {
          f = 0;
        }
      }
      i++;
    }
    if (count % 2 == 1 && f == 1) {
      cout << "YES" << '\n';
    } else {
      cout << "NO" << '\n';
    }
  }
}
