#pragma GCC optimize("O3")   //
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, b, a) for(int i = b - 1; i >= a; i--)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;
typedef unsigned long long ull;

unsigned seed = chrono::system_clock::now().time_since_epoch().count();
mt19937 eng(seed);

ll random2(){
    return (1ll << 31ll)*eng()+eng();
}

ll n,m,k,q,T;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

const int MAXN = 200001;

string s1,s2,s3;
string S[3];

string alfa = "01";

string get(int a, int b, int c, int where){
    string res = "";
    if(where == 0)res += alfa[b];
    rep(c1,0,n){
        res += alfa[a];
    }
    if(where == 1)res += alfa[b];
    rep(c1,0,n){
        res += alfa[c];
    }
    if(where == 2)res += alfa[b];
    return res;
}

bool mat(string s, string t){
    int seen = 0;
    rep(c1,0,sz(s)){
        if(s[c1] == t[seen])seen++;
        if(seen == sz(t))return 1;
    }
    return 0;
}


string greedy(){
    int A[3] = {0};
    string res = "";

    rep(c1,0,2*n+1){
        int ma = -1;
        char choice;
        rep(c2,0,3){
            if(A[c2] > ma){
                ma = A[c2];
                choice = S[c2][A[c2]];
            }
        }
        res += choice;
        if(c1 == 2*n)break;
        rep(c2,0,3){
            while(S[c2][A[c2]] != choice){
                A[c2]++;
            }
            A[c2]++;
        }

    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    //freopen("fhc.txt","r",stdin);
    //freopen("autput.txt","w",stdout);

    ll a,b,c,d;

    cin >> T;
    rep(c4,0,T){
        cin >> n;
        cin >> s1 >> s2 >> s3;
        S[0] = s1+s1;
        S[1] = s2+s2;
        S[2] = s3+s3;
        string s = "";
        bool good = 0;
        rep(c1,0,2){
            rep(c2,0,2){
                rep(c3,0,2){
                    rep(where,0,3){
                        s = get(c1,c2,c3,where);
                        if(mat(s1+s1,s) && mat(s2+s2,s) && mat(s3+s3,s)){
                            good = 1;
                            goto label;
                        }
                    }
                }
            }
        }
        label:
        assert(good);
        cout << s << "\n";
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;

const int Maxn = 400004;

char tmp[Maxn];
int T;
int n;
string A, B, C;
int nxtA[Maxn][2], nxtB[Maxn][2], nxtC[Maxn][2];
char res[Maxn];
int rlen;

void Read(string &S, int nxt[][2])
{
	scanf("%s", tmp);
	S = tmp; S = S + S;
	nxt[S.length()][0] = nxt[S.length()][1] = S.length();
	for (int i = int(S.length()) - 1; i >= 0; i--) {
		nxt[i][0] = nxt[i + 1][0];
		nxt[i][1] = nxt[i + 1][1];
		nxt[i][S[i] - '0'] = i;
	}
}

int main()
{
	scanf("%d", &T);
	while (T--) {
		scanf("%d", &n);
		Read(A, nxtA);
		Read(B, nxtB);
		Read(C, nxtC);
		printf("%s%s%s\n", string(n, '0').c_str(), string(n, '1').c_str(), string(1, '0').c_str());
	}
    return 0;
}
