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

#define sync {ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
#define rep(n) for(int i = 0;i<n;i++)
#define rep1(a,b) for(int i = a;i<b;i++)
#define int long long int
#define mod 1000000007

int n;

void soln(int oc, int zc)
{
    string a = "";
    string b = "";
    int x = zc;
    int y = oc;
    if (x < y)
    {
        rep(x)
        {
            a += '0';
        }
        rep(y)
        {
            a += '1';
        }
        int div = x + 1;
        int par = y % div;
        int minm = y / div;
        string temp = "";
        string temp1 = "";
        rep(minm)
        {
            temp += '1';
            temp1 += '1';
        }
        temp += '1';
        temp += '0';
        temp1 += '0';
        rep(par)
        {
            b += temp;
        }
        rep(x + 1 - par)
        {
            b += temp1;
        }
        b.pop_back();
    }
    else
    {
        rep(y)
        {
            a += '1';
        }
        rep(x)
        {
            a += '0';
        }
        int div = y + 1;
        int par = x % div;
        int minm = x / div;
        string temp = "";
        string temp1 = "";
        rep(minm)
        {
            temp += '0';
            temp1 += '0';
        }
        temp += '0';
        temp += '1';
        temp1 += '1';
        rep(par)
        {
            b += temp;
        }
        rep(y + 1 - par)
        {
            b += temp1;
        }
        b.pop_back();
    }
    cout<<a<<endl;
    cout<<b<<endl;
}

void solve()
{
    cin>>n;
    string a;
    cin>>a;

    int oc = 0;
    int zc = 0;
    rep(n){
        if(a[i]=='0') zc++;
        else oc++;
    }
    soln(oc, zc);
}

int32_t main()
{

    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    
    sync;
    int t = 1;
    cin>>t;
    while(t--){
        solve();
        //cout<<"\n";
    }
    return 0;
}