#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int i, j, n, x = 1;
    cin >> n;
    string str;
    vector<string> v;
    cin >> str;
    v.push_back(str);
    cin >> str;
    v.push_back(str);
    for (i = 1, j = n - 1; j >= 0;) {
      if (x) {
        if (v[i][j] <= '2') {
          v[i][j] = 2;
          j--;
          x = 1;
        } else if (i)
          v[i][j] = 6, x = 0, i = 0;
        else
          v[i][j] = 3, x = 0, i = 1;
      } else {
        if (v[i][j] <= '2') {
          j = -1;
          i = 1;
        } else if (i)
          v[i][j] = 5, x = 1;
        else
          v[i][j] = 4, x = 1;
        j--;
      }
    }
    if (!i && j < 0)
      cout << "YES";
    else
      cout << "NO";
    cout << '\n';
  }
  return 0;
}
