There is a binary string a of length n. In one operation, you can select any prefix of a with an equal number of 0 and 1 symbols. Then all symbols in the prefix are inverted: each 0 becomes 1 and each 1 becomes 0.

For example, suppose a=0111010000. 

  * In the first operation, we can select the prefix of length 8 since it has four 0's and four 1's: [01110100]00→ [10001011]00. 
  * In the second operation, we can select the prefix of length 2 since it has one 0 and one 1: [10]00101100→ [01]00101100. 
  * It is illegal to select the prefix of length 4 for the third operation, because it has three 0's and one 1. 



Can you transform the string a into the string b using some finite number of operations (possibly, none)?

Input

The first line contains a single integer t (1≤ t≤ 10^4) — the number of test cases.

The first line of each test case contains a single integer n (1≤ n≤ 3⋅ 10^5) — the length of the strings a and b.

The following two lines contain strings a and b of length n, consisting of symbols 0 and 1.

The sum of n across all test cases does not exceed 3⋅ 10^5.

Output

For each test case, output "YES" if it is possible to transform a into b, or "NO" if it is impossible. You can print each letter in any case (upper or lower).

Example

Input


5
10
0111010000
0100101100
4
0000
0000
3
001
000
12
010101010101
100110011010
6
000111
110100


Output


YES
YES
NO
YES
NO

Note

The first test case is shown in the statement.

In the second test case, we transform a into b by using zero operations.

In the third test case, there is no legal operation, so it is impossible to transform a into b.

In the fourth test case, here is one such transformation: 

  * Select the length 2 prefix to get 100101010101. 
  * Select the length 12 prefix to get 011010101010. 
  * Select the length 8 prefix to get 100101011010. 
  * Select the length 4 prefix to get 011001011010. 
  * Select the length 6 prefix to get 100110011010. 



In the fifth test case, the only legal operation is to transform a into 111000. From there, the only legal operation is to return to the string we started with, so we cannot transform a into b.
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    
#include "bits/stdc++.h"

// #include <ext/rope>

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
     
using namespace std;
// using namespace __gnu_cxx;
//using namespace __gnu_pbds;
     
void err(istream_iterator<string> it) {cout << '\n';}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    string s = typeid(a).name();
    cout << "[" << *it << " = ";
    cout << a;
    cout << "] ";
    err(++it, args...);
}

void catchAlarm(int sig) {
    cout << "TL!!!!!";
    exit(0);
}
     
#define F first
#define S second
#define ll long long
#define ull unsigned ll
#define pb push_back
#define pf push_front
#define db double
#define ld long double
#define ofk order_of_key
#define fbo find_by_order
#define ppb pop_back
#define ppf pop_front
#define br cout << '\n'
#define pil pair<int, ll>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define here cout << "HERE\n"
#define bruh cout << "BRUH\n"
#define all(x) (x).begin(),(x).end()
#define __ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define watch(x) cout << (#x) << " is " << (x) << endl
#define TEST int TT; cin >> TT; for(int T = 1; T <= TT; T++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define sqr(x) ((x) * (x))

void assertTL(bool stat) {while(!stat){}}
void assertML(bool stat) {vector<ll> v;while(!stat){v.pb(1);}}

int gcd(int a, int b) {if (a < b) swap(a, b); return b ? gcd(b, a % b) : a;}
ll gcd(ll a, ll b) {if (a < b) swap(a, b); return b ? gcd(b, a % b) : a;}
   
pair<int, int> dx2[] = {{1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
pair<int, int> dx[] = {{0, -1}, {-1, 0}, {0, 1}, {1, 0}};

int inf = 2e9 + 7;
ll INF = 1e18 + 7;
//ld pi = 3.1415926535897932384626433;
db eps = 1e-7;
//ld EPS = 1e-9;
int mod = 1e9 + 7;
int mod2 = 1000010029;
int BASE = 1000117;
int base = 29;
ll MOD = 1e15 + 7;
    

mt19937 lol(chrono::steady_clock::now().time_since_epoch().count());


void Max(int &a, int b) {
    if (b > a) a = b;
}
void Min(int &a, int b) {
    if (b < a) a = b;
}   
void Max(ll &a, ll b) {
    if (b > a) a = b;
}
void Min(ll &a, ll b) {
    if (b < a) a = b;
}    
void Add(int &a, int b) {
    a += b;
    if (a >= mod) a -= mod;
}
void Sub(int &a, int b) {
    a -= b;
    if (a < 0) a += mod;
}
void mul(int &a, int b) {
    a = a * 1ll * b % mod;
}
int add(int a, int b) {
    a += b;
    if (a >= mod) a -= mod;
    return a;
}
int sub(int a, int b) {
    a -= b;
    if (a < 0) a += mod;
    return a;
}
int mul(int a, int b) {
    return a * 1ll * b % mod;
}

int bp(int a, int n, int mOd = mod) {
    if (n == 0) return 1;
    int res = bp(a, n / 2, mOd);
    res = res * 1ll * res % mOd;
    if (n & 1) res = res * 1ll * a % mOd;
    return res;
}


const bool multiple_tests = 1;
const int N = 1e6 + 77;

// #define int long long
#define pii pair<int, int>

string s, b;
int n;

void solve() { 
    cin >> n;
    cin >> s >> b;
    b = '.' + b;
    s = '.' + s;

    vector<int> v;
    int sum = 0;
    for (int i = 1; i <= n; i++) {
        if (s[i] == '1') sum++;
        else sum--;
        if (sum == 0) {
            v.pb(i);
        }
    }
    int prev = 1;
    for (int i: v) {
        // [prev, i]
        bool bo = 1, ok = 1;
        if (s[prev] != b[prev]) bo = 0;
        for (int j = prev; j <= i; j++) {
            if (bo) {
                if (s[j] != b[j]) {
                    ok = 0;
                    break;
                }
            }
            else {
                if (s[j] == b[j]) {
                    ok = 0;
                    break;
                }
            }
        }
        if (!ok) {
            cout << "NO";
            return;
        }
        prev = i + 1;
    }
    int from = 1;
    if (v.size()) 
        from = v.back() + 1;
    for (int i = from; i <= n; i++) {
        if (s[i] != b[i]) {
            cout << "NO";
            return;
        }
    }
    cout << "YES";
}

// KEEP IT SIMPLE


signed main() { __
    string file_name = "test";
    // file_name = "trains";
    #ifndef ONLINE_JUDGE
        signal(SIGALRM, catchAlarm);
        alarm(5);
        freopen((file_name + ".in").c_str(), "r", stdin);
        freopen((file_name + ".out").c_str(), "w", stdout);
    #endif
    int TT = 1;
    if (multiple_tests) cin >> TT;

    for (int testcase = 1; testcase <= TT; testcase++) {
        solve();
        cout << '\n';
    }
        
//    #ifndef ONLINE_JUDGE
//      cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
//    #endif
    return 0;
}