/**
*    author: kuins_air
*    created: 28.05.2021 11:21:10
**/

#include <bits/stdc++.h>
using namespace std;
#define rep(i, r, n) for(int i = r; i < (int)(n); i++)
#define ll long long

string S;
int main() {
    cin >> S;
    int n = (int)S.size();
    rep(i, 1, (int)S.size() + 1) {
        if(S[n-i] == '0') cout << 0;
        if(S[n-i] == '1') cout << 1;
        if(S[n-i] == '6') cout << 9;
        if(S[n-i] == '8') cout << 8;
        if(S[n-i] == '9') cout << 6;
    }
    cout << endl;

    return 0;
}
#include<bits/stdc++.h>
using namespace std;
const int N=4e5+10;
int T,n;
char s1[N],s2[N],s3[N];
int pos[4][2][N],now[4];
int main(){
	scanf("%d",&T);
	while(T--){
		scanf("%d",&n);
		scanf("%s%s%s",s1+1,s2+1,s3+1);
		for(int i=1;i<=n;++i) printf("0");
		for(int i=1;i<=n;++i) printf("1");
		printf("0\n");
	}
	return 0;
}