#include<bits/stdc++.h>
#define ll long long
#define nl '\n'
#define F first
#define S second
#define pb push_back
#define all(a) (a.begin()),(a.end())
#define Input freopen("in.txt","r",stdin)
#define Output freopen("out.txt","w",stdout)
#define PI 2*acos(0.0)
#define MOD 1000000007
using namespace std;
const int N = 30 + 5;
int n, dp[N][3];
string s, t;
int FuN(int pos, int fg)
{
if (pos >= n)
{
return fg == 2;
}
if (dp[pos][fg] != -1) return dp[pos][fg];
int ret = 0;
char cur = s[pos], cur2 = t[pos];
if (fg == 1) {
cur = '1';
}
else if (fg == 0)
cur = '0';
if (cur == cur2)
{
ret |= FuN(pos + 1, 2);
if (cur2 == '1') {
ret |= FuN(pos + 1, 0);
}
if (cur2 == '0')
ret |= FuN(pos + 1, 1);
}
else {
if (cur2 == '0')
{
ret |= FuN(pos + 1, 1);
}
if (cur2 == '1') {
ret |= FuN(pos + 1, 0);
}
}
return dp[pos][fg] = ret;
}
void Solve()
{
cin >> n;
cin >> s >> t;
memset(dp, -1, sizeof(dp));
int ans = FuN(0, 2);
if (ans)
cout << "YES\n";
else
cout << "NO\n";
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int t, T = 1;
cin >> T;
for (t = 1; t <= T; t++)
Solve();
return 0;
}