#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#pragma GCC optimization("unroll-loops")
using namespace std;
inline int countBits(unsigned int v) {
  v = v - ((v >> 1) & 0x55555555);
  v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
  return ((v + (v >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}
inline int countBits(unsigned long long v) {
  unsigned int t = v >> 32;
  unsigned int p = (v & ((1ULL << 32) - 1));
  return countBits(t) + countBits(p);
}
inline int countBits(long long v) { return countBits((unsigned long long)v); }
inline int countBits(int v) { return countBits((unsigned int)v); }
inline bool isPowerOfTwo(int first) {
  return (first != 0 && (first & (first - 1)) == 0);
}
inline long long mulmod(long long first, long long n, long long _mod) {
  long long res = 0;
  while (n) {
    if (n & 1) res = (res + first) % _mod;
    first = (first + first) % _mod;
    n >>= 1;
  }
  return res;
}
inline long long binpow(long long first, long long n, long long _mod) {
  long long res = 1;
  while (n) {
    if (n & 1) res = (res * first) % _mod;
    first = (first * first) % _mod;
    n >>= 1;
  }
  return res;
}
inline long long gcd(long long a, long long b) {
  long long t;
  while (b) {
    a = a % b;
    t = a;
    a = b;
    b = t;
  }
  return a;
}
inline int gcd(int a, int b) {
  int t;
  while (b) {
    a = a % b;
    t = a;
    a = b;
    b = t;
  }
  return a;
}
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
inline long long gcd(long long a, long long b, long long c) {
  return gcd(gcd(a, b), c);
}
inline int gcd(int a, int b, int c) { return gcd(gcd(a, b), c); }
const int __BS = 4096;
static char __bur[__BS + 16], *__er = __bur + __BS, *__ir = __er;
template <class T = int>
T readInt() {
  auto c = [&]() {
    if (__ir == __er)
      std::fill(__bur, __bur + __BS, 0), cin.read(__bur, __BS), __ir = __bur;
  };
  c();
  while (*__ir && (*__ir < '0' || *__ir > '9') && *__ir != '-') ++__ir;
  c();
  bool m = false;
  if (*__ir == '-') ++__ir, c(), m = true;
  T r = 0;
  while (*__ir >= '0' && *__ir <= '9') r = r * 10 + *__ir - '0', ++__ir, c();
  ++__ir;
  return m ? -r : r;
}
string readString() {
  auto c = [&]() {
    if (__ir == __er)
      std::fill(__bur, __bur + __BS, 0), cin.read(__bur, __BS), __ir = __bur;
  };
  string r;
  c();
  while (*__ir && isspace(*__ir)) ++__ir, c();
  while (!isspace(*__ir)) r.push_back(*__ir), ++__ir, c();
  ++__ir;
  return r;
}
char readChar() {
  auto c = [&]() {
    if (__ir == __er)
      std::fill(__bur, __bur + __BS, 0), cin.read(__bur, __BS), __ir = __bur;
  };
  c();
  while (*__ir && isspace(*__ir)) ++__ir, c();
  return *__ir++;
}
static char __buw[__BS + 20], *__iw = __buw, *__ew = __buw + __BS;
template <class T>
void writeInt(T first, char endc = '\n') {
  if (first < 0) *__iw++ = '-', first = -first;
  if (first == 0) *__iw++ = '0';
  char* s = __iw;
  while (first) {
    T t = first / 10;
    char c = first - 10 * t + '0';
    *__iw++ = c;
    first = t;
  }
  char* f = __iw - 1;
  while (s < f) swap(*s, *f), ++s, --f;
  if (__iw > __ew) cout.write(__buw, __iw - __buw), __iw = __buw;
  if (endc) {
    *__iw++ = endc;
  }
}
template <class T>
void writeStr(const T& str) {
  int i = 0;
  while (str[i]) {
    *__iw++ = str[i++];
    if (__iw > __ew) cout.write(__buw, __iw - __buw), __iw = __buw;
  }
}
struct __FL__ {
  ~__FL__() {
    if (__iw != __buw) cout.write(__buw, __iw - __buw);
  }
};
static __FL__ __flushVar__;
template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p);
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v);
template <class T1, class T2>
ostream& operator<<(ostream& os, const set<T1, T2>& v);
template <class T1, class T2>
ostream& operator<<(ostream& os, const multiset<T1, T2>& v);
template <class T1, class T2>
ostream& operator<<(ostream& os, priority_queue<T1, T2> v);
template <class T1, class T2, class T3>
ostream& operator<<(ostream& os, const map<T1, T2, T3>& v);
template <class T1, class T2, class T3>
ostream& operator<<(ostream& os, const multimap<T1, T2, T3>& v);
template <class T, size_t N>
ostream& operator<<(ostream& os, const array<T, N>& v);
template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  bool f = 1;
  os << "[";
  for (auto& i : v) {
    if (!f) os << ", ";
    os << i;
    f = 0;
  }
  return os << "]";
}
template <class T, size_t N>
ostream& operator<<(ostream& os, const array<T, N>& v) {
  bool f = 1;
  os << "[";
  for (auto& i : v) {
    if (!f) os << ", ";
    os << i;
    f = 0;
  }
  return os << "]";
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const set<T1, T2>& v) {
  bool f = 1;
  os << "[";
  for (auto& i : v) {
    if (!f) os << ", ";
    os << i;
    f = 0;
  }
  return os << "]";
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const multiset<T1, T2>& v) {
  bool f = 1;
  os << "[";
  for (auto& i : v) {
    if (!f) os << ", ";
    os << i;
    f = 0;
  }
  return os << "]";
}
template <class T1, class T2, class T3>
ostream& operator<<(ostream& os, const map<T1, T2, T3>& v) {
  bool f = 1;
  os << "[";
  for (auto& ii : v) {
    if (!f) os << ", ";
    os << "(" << ii.first << " -> " << ii.second << ") ";
    f = 0;
  }
  return os << "]";
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const multimap<T1, T2>& v) {
  bool f = 1;
  os << "[";
  for (auto& ii : v) {
    if (!f) os << ", ";
    os << "(" << ii.first << " -> " << ii.second << ") ";
    f = 0;
  }
  return os << "]";
}
template <class T1, class T2>
ostream& operator<<(ostream& os, priority_queue<T1, T2> v) {
  bool f = 1;
  os << "[";
  while (!v.empty()) {
    auto first = v.top();
    v.pop();
    if (!f) os << ", ";
    f = 0;
    os << first;
  }
  return os << "]";
}
template <class T1, class T2>
void printarray(const T1& a, T2 sz, T2 beg = 0) {
  for (T2 i = beg; i < sz; i++) cout << a[i] << " ";
  cout << '\n';
}
template <typename T, typename T2>
void printarr(T a[], T2 sz, T2 beg = 0) {
  for (T2 i = beg; i < sz; i++) cout << a[i] << " ";
  cout << '\n';
}
bool isPowo(char c) { return c != '1' && c != '2'; }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    string s[2];
    cin >> s[0] >> s[1];
    int first = 0, second = 0;
    if (s[0][0] == '1' || s[0][0] == '2') {
      first = 1;
    } else {
      second = 1;
    }
    int oldx = 0, oldy = 0;
    bool ok = 1;
    for (int(i) = (0); (i) < (2 * n + 10); (i)++) {
      if (first >= n) break;
      pair<int, int> pr = {first, second};
      if (s[second][first] == '1' || s[second][first] == '2') {
        if (isPowo(s[oldy][oldx]) && oldy == 0) {
          if (second == 0) {
            first++;
          } else {
            ok = 0;
            break;
          }
        } else if (isPowo(s[oldy][oldx]) && oldy == 1) {
          if (second == 0) {
            ok = 0;
            break;
          } else {
            first++;
          }
        } else if (!isPowo(s[oldy][oldx]) && oldy == 0) {
          if (second == 0) {
            first++;
          } else {
            ok = 0;
            break;
          }
        } else if (!isPowo(s[oldy][oldx]) && oldy == 1) {
          if (second == 0) {
            ok = 0;
            break;
          } else {
            first++;
          }
        }
      } else {
        if (isPowo(s[oldy][oldx]) && oldy == 0) {
          if (second == 0) {
            second = 1;
          } else {
            first++;
          }
        } else if (isPowo(s[oldy][oldx]) && oldy == 1) {
          if (second == 0) {
            first++;
          } else {
            second = 0;
          }
        } else if (!isPowo(s[oldy][oldx]) && oldy == 0) {
          if (second == 0) {
            second = 1;
          } else {
            ok = 0;
            break;
          }
        } else if (!isPowo(s[oldy][oldx]) && oldy == 1) {
          if (second == 0) {
            ok = 0;
            break;
          } else {
            second = 1;
          }
        }
      }
      oldy = pr.second;
      oldx = pr.first;
    }
    if (ok && first == n && second == 1) {
      cout << "YES\n";
    } else
      cout << "NO\n";
  }
  return 0;
}
