#include <bits/stdc++.h>

using namespace std;

int main(){
    int t; cin >> t;
    while(t--){
        int n; cin >> n;
        string a,b; 
        cin >> a >> b;
        a += '0';
        b += '0';
        int a0,a1;
        a0 = a1 = 0;
        bool ans = true;
        for(int i=0; i < n ; i++){
            if(a[i] == '0') a0++;
            else a1++;
            if((a[i] != b[i]) != (a[i+1] != b[i+1]) && a1 != a0){
                ans = false;
                break;
            }
        }
        cout << (ans ? "yes" : "no") << "\n";
    }
    return 0;
}