挺简单的贪心
#include <iostream>
#include <cstring>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <stdio.h>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define ll long long
inline ll read()
{
ll k = 0, f = 1; char ch = getchar();
while (ch < '0' || ch>'9')
{
if (ch == '-')
f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
{
k = k * 10 + ch - '0';
ch = getchar();
}
return k * f;
}
char a[50005];
char b[50005];
int main()
{
ll t=read();
while(t--)
{
ll n=read();
string s;
cin>>s;
int flag=0;
for(int i=0;i<n;i++)
{
a[i]='0';
b[i]='0';
}
for(int i=0;i<n;i++)
{
if(s[i]=='1')
{
if(flag)b[i]='1';
else
{
a[i]='1';
flag=1;
}
}
else if(s[i]=='2')
{
if(flag)b[i]='2';
else
{
a[i]='1';
b[i]='1';
}
}
}
for(int i=0;i<n;i++)printf("%c",a[i]);
printf("\n");
for(int i=0;i<n;i++)printf("%c",b[i]);
printf("\n");
}
}