A number is ternary if it contains only digits $0$, $1$ and $2$. For example, the following numbers are ternary: $1022$, $11$, $21$, $2002$.

You are given a long ternary number $x$. The first (leftmost) digit of $x$ is guaranteed to be $2$, the other digits of $x$ can be $0$, $1$ or $2$.

Let's define the ternary XOR operation $\odot$ of two ternary numbers $a$ and $b$ (both of length $n$) as a number $c = a \odot b$ of length $n$, where $c_i = (a_i + b_i) \% 3$ (where $\%$ is modulo operation). In other words, add the corresponding digits and take the remainders of the sums when divided by $3$. For example, $10222 \odot 11021 = 21210$.

Your task is to find such ternary numbers $a$ and $b$ both of length $n$ and both without leading zeros that $a \odot b = x$ and $max(a, b)$ is the minimum possible.

You have to answer $t$ independent test cases.


-----Input-----

The first line of the input contains one integer $t$ ($1 \le t \le 10^4$) — the number of test cases. Then $t$ test cases follow. The first line of the test case contains one integer $n$ ($1 \le n \le 5 \cdot 10^4$) — the length of $x$. The second line of the test case contains ternary number $x$ consisting of $n$ digits $0, 1$ or $2$. It is guaranteed that the first digit of $x$ is $2$. It is guaranteed that the sum of $n$ over all test cases does not exceed $5 \cdot 10^4$ ($\sum n \le 5 \cdot 10^4$).


-----Output-----

For each test case, print the answer — two ternary integers $a$ and $b$ both of length $n$ and both without leading zeros such that $a \odot b = x$ and $max(a, b)$ is the minimum possible. If there are several answers, you can print any.


-----Example-----
Input
4
5
22222
5
21211
1
2
9
220222021

Output
11111
11111
11000
10211
1
1
110111011
110111010

Difficulty: EASY
Tags: Implementation

Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
for _ in range(int(input())):
	a = int(input())
	b = input()
	ans = ''
	if b.count('1'):
		for i in range(b.find('1')):
			ans += '0' if b[i] == '0' else '1'
		print(ans + '1' + '0' * (a - len(ans) - 1))
		print(ans + '0' + b[b.find('1') + 1:])
	else:
		print(b.replace('2', '1'))
		print(b.replace('2', '1'))


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		d = list(input())
		ans1 = [0] * n
		ans2 = [0] * n
		flag = 0
		for i in range(n):
			if d[i] == '0':
				ans1[i] = '0'
				ans2[i] = '0'
			elif d[i] == '1':
				if flag:
					ans1[i] = '1'
					ans2[i] = '0'
				else:
					ans1[i] = '0'
					ans2[i] = '1'
					flag = 1
			elif flag:
				ans1[i] = '2'
				ans2[i] = '0'
			else:
				ans1[i] = '1'
				ans2[i] = '1'
		print(''.join(ans1))
		print(''.join(ans2))
main()


import sys

def fastio():
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
(t,) = I()
while t:
	t -= 1
	(n,) = I()
	s = input()
	ans = [['0'] * n for i in range(2)]
	ans[0][0] = ans[1][0] = '1'
	p = 1
	for i in range(1, n):
		if s[i] == '0':
			continue
		if p and s[i] == '1':
			ans[0][i] = '1'
			p = 0
			continue
		if p and s[i] == '2':
			ans[0][i] = ans[1][i] = '1'
			continue
		ans[1][i] = s[i]
	print(''.join(ans[0]))
	print(''.join(ans[1]))


for _ in range(int(input())):
	n = int(input())
	lst = list(input())
	(a, b) = (['0'] * n, ['0'] * n)
	for i in range(n):
		if lst[i] == '1':
			a[i] = '1'
			b[i] = '0'
			for j in range(i + 1, n):
				b[j] = lst[j]
			break
		elif lst[i] == '0':
			a[i] = b[i] = '0'
		elif lst[i] == '2':
			a[i] = b[i] = '1'
	print(''.join(a))
	print(''.join(b))


t = int(input())
while t > 0:
	size = int(input())
	inp = str(input())
	a = []
	b = []
	flag = 0
	for i in range(size):
		if flag == 0:
			if inp[i] == '2':
				a.append(1)
				b.append(1)
			elif inp[i] == '0':
				a.append(0)
				b.append(0)
			else:
				a.append(1)
				b.append(0)
				flag = 1
		elif inp[i] == '2':
			a.append(0)
			b.append(2)
		elif inp[i] == '0':
			a.append(0)
			b.append(0)
		else:
			a.append(0)
			b.append(1)
	for i in range(size):
		print(a[i], end='')
	print()
	for i in range(size):
		print(b[i], end='')
	print()
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	fn = ''
	sn = ''
	c = 0
	for c in range(n):
		i = x[c]
		if i == '1':
			fn += '1'
			sn += '0'
			break
		elif i == '2':
			fn += '1'
			sn += '1'
		elif i == '0':
			fn += '0'
			sn += '0'
	if c != n - 1:
		fn += '0' * (n - c - 1)
		sn += x[c + 1:]
	print(fn)
	print(sn)


q = int(input())
for i in range(q):
	n = int(input())
	maxx = []
	minn = []
	s = input()
	yek = False
	for i in s:
		if i == '1' and (not yek):
			maxx.append(1)
			minn.append(0)
			yek = True
		elif i == '2' and (not yek):
			maxx.append(1)
			minn.append(1)
		elif i == '2' and yek:
			maxx.append(0)
			minn.append(2)
		elif i == '1' and yek:
			maxx.append(0)
			minn.append(1)
		elif i == '0':
			maxx.append(0)
			minn.append(0)
	for i in maxx:
		print(i, end='')
	print()
	for j in minn:
		print(j, end='')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	l = input()
	a = []
	b = []
	stop = False
	i = 0
	while not stop and i < n:
		if l[i] == '2':
			a.append('1')
			b.append('1')
		elif l[i] == '0':
			a.append('0')
			b.append('0')
		else:
			a.append('1')
			a += ['0'] * (n - i - 1)
			b.append('0')
			b += l[i + 1:]
			i = n
		i += 1
	print(''.join(a))
	print(''.join(b))


t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	a = '1'
	b = '1'
	flag = False
	for j in range(1, n):
		if flag == True:
			if x[j] == '0':
				a += '0'
				b += '0'
			elif x[j] == '1':
				a += '0'
				b += '1'
			else:
				a += '0'
				b += '2'
		elif x[j] == '0':
			a += '0'
			b += '0'
		elif x[j] == '1':
			a += '1'
			b += '0'
			flag = True
		else:
			a += '1'
			b += '1'
	print(a)
	print(b)


t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	bolshe = []
	menshe = []
	k = 0
	for j in range(len(x)):
		if int(x[j]) == 2:
			if not k:
				bolshe.append('1')
				menshe.append('1')
			else:
				bolshe.append('0')
				menshe.append('2')
		elif int(x[j]) == 1:
			if not k:
				bolshe.append('1')
				menshe.append('0')
				k = 1
			else:
				bolshe.append('0')
				menshe.append('1')
		else:
			bolshe.append('0')
			menshe.append('0')
	print(''.join(bolshe))
	print(''.join(menshe))


t = int(input())
for _ in range(t):
	n = int(input())
	ar = list(map(int, list(input())))
	a = ''
	b = ''
	k = False
	for i in range(n):
		if ar[i] == 2:
			if k:
				b += '2'
				a += '0'
			else:
				a += '1'
				b += '1'
		if ar[i] == 1:
			if k:
				b += '1'
				a += '0'
			else:
				a += '1'
				b += '0'
				k = True
		if ar[i] == 0:
			a += '0'
			b += '0'
	print(a)
	print(b)


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	a = ''
	b = ''
	diff = 0
	for i in range(n):
		if x[i] == '2' and diff == 0:
			a = a + '1'
			b = b + '1'
		elif x[i] == '2' and diff == 1:
			a = a + '0'
			b = b + '2'
		elif x[i] == '0':
			a = a + '0'
			b = b + '0'
		elif x[i] == '1' and diff == 0:
			a = a + '1'
			b = b + '0'
			diff = 1
		elif x[i] == '1' and diff == 1:
			a = a + '0'
			b = b + '1'
	print(a)
	print(b)


for _ in range(int(input())):
	n = int(input())
	s = input()
	(a, b) = (['0'] * n, ['0'] * n)
	k = -1
	for i in range(n):
		if s[i] == '0':
			a[i] = b[i] = '0'
		elif s[i] == '2':
			a[i] = b[i] = '1'
		else:
			a[i] = '1'
			b[i] = '0'
			k = i + 1
			break
	if k != -1:
		for i in range(k, n):
			b[i] = s[i]
	print(int(''.join(a)))
	print(int(''.join(b)))


t = int(input())
for i in range(t):
	n = int(input())
	c = str(input())
	(a, b) = ('1', '1')
	x = True
	for j in range(n - 1):
		if c[j + 1] == '0':
			a += '0'
			b += '0'
		elif c[j + 1] == '2' and x:
			a += '1'
			b += '1'
		elif c[j + 1] == '2' and (not x):
			a += '0'
			b += '2'
		elif x:
			a += '1'
			b += '0'
			x = False
		else:
			a += '0'
			b += '1'
	print(a, b, sep='\n')


for _ in range(int(input())):
	l = int(input())
	num = input()
	a = [0] * l
	b = [0] * l
	flag = 0
	for i in range(l):
		if flag == 0 and num[i] == '2':
			a[i] = 1
			b[i] = 1
		elif flag == 0 and num[i] == '1':
			a[i] = 1
			flag = 1
		elif flag == 1:
			b[i] = str(num[i])
	print(*a, sep='')
	print(*b, sep='')


t = int(input())
for i in range(t):
	count = 0
	c = list()
	d = list()
	n = int(input())
	a = int(input())
	b = list(map(int, str(a)))
	for i in b:
		if i == 1:
			if count == 0:
				c.append(1)
				d.append(0)
				count += 1
			else:
				c.append(0)
				d.append(1)
		elif i == 0:
			c.append(0)
			d.append(0)
		elif count == 0:
			c.append(1)
			d.append(1)
		else:
			c.append(0)
			d.append(2)
	ans1 = int(''.join(map(str, c)))
	ans2 = int(''.join(map(str, d)))
	print(ans1)
	print(ans2)


(z, zz) = (input, lambda : list(map(int, z().split())))
(szz, dgraphs, mod) = (lambda : sorted(zz()), {}, 10 ** 9 + 7)
from string import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
num = int(z())
for _ in range(num):
	n = int(z())
	l = z()
	a = ''
	b = ''
	c = 0
	for i in l:
		try:
			if c:
				a += '0'
				b += i
			elif i == '0':
				a += '0'
				b += '0'
			elif i == '2':
				a += '1'
				b += '1'
			else:
				a += '1'
				b += '0'
				c = 1
		except:
			pass
	print(a)
	print(b)


for _ in range(int(input())):
	n = int(input())
	x = input()
	(r1, r2) = (['0' for i in range(n)], ['0' for i in range(n)])
	(f1, f2) = (0, 0)
	for i in range(n):
		if x[i] == '2':
			r1[i] = r2[i] = '1'
		elif x[i] == '0':
			r1[i] = r2[i] = '0'
		else:
			r1[i] = '0'
			r1[i + 1:] = x[i + 1:]
			r2[i] = '1'
			r2[i + 1:] = '0' * (n - i - 1)
			break
	print(''.join(r1))
	print(''.join(r2))


t = int(input())
for fhafg in range(t):
	n = int(input())
	x = input()
	f = False
	ans1 = ''
	ans2 = ''
	for i in x:
		if f:
			ans1 += '0'
			ans2 += i
		elif i == '1':
			f = True
			ans1 += '1'
			ans2 += '0'
		elif i == '2':
			ans1 += '1'
			ans2 += '1'
		else:
			ans1 += '0'
			ans2 += '0'
	print(ans1)
	print(ans2)


t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	a = [0 for j in range(n)]
	b = [0 for j in range(n)]
	flag = -1
	for j in range(n):
		if x[j] == '1':
			a[j] = '1'
			b[j] = '0'
			break
		elif x[j] == '2':
			a[j] = '1'
			b[j] = '1'
		else:
			a[j] = '0'
			b[j] = '0'
	for k in range(j + 1, n):
		if x[k] == '2':
			a[k] = '0'
			b[k] = '2'
		elif x[k] == '1':
			a[k] = '0'
			b[k] = '1'
		else:
			a[k] = '0'
			b[k] = '0'
	for j in range(n):
		print(a[j], end='')
	print()
	for j in range(n):
		print(b[j], end='')
	print()


import math
from collections import Counter
for _ in range(int(input())):
	n = int(input())
	s = input()
	s1 = '1'
	s2 = '1'
	i = 1
	while i < n:
		if s[i] == '2':
			s1 += '1'
			s2 += '1'
		elif s[i] == '0':
			s1 += '0'
			s2 += '0'
		elif s[i] == '1':
			s1 += '1'
			s2 += '0'
			break
		i += 1
	s1 += (n - len(s1)) * '0'
	s2 += s[i + 1:]
	print(s1)
	print(s2)


t = int(input())
for tc in range(t):
	n = int(input())
	x = list(map(int, input()))
	(a, b) = (['1'], ['1'])
	metOne = False
	for ch in x[1:]:
		if ch == 2:
			if metOne:
				a.append('2')
				b.append('0')
			else:
				a.append('1')
				b.append('1')
		elif ch == 1:
			if metOne:
				a.append('1')
				b.append('0')
			else:
				a.append('0')
				b.append('1')
			metOne = True
		else:
			a.append('0')
			b.append('0')
	print(''.join(b))
	print(''.join(a))


def main():
	for _ in range(int(input())):
		n = int(input())
		string = input()
		(a, b, greater) = ('1', '1', 'neither')
		for i in range(1, n):
			if string[i] == '2':
				if greater == 'neither':
					a += '1'
					b += '1'
				elif greater == 'a':
					a += '0'
					b += '2'
				else:
					a += '2'
					b += '0'
			elif string[i] == '1':
				if greater == 'neither':
					a += '1'
					b += '0'
					greater = 'a'
				elif greater == 'a':
					a += '0'
					b += '1'
				else:
					a += '1'
					b += '0'
			else:
				a += '0'
				b += '0'
		print(a)
		print(b)
main()


a = []
b = []
for _ in range(int(input())):
	x = int(input())
	xx = list(input())
	flag = 0
	for i in xx:
		if i == '2':
			if flag == 0:
				a.append('1')
				b.append('1')
			elif flag == 1:
				a.append('0')
				b.append('2')
		elif i == '1':
			if flag == 0:
				a.append('1')
				b.append('0')
				flag = 1
			elif flag == 1:
				a.append('0')
				b.append('1')
		else:
			a.append('0')
			b.append('0')
	print(''.join(a))
	print(''.join(b))
	a.clear()
	b.clear()


for _ in range(int(input())):
	n = int(input())
	x = input()
	(a, b) = ('1', '1')
	a_is_biger = None
	for i in range(1, n):
		char = x[i]
		if char == '0':
			a += '0'
			b += '0'
		elif char == '1':
			if a_is_biger:
				b += '1'
				a += '0'
			else:
				a_is_biger = True
				a += '1'
				b += '0'
		elif char == '2':
			if a_is_biger:
				b += '2'
				a += '0'
			elif a_is_biger is None:
				a += '1'
				b += '1'
	print(a)
	print(b)


for i in range(int(input())):
	n = input()
	x = input()
	a = ['1', '1']
	p = 0
	for i in x[1:]:
		if p == 0:
			if i == '0':
				a[0] = a[0] + '0'
				a[1] = a[1] + '0'
			if i == '2':
				a[0] = a[0] + '1'
				a[1] = a[1] + '1'
			if i == '1':
				a[0] = a[0] + '1'
				a[1] = a[1] + '0'
				p += 1
		else:
			a[0] = a[0] + '0'
			a[1] = a[1] + i
	print(a[0])
	print(a[1])


t = int(input())
while t > 0:
	n = input()
	x = input()
	n = int(n)
	a = []
	b = []
	a.append('1')
	b.append('1')
	eq = 1
	for i in range(1, n):
		if x[i] == '0':
			a.append('0')
			b.append('0')
		elif eq == 1:
			if x[i] == '2':
				a.append('1')
				b.append('1')
			else:
				a.append('1')
				b.append('0')
				eq = -1
		else:
			a.append('0')
			b.append(x[i])
	a1 = ''.join(a)
	b1 = ''.join(b)
	print(a1)
	print(b1)
	t -= 1


import sys
import math
lines = sys.stdin.readlines()
T = int(lines[0])
for t in range(T):
	N = int(lines[2 * t + 1].strip())
	num = lines[2 * t + 2].strip()
	A = '1'
	B = '1'
	index = -1
	for i in range(1, N):
		l = num[i]
		if l == '0':
			A += '0'
			B += '0'
		elif l == '2':
			A += '1'
			B += '1'
		elif l == '1':
			A += '1'
			B += '0'
			index = i + 1
			break
	if index != -1:
		A += '0' * (N - index)
		B += num[index:]
	print(A)
	print(B)


def solve(n, x, ans):
	a = []
	b = []
	found = False
	for i in range(n):
		if i == 0:
			a.append(1)
			b.append(1)
		elif x[i] == '0':
			a.append(0)
			b.append(0)
		elif x[i] == '2':
			if not found:
				a.append(1)
				b.append(1)
			else:
				a.append(0)
				b.append(2)
		elif not found:
			a.append(1)
			b.append(0)
			found = True
		else:
			a.append(0)
			b.append(1)
	ans.append(a)
	ans.append(b)

def main():
	ans = []
	t = int(input())
	for i in range(t):
		n = int(input())
		x = input()
		solve(n, x, ans)
	for i in ans:
		for j in i:
			print(j, end='')
		print()
main()


import os
import io
import sys
from collections import Counter, defaultdict
import math
import random
import heapq as hq
from functools import reduce, cmp_to_key
from collections import deque
import threading
import bisect

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
for _ in range(iinput()):
	n = iinput()
	x = input()
	a = ''
	b = ''
	done = False
	for i in x:
		if i == '2':
			if done:
				a += '0'
				b += '2'
			else:
				a += '1'
				b += '1'
		elif i == '1':
			if done:
				a += '0'
				b += '1'
			else:
				a += '1'
				b += '0'
				done = True
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


T = int(input())
S = {}
for t in range(T):
	N = int(input())
	x = input()
	a = ''
	b = ''
	for n in range(N):
		if x[n] == '1':
			a = a + '1' + '0' * (N - n - 1)
			b = b + '0' + x[n + 1:]
			break
		else:
			a = a + str(int(x[n]) // 2)
			b = b + str(int(x[n]) // 2)
	print(a)
	print(b)


import sys
t = int(input())
for _ in range(t):
	n = input()
	x = input().strip()
	a = []
	b = []
	same = True
	for c in x:
		if same:
			if c == '2':
				a.append('1')
				b.append('1')
			elif c == '0':
				a.append('0')
				b.append('0')
			else:
				a.append('1')
				b.append('0')
				same = False
		else:
			a.append('0')
			b.append(c)
	print(''.join(a))
	print(''.join(b))


t = int(input())
dump = []
for i in range(t):
	n = int(input())
	x = list(input())
	flag = False
	a = [0 for _ in range(n)]
	b = [0 for _ in range(n)]
	for (idx, ele) in enumerate(x):
		if idx == 0:
			a[idx] = '1'
			b[idx] = '1'
		elif flag:
			if ele == '2':
				a[idx] = '0'
				b[idx] = '2'
			if ele == '1':
				a[idx] = '0'
				b[idx] = '1'
			if ele == '0':
				a[idx] = '0'
				b[idx] = '0'
		else:
			if ele == '2':
				a[idx] = '1'
				b[idx] = '1'
			if ele == '1':
				a[idx] = '1'
				b[idx] = '0'
				flag = True
			if ele == '0':
				a[idx] = '0'
				b[idx] = '0'
	dump.append(''.join(a))
	dump.append(''.join(b))
for d in dump:
	print(d)


import sys
t = int(sys.stdin.readline())

def search(x, n):
	a = '1'
	b = '1'
	g = 0
	for i in range(1, n):
		v = x[i]
		if g == 0:
			if v == '2':
				a += '1'
				b += '1'
			elif v == '1':
				a += '1'
				b += '0'
				g = 1
			else:
				a += '0'
				b += '0'
		elif g == 1:
			if v == '2':
				a += '0'
				b += '2'
			elif v == '1':
				a += '0'
				b += '1'
			else:
				a += '0'
				b += '0'
	return (a, b)
for _ in range(t):
	n = int(sys.stdin.readline())
	x = sys.stdin.readline().split()[0]
	(a, b) = search(x, n)
	print(a)
	print(b)


import sys
import math
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	s = sys.stdin.readline()[:-1]
	a = ['0' for x in range(n)]
	b = ['0' for x in range(n)]
	a[0] = '1'
	b[0] = '1'
	z = True
	for i in range(1, n):
		if z:
			if s[i] == '2':
				a[i] = '1'
				b[i] = '1'
				continue
			elif s[i] == '1':
				a[i] = '1'
				z = False
				continue
		else:
			b[i] = s[i]
	print(''.join((x for x in a)))
	print(''.join((x for x in b)))


import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random
import string

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
for _ in range(ii()):
	n = ii()
	s = [int(x) for x in input()]
	a = []
	b = []
	f = 1
	for i in s:
		if i == 0:
			a.append(0)
			b.append(0)
		elif i == 2:
			if f:
				a.append(1)
				b.append(1)
			else:
				a.append(0)
				b.append(2)
		elif f:
			a.append(1)
			b.append(0)
			f = 0
		else:
			a.append(0)
			b.append(1)
	prr(a, '')
	prr(b, '')


ASCII_0 = ord('0')

def compute_operands(x):
	a = ''
	b = ''
	only_use_a = False
	only_use_b = False
	for digit in x:
		d = ord(digit) - ASCII_0
		if d == 0:
			a += '0'
			b += '0'
		elif d == 1:
			if only_use_a:
				a += '1'
				b += '0'
			elif only_use_b:
				a += '0'
				b += '1'
			else:
				a += '1'
				b += '0'
		elif only_use_a:
			a += '2'
			b += '0'
		elif only_use_b:
			a += '0'
			b += '2'
		else:
			a += '1'
			b += '1'
		if ord(a[-1]) < ord(b[-1]) and (not (only_use_a or only_use_b)):
			only_use_a = True
		elif ord(a[-1]) > ord(b[-1]) and (not (only_use_a or only_use_b)):
			only_use_b = True
		else:
			pass
	return (a, b)

def run_alg():
	num_cases = int(input())
	for _ in range(num_cases):
		_ = int(input())
		x = input()
		(a, b) = compute_operands(x)
		print(a)
		print(b)
run_alg()


t = int(input())
while t:
	n = input()
	x = input()
	a = ''
	b = ''
	for i in x:
		if a == b:
			if i == '2':
				a += '1'
				b += '1'
			elif i == '1':
				a += '1'
				b += '0'
			else:
				a += '0'
				b += '0'
		elif a > b:
			if i == '2':
				b += '2'
				a += '0'
			elif i == '1':
				b += '1'
				a += '0'
			else:
				a += '0'
				b += '0'
	print(a)
	print(b)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	j = [1]
	k = [1]
	flag = 0
	l = input()
	s = [int(x) for x in l]
	for i in range(1, len(s)):
		if flag == 0:
			if s[i] == 2:
				j.append(1)
				k.append(1)
			elif s[i] == 1:
				j.append(1)
				k.append(0)
				flag = 1
			else:
				j.append(0)
				k.append(0)
		elif s[i] == 2:
			j.append(0)
			k.append(2)
		elif s[i] == 1:
			j.append(0)
			k.append(1)
		else:
			j.append(0)
			k.append(0)
	ans1 = ''
	ans2 = ''
	for i in j:
		ans1 += str(i)
	for i in k:
		ans2 += str(i)
	print(ans1)
	print(ans2)


for _ in range(int(input())):
	n = int(input())
	x = input()
	a = ''
	b = ''
	ch = 0
	for i in range(n):
		if x[i] == '2':
			if ch:
				a += '2'
				b += '0'
			else:
				a += '1'
				b += '1'
		elif x[i] == '1':
			a += '1'
			b += '0'
			if not ch:
				ch = 1
				(a, b) = (b, a)
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


for t in range(int(input())):
	n = int(input())
	ans = input()
	output1 = '1'
	output2 = '1'
	flag = 0
	j = 0
	length = len(ans)
	for i in range(1, length):
		if ans[i] == '0':
			output1 += '0'
			output2 += '0'
		if ans[i] == '1':
			output1 += ans[i]
			output2 += '0'
			j = i
			break
		if ans[i] == '2':
			output1 += '1'
			output2 += '1'
			continue
	if j != 0:
		output2 += ans[j + 1:]
		leng = len(ans[j + 1:])
		output1 += '0' * leng
	print(output1)
	print(output2)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	if s[0] == '0':
		flag = -1
	else:
		flag = 1
	a = ''
	b = ''
	m = 0
	for i in s:
		if i == '0':
			if flag == -1:
				a = a + '2'
				b = b + '1'
				flag = 1
				m = 1
			else:
				a = a + '0'
				b = b + '0'
		elif i == '1':
			if m == 0:
				a = a + '1'
				b = b + '0'
				m = 1
			else:
				a = a + '0'
				b = b + '1'
		elif m == 0:
			a = a + '1'
			b = b + '1'
		else:
			a = a + '0'
			b = b + '2'
	for i in a:
		print(int(i), end='')
	print()
	for i in b:
		print(int(i), end='')
	print()


from math import *
for _ in range(int(input())):
	n = int(input())
	x = input()
	(a, b) = ('', '')
	if x.count('1') == 0:
		for i in x:
			if i == '2':
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '0'
	else:
		a += '1'
		b += '1'
		count = 0
		for i in range(1, n):
			if x[i] == '2':
				if count == 0:
					a += '1'
					b += '1'
				else:
					a += '0'
					b += '2'
			elif x[i] == '0':
				a += '0'
				b += '0'
			else:
				count += 1
				if count == 1:
					a += '1'
					b += '0'
				else:
					a += '0'
					b += '1'
	print(a)
	print(b)


for _ in range(int(input())):
	n = int(input())
	a = int(input())
	s1 = ''
	s2 = ''
	f = True
	for i in str(a):
		if i == '2':
			if f:
				s1 = s1 + '1'
				s2 = s2 + '1'
			else:
				s1 = s1 + '0'
				s2 = s2 + '2'
		elif i == '1':
			if f:
				s1 = s1 + '1'
				s2 = s2 + '0'
				f = False
			else:
				s1 = s1 + '0'
				s2 = s2 + '1'
		else:
			s1 = s1 + '0'
			s2 = s2 + '0'
	print(s1)
	print(s2)


def triple_xor(number):
	pairs = [[(0, 0), (1, 0), (1, 1)], [(0, 0), (0, 1), (0, 2)]]
	first_number = second_number = '1'
	max_obtained = 0
	for i in number[1:]:
		pair = pairs[max_obtained]
		first_number += str(pair[i][0])
		second_number += str(pair[i][1])
		max_obtained = max_obtained or int(pair[i][0] - pair[i][1] == 1)
	return (first_number, second_number)
count_numbers = int(input())
numbers = []
for _ in range(count_numbers):
	_ = input()
	numbers.append([int(s) for s in list(input())])
results = ['\n'.join(triple_xor(n)) for n in numbers]
print('\n'.join(results), sep='')


t = int(input())
for i in range(t):
	n = int(input())
	m = input()
	array = []
	for i in m:
		array.append(int(i))
	l = []
	for i in range(0, len(array)):
		if array[i] != 1:
			l.append(str(array[i] // 2))
		else:
			l.append('1')
			break
	for i in range(0, len(array) - len(l)):
		l.append(str(0))
	one = ''
	for i in range(0, len(l)):
		one += l[i]
	two = int(m) - int(one)
	print(one)
	print(two)


t = int(input())
for i in range(t):
	n = int(input())
	s = input().rstrip()
	s = [int(i) for i in s]
	a = [1]
	b = [1]
	flag = 0
	for i in range(1, n):
		if s[i] == 1:
			flag = i
			break
		elif s[i] == 2:
			a.append(1)
			b.append(1)
		else:
			a.append(0)
			b.append(0)
	if flag > 0:
		g = n - flag
		a.append(1)
		b.append(0)
		for j in range(g - 1):
			a.append(0)
		for j in range(flag + 1, n):
			if s[j] == 0:
				b.append(0)
			elif s[j] == 1:
				b.append(1)
			else:
				b.append(2)
	s1 = ''
	s2 = ''
	for i in a:
		s1 += str(i)
	for i in b:
		s2 += str(i)
	print(s1)
	print(s2)


import sys
input = sys.stdin.readline

def input_list():
	return [int(x) for x in input().split()]

def c():
	k = int(input())
	s = input()
	x = [['1' for _ in range(k)] for _ in range(2)]
	bigger = 2
	for i in range(1, k):
		if s[i] == '0':
			x[0][i] = '0'
			x[1][i] = '0'
		elif s[i] == '1':
			if bigger == 2:
				x[0][i] = '1'
				x[1][i] = '0'
				bigger = 0
			else:
				x[bigger][i] = '0'
				x[abs(bigger - 1)][i] = '1'
		elif bigger == 2:
			x[0][i] = '1'
			x[1][i] = '1'
		else:
			x[bigger][i] = '0'
			x[abs(bigger - 1)][i] = '2'
	print(''.join(x[0]))
	print(''.join(x[1]))

def main():
	n = int(input())
	for _ in range(n):
		c()
main()


for _ in range(int(input())):
	n = int(input())
	l = input()
	(a, b) = (list((1 for i in range(n))), list((1 for i in range(n))))
	status = 0
	for i in range(1, n):
		if status == 0:
			if l[i] == '0':
				a[i] = 0
				b[i] = 0
			elif l[i] == '1':
				b[i] = 0
				status = 1
		elif status == 1:
			if l[i] == '0':
				a[i] = 0
				b[i] = 0
			elif l[i] == '1':
				a[i] = 0
			else:
				a[i] = 0
				b[i] = 2
	for i in a:
		print(i, end='')
	print()
	for i in b:
		print(i, end='')
	print()


nn = int(input())
for i in range(nn):
	n = int(input())
	s = input()
	a = ''
	b = ''
	flag = -1
	for j in range(len(s)):
		if s[j] == '1':
			a += '1'
			b += '0'
			flag = j + 1
			break
		if s[j] == '0':
			a += '0'
			b += '0'
		if s[j] == '2':
			a += '1'
			b += '1'
	if flag == -1:
		print(a)
		print(b)
	else:
		for j in range(flag, len(s)):
			a += '0'
			b += s[j]
		print(a)
		print(b)


t = int(input())

def results(n, x):
	a = []
	b = []
	c = 0
	for i in x:
		if i == 0:
			if c == 0:
				a.append(0)
				b.append(0)
			elif c >= 1:
				a.append(0)
				b.append(i)
		elif i == 2:
			if c == 0:
				a.append(1)
				b.append(1)
			elif c >= 1:
				a.append(0)
				b.append(i)
		elif i == 1:
			if c == 0:
				a.append(1)
				b.append(0)
			elif c >= 1:
				a.append(0)
				b.append(i)
			c += 1
	for i in a:
		print(i, end='')
	print('')
	for i in b:
		print(i, end='')
	print('')
for _ in range(t):
	n = int(input())
	str = input()
	x = []
	for i in str:
		x.append(int(i))
	results(n, x)


for _ in range(int(input())):
	input()
	x = input()
	d = False
	(a, b) = ([], [])
	for v in x:
		if v == '0':
			a.append('0')
			b.append('0')
		elif v == '1':
			if d:
				a.append('0')
				b.append('1')
			else:
				a.append('1')
				b.append('0')
				d = True
		elif v == '2':
			if d:
				a.append('0')
				b.append('2')
			else:
				a.append('1')
				b.append('1')
	print(''.join(a))
	print(''.join(b))


t = int(input())
for _ in range(t):
	n = int(input())
	l = input()
	l = list(l)
	a = []
	b = []
	flag = 0
	for i in range(0, n):
		if l[i] == '2' and flag == 0:
			a.append(1)
			b.append(1)
		elif l[i] == '0' and flag == 0:
			a.append(0)
			b.append(0)
		elif l[i] == '1' and flag == 0:
			a.append(1)
			b.append(0)
			flag = 1
		elif flag == 1:
			a.append(0)
			b.append(l[i])
	a = ''.join([str(i) for i in a])
	b = ''.join([str(i) for i in b])
	print(a)
	print(b)


t = int(input())
for test in range(t):
	n = int(input())
	x = input()
	a = ''
	b = ''
	for i in range(n):
		if x[i] == '0':
			a += '0'
			b += '0'
		elif x[i] == '2':
			a += '1'
			b += '1'
		else:
			a += '1'
			b += '0'
			remaining = n - 1 - i
			if remaining > 0:
				a += '0' * remaining
				b += x[-remaining:]
			break
	print(a)
	print(b)


t = int(input())
ans = [''] * (t * 2)
for k in range(t):
	n = int(input())
	x = input()
	a = 0
	b = 0
	av = ['0'] * n
	bv = ['0'] * n
	for i in range(n):
		a *= 3
		b *= 3
		if x[i] == '2':
			if a == b:
				a += 1
				b += 1
				av[i] = '1'
				bv[i] = '1'
			elif a < b:
				a += 2
				av[i] = '2'
			elif b < a:
				b += 2
				bv[i] = '2'
		elif x[i] == '1':
			if a < b:
				a += 1
				av[i] = '1'
			else:
				b += 1
				bv[i] = '1'
	ans[2 * k] = ''.join(av)
	ans[2 * k + 1] = ''.join(bv)
print('\n'.join(ans))


def func(c, n):
	(a, b) = ('1', '1')
	for i in c[1:]:
		if i == '0':
			a += '0'
			b += '0'
		elif i == '1':
			if a > b:
				b += '1'
				a += '0'
			else:
				a += '1'
				b += '0'
		elif i == '2':
			if a > b:
				b += '2'
				a += '0'
			elif a < b:
				a += '2'
				b += '0'
			else:
				a += '1'
				b += '1'
	ans = a + ' ' + b
	return ans
t = int(input())
for i in range(t):
	n = int(input())
	c = input()
	ans = func(c, n)
	ans = ans.split()
	(a1, a2) = (ans[0], ans[1])
	print(a1)
	print(a2)


for _ in range(int(input())):
	n = int(input())
	s = input()
	res1 = res2 = '1'
	swapped = False
	for i in s[1:]:
		if i == '2':
			if swapped:
				res1 += '2'
				res2 += '0'
			else:
				res1 += '1'
				res2 += '1'
		elif i == '1':
			res1 += '1'
			res2 += '0'
			if not swapped:
				(res1, res2) = (res2, res1)
				swapped = True
		else:
			res1 += '0'
			res2 += '0'
	print(res1)
	print(res2)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	a = ''
	b = ''
	ma = 0
	for j in range(n):
		if j == 0:
			if s[j] == '2':
				a += '1'
				b += '1'
			elif s[j] == '0':
				a += '2'
				b += '1'
				ma += 1
			else:
				a += '2'
				b += '2'
		elif s[j] == '2':
			if ma == 0:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
		elif s[j] == '0':
			a += '0'
			b += '0'
		elif ma == 0:
			a += '1'
			b += '0'
			ma += 1
		else:
			a += '0'
			b += '1'
	print(a)
	print(b)


for t in range(int(input())):
	n = int(input())
	x = list(map(int, list(input())))
	a = [1]
	b = [1]
	first = False
	for i in range(1, n):
		if x[i] == 0:
			a.append(0)
			b.append(0)
		if x[i] == 1:
			if not first:
				a.append(1)
				b.append(0)
				first = True
			else:
				a.append(0)
				b.append(1)
		if x[i] == 2:
			if first:
				a.append(0)
				b.append(2)
			else:
				a.append(1)
				b.append(1)
	A = ''
	for i in a:
		A += str(i)
	B = ''
	for i in b:
		B += str(i)
	print(A)
	print(B)


from collections import defaultdict, deque
from itertools import permutations
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
from copy import deepcopy
import heapq
int_input = lambda : int(stdin.readline())
string_input = lambda : stdin.readline().split()
multi_int_input = lambda : map(int, stdin.readline().split())
multi_input = lambda : stdin.readline().split()
list_input = lambda : list(map(int, stdin.readline().split()))
string_list_input = lambda : list(string_input())
MOD = pow(10, 9) + 7
test = int_input()
for _ in range(test):
	n = int_input()
	number = input()
	a = ''
	b = ''
	start = 0
	for i in range(n):
		char = number[i]
		if char == '2':
			if start == 0:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
				start += 1
		elif char == '1':
			if start == 0:
				a += '1'
				b += '0'
				start += 1
			else:
				a += '0'
				b += '1'
				start += 1
		elif char == '0':
			a += '0'
			b += '0'
	print(a)
	print(b)


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	(a, b) = ('', '')
	bool = True
	for i in x:
		if i == '1':
			if bool:
				b += '1'
				a += '0'
				bool = False
			else:
				a += '1'
				b += '0'
		elif i == '0':
			b += '0'
			a += '0'
		elif bool:
			b += '1'
			a += '1'
		else:
			b += '0'
			a += '2'
	print(a)
	print(b)


test = int(input())
for i in range(test):
	n = int(input())
	x = int(input())
	xstr = str(x)
	a = ''
	b = ''
	l_val = None
	for l in range(n):
		if xstr[l] == '2':
			a = a + '1'
			b = b + '1'
		elif xstr[l] == '0':
			a = a + '0'
			b = b + '0'
		else:
			l_val = l
			a = a + '1' + '0' * (n - 1 - l_val)
			b = b + '0'
			break
	if l_val:
		b = b + xstr[l_val + 1:]
	print(int(a))
	print(int(b))


for i in range(int(input())):
	x = int(input())
	s = input()
	num1 = '1'
	num2 = '1'
	ch = False
	for i in range(1, x):
		if ch:
			num2 += s[i]
			num1 += '0'
		elif s[i] == '0':
			num1 += '0'
			num2 += '0'
		elif s[i] == '1':
			num1 += '1'
			num2 += '0'
			ch = True
		else:
			num1 += '1'
			num2 += '1'
	print(num1)
	print(num2)


for _ in range(int(input())):
	n = int(input())
	s = input()
	s1 = '1'
	s2 = '1'
	for i in range(1, len(s)):
		if s[i] == '2':
			s1 += '1'
			s2 += '1'
		elif s[i] == '0':
			s1 += '0'
			s2 += '0'
		else:
			s1 += '0' + s[i + 1:]
			s2 += '1' + '0' * (len(s) - i - 1)
			break
	print(s1)
	print(s2)


t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	s = ''
	s1 = ''
	a = True
	for i in x:
		if i == '2' and a:
			s = s + '1'
			s1 = s1 + '1'
		elif i == '2':
			s = s + '0'
			s1 = s1 + '2'
		if i == '0':
			s = s + '0'
			s1 = s1 + '0'
		if i == '1' and a:
			a = False
			s = s + '1'
			s1 = s1 + '0'
		elif i == '1':
			s = s + '0'
			s1 = s1 + '1'
	print(s)
	print(s1)


from math import *
T = int(input())
for _ in range(T):
	n = int(input())
	Str = list(map(int, list(input())))
	a = ['1']
	b = ['1']
	for k in range(1, n):
		i = Str[k]
		if i == 2:
			a.append('1')
			b.append('1')
		elif i == 1:
			a.append('1')
			b.append('0')
			for j in range(k + 1, n):
				a.append('0')
				b.append(str(Str[j]))
			break
		else:
			a.append('0')
			b.append('0')
	print(''.join(a))
	print(''.join(b))


debug = False
for _ in range(int(input())):
	n = int(input())
	s = input()
	a = []
	b = []
	i = 0
	while i < n:
		if s[i] == '0':
			a.append('0')
			b.append('0')
		elif s[i] == '2':
			a.append('1')
			b.append('1')
		elif s[i] == '1':
			a.append('1')
			b.append('0')
			i += 1
			break
		i += 1
	while i < n:
		a.append('0')
		b.append(s[i])
		i += 1
	print(''.join(a), ''.join(b), sep='\n')


t = int(input())

def numgen(x):
	if x == '0':
		return ['0', '0', '0', '0']
	elif x == '1':
		return ['0', '1', '1', '0']
	else:
		return ['1', '1', '2', '0']
for xx in range(t):
	n = int(input())
	x = input()
	flag = 0
	a = ''
	b = ''
	for tt in x:
		add = 0
		if flag >= 1:
			add = 2
		if tt == '1':
			flag += 1
		lis = numgen(tt)
		a += lis[0 + add]
		b += lis[1 + add]
	print(a)
	print(b)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	arr = [i for i in s]
	res1 = ''
	res2 = ''
	flag = False
	for i in arr:
		if i == '2':
			if i == 0 or flag == False:
				res1 += '1'
				res2 += '1'
			else:
				res1 += '0'
				res2 += '2'
		elif i == '0':
			res1 += '0'
			res2 += '0'
		elif flag:
			res1 += '0'
			res2 += '1'
		else:
			res1 += '1'
			res2 += '0'
			flag = True
	print(res1)
	print(res2)


s = ''
for _ in range(int(input())):
	n = int(input())
	xn = list(map(int, input().strip()))
	i = 0
	s1 = ''
	s2 = ''
	state = 0
	while i < n:
		if xn[i] == 2:
			if state == 0:
				s1 += '1'
				s2 += '1'
			else:
				s1 += '0'
				s2 += '2'
		elif xn[i] == 0:
			s1 += '0'
			s2 += '0'
		elif state == 0:
			state = 1
			s1 += '1'
			s2 += '0'
		else:
			s1 += '0'
			s2 += '1'
		i += 1
	print(s1)
	print(s2)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
for i in range(n):
	n1 = int(input())
	a = [0] * n1
	b = [0] * n1
	a[0] = 1
	b[0] = 1
	t = 0
	c = list(input())
	for j in range(1, n1):
		if c[j] == '0':
			a[j] = 0
			b[j] = 0
		elif c[j] == '2':
			if t == 0:
				a[j] = 1
				b[j] = 1
			else:
				a[j] = 2
				b[j] = 0
		elif t == 0:
			a[j] = 0
			b[j] = 1
			t = 1
		else:
			a[j] = 1
			b[j] = 0
	print(*a, sep='')
	print(*b, sep='')


import math
q = int(input())
for z in range(0, q):
	d = int(input())
	n = input()
	a = ['1']
	b = ['1']
	equality = True
	for i in range(1, d):
		if n[i] == '0':
			a.append('0')
			b.append('0')
		elif equality:
			if n[i] == '1':
				equality = False
				a.append('1')
				b.append('0')
			elif n[i] == '2':
				a.append('1')
				b.append('1')
		elif n[i] == '1':
			a.append('0')
			b.append('1')
		elif n[i] == '2':
			a.append('0')
			b.append('2')
	print(''.join(a))
	print(''.join(b))


from functools import reduce
import operator
import itertools
from bisect import bisect_left
t = int(input())

def solve():
	l = int(input())
	n = list(map(int, input()))
	ho = False
	(f, s) = ([0] * l, [0] * l)
	f[0] = s[0] = 1
	for (i, v) in enumerate(n):
		if v != 1:
			f[i] = s[i] = v // 2
		else:
			f[i] = 1
			s[i + 1:] = n[i + 1:]
			break
	print(''.join(map(str, f)))
	print(''.join(map(str, s)))
for i in range(t):
	solve()


n = int(input())
clist = []
for i in range(n):
	alist = []
	blist = []
	l = int(input())
	word = str(input())
	if word.count('1') != 0:
		num = word.index('1')
		for i in range(num):
			if word[i] == '2':
				alist.append('1')
				blist.append('1')
			elif word[i] == '0':
				alist.append('0')
				blist.append('0')
		alist.append('1')
		blist.append('0')
		for i in range(num + 1, l):
			if word[i] == '2':
				alist.append('0')
				blist.append('2')
			elif word[i] == '0':
				alist.append('0')
				blist.append('0')
			elif word[i] == '1':
				alist.append('0')
				blist.append('1')
		a = ''.join(alist)
		b = ''.join(blist)
		clist.append(a)
		clist.append(b)
	else:
		for i in range(l):
			if word[i] == '2':
				alist.append('1')
				blist.append('1')
			elif word[i] == '0':
				alist.append('0')
				blist.append('0')
		a = ''.join(alist)
		b = ''.join(blist)
		clist.append(a)
		clist.append(b)
for i in clist:
	print(i)


import sys
t = int(sys.stdin.readline())
for i in range(t):
	nombre = int(sys.stdin.readline())
	n = int(sys.stdin.readline())
	n = str(n)
	a1 = '1'
	a2 = '1'
	maxi = False
	for c in range(1, nombre):
		if n[c] == '2' and (not maxi):
			a1 += '1'
			a2 += '1'
		elif n[c] == '2' and maxi:
			a1 += '0'
			a2 += '2'
		elif n[c] == '0':
			a1 += '0'
			a2 += '0'
		elif n[c] == '1' and (not maxi):
			maxi = True
			a1 += '1'
			a2 += '0'
		else:
			a1 += '0'
			a2 += '1'
	print(a1)
	print(a2)


def func(n, x):
	maxn = ''
	minn = ''
	count = 0
	for i in range(n):
		elem = x[i]
		if i == 0:
			if elem == '2':
				maxn += '1'
				minn += '1'
			elif elem == '0':
				maxn += '2'
				minn += '1'
		elif elem == '2':
			if maxn + '0' >= minn + '2':
				maxn += '0'
				minn += '2'
			else:
				maxn += '1'
				minn += '1'
		elif elem == '1':
			if maxn + '0' >= minn + '1':
				maxn += '0'
				minn += '1'
			else:
				maxn += '1'
				minn += '0'
		elif maxn + '0' >= minn + '0':
			maxn += '0'
			minn += '0'
		elif maxn + '1' >= minn + '2':
			maxn += '1'
			minn += '2'
		else:
			maxn += '2'
			minn += '1'
		count += 1
	print(maxn)
	print(minn)
t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	func(n, x)


t = int(input())
while t:
	n = int(input())
	s = input()
	(ans_1, ans_2) = ('', '')
	if s.find('1') != -1:
		flag = True
		for i in s:
			if i == '2' and flag:
				ans_1 += '1'
				ans_2 += '1'
			elif i == '1' and flag:
				ans_1 += '0'
				ans_2 += '1'
				flag = False
			elif i == '1' and (not flag):
				ans_1 += '1'
				ans_2 += '0'
			elif i == '2' and (not flag):
				ans_1 += '2'
				ans_2 += '0'
			elif i == '0':
				ans_1 += '0'
				ans_2 += '0'
	else:
		for i in s:
			if i == '2':
				ans_1 += '1'
				ans_2 += '1'
			elif i == '0':
				ans_1 += '0'
				ans_2 += '0'
	t -= 1
	print(ans_1, ans_2, sep='\n')


t = int(input())
while t > 0:
	x = int(input())
	n = int(input())
	l = [int(i) for i in str(n)]
	a = [0] * x
	b = [0] * x
	i = 0
	if l[0] == 1:
		a[0] += 2
		b[0] += 2
		i = 1
	while i < x and l[i] != 1:
		a[i] += l[i] // 2
		b[i] += l[i] // 2
		i += 1
	if i < x:
		a[i] += l[i]
		i += 1
	while i < x:
		b[i] += l[i]
		i += 1
	for j in range(len(a)):
		print(a[j], end='')
	print()
	for j in range(len(a)):
		print(b[j], end='')
	print()
	t -= 1


def generate_ternary_nums(x, a='1', b='1'):
	if x.count('1'):
		one = x.index('1')
	else:
		one = len(x)
	for i in range(1, one):
		if x[i] == '0':
			a += '0'
			b += '0'
		elif x[i] == '1':
			a += '0'
			b += '1'
		else:
			a += '1'
			b += '1'
	if len(a) != len(x):
		b += '1'
		a += '0'
		b += '0' * (len(x) - len(b))
		a += x[len(a):]
	return (a, b)
for _ in range(int(input())):
	input()
	x = input()
	print('\n'.join(generate_ternary_nums(x)))


t = int(input())
while t:
	t -= 1
	n = int(input())
	s = input()
	(a, b) = ('', '')
	found = False
	for x in s:
		if x == '2':
			if found:
				a += '2'
				b += '0'
			else:
				a += '1'
				b += '1'
		elif x == '1':
			if found:
				a += '1'
				b += '0'
			else:
				a += '0'
				b += '1'
				found = True
		elif x == '0':
			a += '0'
			b += '0'
	print(a)
	print(b)


for _ in range(int(input())):
	n = int(input())
	x = list(map(int, list(input())))
	decided = False
	a = []
	b = []
	smaller = None
	bigger = None
	for num in x:
		if num == 2:
			if decided:
				smaller.append(2)
				bigger.append(0)
			else:
				a.append(1)
				b.append(1)
		elif num == 1:
			if decided:
				smaller.append(1)
				bigger.append(0)
			else:
				a.append(0)
				b.append(1)
				smaller = a
				bigger = b
				decided = True
		elif num == 0:
			a.append(0)
			b.append(0)
	for i in a:
		print(i, end='')
	print()
	for i in b:
		print(i, end='')
	print()


for _ in range(int(input())):
	(x, string) = (int(input()), input())
	a = b = ''
	for i in range(x):
		if string[i] == '1':
			a += '1' + '0' * (x - i - 1)
			b += '0' + string[i + 1:]
			break
		else:
			a += str(int(string[i]) // 2)
			b += str(int(string[i]) // 2)
	print(a, b, sep='\n')


t = int(input())
for i in range(0, t):
	n = int(input())
	x = input()
	a = ''
	b = ''
	count = 0
	for k in range(0, n):
		if x[k] == '0':
			a = a + '0'
			b = b + '0'
		if x[k] == '1':
			if count == 0:
				a = a + '1'
				b = b + '0'
				count = count + 1
			else:
				a = a + '0'
				b = b + '1'
		if x[k] == '2':
			if count == 0:
				a = a + '1'
				b = b + '1'
			else:
				a = a + '0'
				b = b + '2'
	print(int(a))
	print(int(b))


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)

def in_int():
	return int(input())

def in_list():
	return list(map(int, input().split()))

def in_str():
	s = input()
	return list(s[:len(s) - 1])

def in_ints():
	return map(int, input().split())
import math
q = in_int()
for qq in range(q):
	n = in_int()
	a = in_str()
	ok = True
	ans1 = ''
	ans2 = ''
	for aa in a:
		if ok:
			if aa == '2':
				ans1 += '1'
				ans2 += '1'
			if aa == '0':
				ans1 += '0'
				ans2 += '0'
			if aa == '1':
				ans1 += '1'
				ans2 += '0'
				ok = False
		else:
			ans1 += '0'
			ans2 += aa
	print(ans1)
	print(ans2)


t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	x = list(x)
	a = []
	b = []
	count = 0
	for i in x:
		if i == '0':
			a.append(i)
			b.append(i)
		elif i == '2' and count == 0:
			a.append('1')
			b.append('1')
		elif i == '2' and count > 0:
			a.append('0')
			b.append('2')
		elif i == '1':
			count = count + 1
			if count == 1:
				a.append(i)
				b.append('0')
			else:
				a.append('0')
				b.append(i)
	print(''.join(a))
	print(''.join(b))


import math

def solve():
	n = int(input())
	c = input()
	s1 = ''
	s2 = ''
	flag = 0
	for i in c:
		if i == '0':
			s1 += '0'
			s2 += '0'
		elif i == '1':
			if flag == 0:
				s1 += '1'
				s2 += '0'
				flag = 1
			else:
				s1 += '0'
				s2 += '1'
		elif i == '2':
			if flag == 0:
				s1 += '1'
				s2 += '1'
			else:
				s1 += '0'
				s2 += '2'
	s1 = s1.lstrip('0')
	s2 = s2.lstrip('0')
	print(int(s1))
	print(int(s2))
for _ in range(int(input())):
	solve()


res = []
for _ in range(int(input())):
	input()
	s = list(map(int, input()))
	(a, b) = ('', '')
	flag = False
	for x in s:
		if x == 0:
			a += '0'
			b += '0'
		elif x == 2:
			if flag:
				a += '0'
				b += '2'
			else:
				a += '1'
				b += '1'
		elif flag:
			a += '0'
			b += '1'
		else:
			a += '1'
			b += '0'
			flag = True
	res.append((a, b))
for (a, b) in res:
	print(a)
	print(b)


t = int(input())
while t > 0:
	t = t - 1
	a = ''
	b = ''
	n = int(input())
	k = input()
	a += '1'
	b += '1'
	f = 0
	for i in range(1, n):
		if f == 0:
			if k[i] == '0':
				a += '0'
				b += '0'
			elif k[i] == '2':
				a += '1'
				b += '1'
			else:
				a += '1'
				b += '0'
				f = 1
		elif k[i] == '0':
			a += '0'
			b += '0'
		elif k[i] == '2':
			a += '0'
			b += '2'
		else:
			a += '0'
			b += '1'
	print(a)
	print(b)


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	a = [''] * n
	b = [''] * n
	fst = False
	for (i, num) in enumerate(x):
		if num == '2':
			if fst:
				a[i] = '0'
				b[i] = '2'
			else:
				a[i] = b[i] = '1'
		elif num == '0':
			a[i] = b[i] = '0'
		elif fst:
			a[i] = '0'
			b[i] = '1'
		else:
			a[i] = '1'
			b[i] = '0'
			fst = True
	print(''.join(a))
	print(''.join(b))


def f(n, x):
	a = ''
	b = ''
	for i in range(n):
		if x[i] == '2':
			a += '1'
			b += '1'
		elif x[i] == '0':
			a += '0'
			b += '0'
		elif x[i] == '1':
			a += '1'
			a += '0' * (n - len(a))
			b += '0' + x[i + 1:]
			break
	print(a)
	return b

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		x = input()
		print(f(n, x))
main()


for _ in range(int(input())):
	n = int(input())
	s = input()
	(ans1, ans2) = ('', '')
	for i in range(n):
		if s[i] == '1':
			ans1 += '1'
			ans2 += '0'
			for j in range(i + 1, n):
				ans1 += '0'
				ans2 += s[j]
			break
		elif s[i] == '0':
			ans1 += '0'
			ans2 += '0'
		elif s[i] == '2':
			ans1 += '1'
			ans2 += '1'
	print(ans1)
	print(ans2)


t = int(input())
for i in range(t):
	x = int(input())
	n = input()
	k = True
	a = ''
	b = ''
	for c in n:
		if int(c) % 3 == 0:
			a += '0'
			b += '0'
		elif int(c) % 3 == 1:
			if k:
				a += '1'
				b += '0'
				k = False
			else:
				a += '0'
				b += '1'
		elif k:
			a += '1'
			b += '1'
		else:
			a += '0'
			b += '2'
	print(a)
	print(b)


t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	r1 = '1'
	r2 = '1'
	fl = False
	for q in range(1, len(x)):
		if x[q] == '2' and (not fl):
			r1 += '1'
			r2 += '1'
		elif x[q] == '2':
			r1 += '0'
			r2 += '2'
		if x[q] == '0':
			r1 += '0'
			r2 += '0'
		if x[q] == '1' and (not fl):
			r1 += '1'
			r2 += '0'
			fl = True
		elif x[q] == '1':
			r1 += '0'
			r2 += '1'
	print(r1)
	print(r2)


def linput():
	return [int(i) for i in input().split()]
q = int(input())
for ______ in range(q):
	n = int(input())
	k = input()
	(a, b) = ('', '')
	i = 0
	while i < n and k[i] != '1':
		a = a + str(int(k[i]) // 2)
		i += 1
	if i == n:
		print(a)
		print(a)
	else:
		print(a + '1' + '0' * (n - i - 1))
		if i + 1 < n:
			print(a + '0' + k[i + 1:])
		else:
			print(a + '0')


t = int(input())
for g in range(t):
	n = int(input())
	first = []
	second = []
	was = False
	for i in list(input()):
		if i == '2':
			if not was:
				first.append('1')
				second.append('1')
			else:
				first.append('0')
				second.append('2')
		elif i == '1':
			if not was:
				first.append('1')
				second.append('0')
				was = True
			else:
				first.append('0')
				second.append('1')
		elif i == '0':
			first.append('0')
			second.append('0')
	print(''.join(first))
	print(''.join(second))


for _ in range(int(input())):
	n = int(input())
	lis = input()
	s1 = []
	s2 = []
	diff = 0
	for i in lis:
		if diff == 0:
			if i == '2':
				s1.append(1)
				s2.append(1)
			elif i == '0':
				s1.append(0)
				s2.append(0)
			else:
				s1.append(1)
				s2.append(0)
				diff = 1
		else:
			s1.append(0)
			s2.append(i)
	for i in range(len(s1)):
		print(s1[i], end='')
	print()
	for i in range(len(s1)):
		print(s2[i], end='')
	print()


t = int(input())
while t != 0:
	length = int(input())
	n = input()
	list1 = list()
	list2 = list()
	maxi = -1
	for i in range(length):
		if n[i] == '2':
			if maxi != -1:
				if maxi == 1:
					list2.append(2)
					list1.append(0)
				else:
					list1.append(2)
					list2.append(0)
			else:
				list1.append(1)
				list2.append(1)
		elif n[i] == '1':
			if maxi != -1:
				if maxi == 1:
					list2.append(1)
					list1.append(0)
				else:
					list1.append(1)
					list2.append(0)
			else:
				list1.append(1)
				list2.append(0)
				maxi = 1
		elif n[i] == '0':
			list1.append(0)
			list2.append(0)
	for i in range(len(list2)):
		print(list2[i], end='')
	print()
	for i in range(len(list1)):
		print(list1[i], end='')
	print()
	t -= 1


import math
t = int(input())
for _i in range(t):
	n = int(input())
	str = input()
	s1 = ''
	s2 = ''
	flag1 = False
	for i in range(1, n):
		if str[i] == '1':
			khuti1 = i
			flag1 = True
			break
	if flag1 == True:
		s1 += '1'
		s2 += '1'
		for i in range(1, khuti1 + 1):
			if str[i] == '2':
				s1 += '1'
				s2 += '1'
			elif str[i] == '1':
				s1 += '1'
				s2 += '0'
			else:
				s1 += '0'
				s2 += '0'
		for j in range(khuti1 + 1, n):
			s1 += '0'
			s2 += str[j]
	else:
		for i in range(n):
			if str[i] == '2':
				s1 += '1'
				s2 += '1'
			elif str[i] == '1':
				s1 += '1'
				s2 += '0'
			else:
				s1 += '0'
				s2 += '0'
	print(s1)
	print(s2)


t = int(input())
while t:
	t -= 1
	n = int(input())
	x = [int(c) for c in input()]
	a = [0] * n
	b = [0] * n
	index = n
	for i in range(0, n):
		if x[i] == 0:
			a[i] = 0
			b[i] = 0
		elif x[i] == 1:
			a[i] = 1
			b[i] = 0
			index = i
			break
		else:
			a[i] = 1
			b[i] = 1
	for i in range(index + 1, n):
		b[i] = x[i]
	print(''.join([str(c) for c in a]))
	print(''.join([str(c) for c in b]))


from math import factorial
from collections import Counter, defaultdict
from heapq import heapify, heappop, heappush
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 1000000007
INF = float('inf')

def main():
	for _ in range(N()):
		n = N()
		s = input()
		a = [1]
		b = [1]
		na = nb = 0
		for i in range(1, len(s)):
			if s[i] == '0':
				a.append(0)
				b.append(0)
			elif s[i] == '1':
				if na == nb:
					a.append(1)
					na += 1
					b.append(0)
				else:
					a.append(0)
					b.append(1)
			elif s[i] == '2':
				if na == nb:
					a.append(1)
					b.append(1)
				else:
					a.append(0)
					b.append(2)
		print(''.join([str(i) for i in a]))
		print(''.join([str(i) for i in b]))
main()


for i in range(int(input())):
	n = int(input())
	nummax = ''
	nummin = ''
	tr = False
	lst = list(input())
	for i in lst:
		if i == '2':
			if tr:
				nummax += '0'
				nummin += '2'
			else:
				nummin += '1'
				nummax += '1'
		elif i == '1':
			if tr:
				nummax += '0'
				nummin += '1'
			else:
				nummax += '1'
				nummin += '0'
				tr = True
		else:
			nummin += '0'
			nummax += '0'
	print(nummax)
	print(nummin)


for i in range(int(input())):
	N = [int(i) for i in input().split(' ')]
	K = input()
	a = '1'
	b = '1'
	flag = 0
	for i in range(1, len(K)):
		if K[i] == '0':
			a += '0'
			b += '0'
		elif K[i] == '1':
			if flag == 0:
				a += '1'
				b += '0'
				flag = 1
			else:
				a += '0'
				b += '1'
		elif flag == 0:
			a += '1'
			b += '1'
		else:
			a += '0'
			b += '2'
	print(a)
	print(b)


t = int(input())
for testcase in range(t):
	n = int(input())
	s = input()
	a = ''
	b = ''
	T = False
	for i in range(len(s)):
		if T:
			if s[i] == '2':
				a = a + '0'
				b = b + '2'
			if s[i] == '0':
				a = a + '0'
				b = b + '0'
			if s[i] == '1':
				a = a + '0'
				b = b + '1'
		else:
			if s[i] == '2':
				a = a + '1'
				b = b + '1'
			if s[i] == '0':
				a = a + '0'
				b = b + '0'
			if s[i] == '1':
				a = a + '1'
				b = b + '0'
				T = True
	print(a)
	print(b)


T = int(input())
for _ in range(T):
	n = int(input())
	x = input()
	(a, b) = ('', '')
	flag = 0
	for i in x:
		if i == '2':
			if flag == 0:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
		elif i == '0':
			a += '0'
			b += '0'
		elif flag == 0:
			a += '1'
			b += '0'
			flag = 1
		else:
			a += '0'
			b += '1'
	print(a)
	print(b)


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, list(input())))
	a = '1'
	b = '1'
	ind = -1
	try:
		ind = s.index(1)
	except:
		pass
	if ind == -1 or ind == n - 1:
		f = {0: '0', 2: '1', 1: '0'}
		print(*[f[i] for i in s], sep='')
		f = {0: '0', 2: '1', 1: '1'}
		print(*[f[i] for i in s], sep='')
	else:
		f = {0: '0', 2: '1'}
		a = [f[i] for i in s[:ind]]
		b = [f[i] for i in s[:ind]]
		a = a + [1]
		b = b + [0]
		a += [0 for i in range(n - ind - 1)]
		b += [s[i] for i in range(ind + 1, n)]
		print(*a, sep='')
		print(*b, sep='')


for _ in range(int(input())):
	n = int(input())
	x = input()
	a = []
	b = []
	d = 0
	for i in x:
		if i == '2':
			if d == 0:
				a.append('1')
				b.append('1')
			else:
				a.append('0')
				b.append('2')
		elif i == '1':
			if d == 0:
				a.append('1')
				b.append('0')
				d = 1
			else:
				a.append('0')
				b.append('1')
		else:
			a.append('0')
			b.append('0')
	print(''.join(a))
	print(''.join(b))


def solve():
	for _ in range(ii()):
		n = ii()
		s = si()
		a = ''
		b = ''
		found = False
		for i in s:
			if i == '1' and (not found):
				a += '1'
				b += '0'
				found = True
				continue
			if found:
				a += '0'
				b += i
			elif i == '0':
				a += '0'
				b += '0'
			elif i == '2':
				a += '1'
				b += '1'
		print(a)
		print(b)
ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(mi())
si = lambda : input()
solve()


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
M = mod = 998244353

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
for _ in range(val()):
	n = val()
	l = li3()
	l1 = []
	l2 = []
	chosen = 1
	ind = 0
	while chosen and ind < n:
		if l[ind] != 1:
			l1.append(l[ind] // 2)
			l2.append(l[ind] // 2)
		else:
			l1.append(1)
			l2.append(0)
			chosen = 0
		ind += 1
	l1 += [0] * n
	if not chosen:
		for i in range(ind, n):
			l2.append(l[i])
	print(*l1[:n], sep='')
	print(*l2, sep='')


n = int(input())
for a in range(n):
	input()
	s = input()
	highest = False
	one = ''
	two = ''
	for num in s:
		if num == '2':
			if highest == False:
				one += '1'
				two += '1'
			else:
				one += '0'
				two += '2'
		elif num == '1':
			if highest == False:
				one += '1'
				two += '0'
				highest = True
			else:
				one += '0'
				two += '1'
		elif num == '0':
			one += '0'
			two += '0'
	print(one)
	print(two)


t = int(input())
while t > 0:
	n = int(input())
	x = input()
	a = []
	b = []
	eq = False
	i = 0
	while i < len(x):
		if i == 0:
			a.append(1)
			b.append(1)
			eq = True
		elif x[i] == '2' and eq == True:
			a.append(1)
			b.append(1)
		elif x[i] == '2':
			a.append(0)
			b.append(2)
		elif x[i] == '0':
			a.append(0)
			b.append(0)
		else:
			if eq == True:
				a.append(1)
				b.append(0)
			else:
				a.append(0)
				b.append(1)
			eq = False
		i += 1
	i = 0
	while i < len(a):
		print(a[i], end='')
		i += 1
	print()
	i = 0
	while i < len(b):
		print(b[i], end='')
		i += 1
	print()
	t -= 1


for run in range(0, int(input())):
	length = int(input())
	goal = input()[1:]
	num1 = 1
	num2 = 1
	if '1' in goal:
		ind = goal.index('1')
		before = goal[:ind]
		after = goal[ind + 1:]
		if before != '':
			toA = ''
			for i in before:
				toA += str(round(int(i) / 2))
			num1 = '1' + toA
			num2 = '1' + toA
		num1 = int(str(num1) + '1')
		num2 = int(str(num2) + '0')
		if after != '':
			num2 = int(str(num2) + after)
			num1 = int(str(num1) + '0' * len(after))
	elif goal != '':
		add = ''
		for i in goal:
			add += str(round(int(i) / 2))
		num1 = int('1' + add)
		num2 = int('1' + add)
	print(num1)
	print(num2)


def swap(a, b):
	return (b, a)
t = int(input())
while t:
	t -= 1
	n = int(input())
	num = input()
	st1 = ''
	st2 = ''
	found = False
	for i in range(n):
		if found:
			st2 = st2 + num[i]
			st1 = st1 + '0'
		elif num[i] == '1':
			found = True
			st1 = st1 + '1'
			st2 = st2 + '0'
		elif num[i] == '2':
			st1 = st1 + '1'
			st2 = st2 + '1'
		else:
			st1 = st1 + '0'
			st2 = st2 + '0'
	print(st1)
	print(st2)


t = int(input())
while t > 0:
	n = int(input())
	string = input()
	i = 1
	p = 0
	s1 = ''
	s2 = ''
	s1 = s1 + '1'
	s2 = s2 + '1'
	while i < n:
		if p == 0:
			if string[i] == '0':
				s1 = s1 + '0'
				s2 = s2 + '0'
			elif string[i] == '1':
				s1 = s1 + '1'
				s2 = s2 + '0'
				p = 1
			elif string[i] == '2':
				s1 = s1 + '1'
				s2 = s2 + '1'
		else:
			s1 = s1 + '0'
			s2 = s2 + string[i]
		i = i + 1
	print(s1)
	print(s2)
	t = t - 1


t = int(input())
for _ in range(t):
	n = int(input())
	num = input()
	a = []
	b = []
	biggest = 'None'
	for i in range(n):
		if num[i] == '2' and biggest == 'None':
			a.append('1')
			b.append('1')
		elif num[i] == '2' and biggest == 'a':
			a.append('0')
			b.append('2')
		elif num[i] == '1' and biggest == 'None':
			a.append('1')
			b.append('0')
			biggest = 'a'
		elif num[i] == '1' and biggest == 'a':
			a.append('0')
			b.append('1')
		else:
			a.append('0')
			b.append('0')
	print(''.join(a))
	print(''.join(b))


T = int(input())
for _ in range(T):
	n = int(input())
	s = list(input())
	a = []
	b = []
	flag = 1
	for i in s:
		i = int(i)
		if i % 2 == 0:
			if flag:
				a.append(i // 2)
				b.append(i // 2)
			else:
				a.append(0)
				b.append(i)
		elif flag:
			a.append(1)
			b.append(0)
			flag = 0
		else:
			a.append(0)
			b.append(1)
	print(*a, sep='')
	print(*b, sep='')


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	a = ''
	b = ''
	check = False
	for i in range(n):
		if s[i] == '0':
			a += '0'
			b += '0'
		elif s[i] == '1':
			if check == False:
				a += '1'
				b += '0'
				check = True
			else:
				a += '0'
				b += '1'
		elif s[i] == '2':
			if check == False:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
	print(a)
	print(b)


import math
import sys, collections
from sys import stdin, stdout

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()

def input():
	return sys.stdin.readline().strip()

def file():
	sys.stdin = open('input.py', 'r')
	sys.stdout = open('output.py', 'w')

def is_subsequence(x, y):
	x = list(x)
	for letter in y:
		if x and x[0] == letter:
			x.pop(0)
	return not x

def sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, mt.ceil(mt.sqrt(MAXN))):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def getFactorization(x):
	ret = list()
	while x != 1:
		ret.append(spf[x])
		x = x // spf[x]
	return ret

def getFloor(A, x):
	(left, right) = (0, len(A) - 1)
	(ind, floor) = (-1, -1)
	while left <= right:
		mid = (left + right) // 2
		if x < A[mid]:
			right = mid - 1
		else:
			floor = A[mid]
			ind = mid
			left = mid + 1
	return ind

def check(st):
	n = len(st)
	digitSum = 0
	for i in range(0, n):
		digitSum = digitSum + int(st[i])
	return digitSum % 9 == 0

def isPowerOfTwo(n):
	if n == 0:
		return False
	while n != 1:
		if n % 2 != 0:
			return False
		n = n // 2
	return True

def kitte(n):
	c = 0
	while n != 0:
		n = n // 2
		c += 1
	return c

def aa(b, c):
	m = min(b, c)
	b -= m
	c -= m
	if c > 0 and b > 0:
		return m + (b + c) // 3
	else:
		return m

def bb(a, c):
	m = min(a, c)
	a -= m
	c -= m
	if c > 0 and a > 0:
		return m + (a + c) // 3
	else:
		return m

def cc(b, a):
	m = min(b, a)
	b -= m
	a -= m
	if a > 0 and b > 0:
		return m + (b + a) // 3
	else:
		return m

def findProductSum(A, n):
	array_sum = 0
	for i in range(0, n, 1):
		array_sum = array_sum + A[i]
	array_sum_square = array_sum * array_sum
	individual_square_sum = 0
	for i in range(0, n, 1):
		individual_square_sum += A[i] * A[i]
	return (array_sum_square - individual_square_sum) // 2

def transpose(a):
	b = a[:][:]
	N = len(a)
	for i in range(N):
		for j in range(N):
			b[i][j] = a[j][i]
	return b

def assign_rank_based_on_scores(a):
	final = []
	for ii in a:
		temp = ii[:]
		l = [1]
		temp.sort(reverse=True)
		for j in range(1, len(temp)):
			if temp[j] == temp[j - 1]:
				l.append(l[-1])
			else:
				l.append(j + 1)
		d = collections.defaultdict(int)
		j = 0
		for i in temp:
			d[i] = l[j]
			j += 1
		ans = []
		for j in ii:
			ans.append(d[j])
		final.append(ans)
	return final
mod = 10 ** 9 + 7

def main():
	n = int(input())
	s = input()
	a = ['1']
	b = ['1']
	flag = 0
	for i in range(1, n):
		if s[i] == '0':
			a.append('0')
			b.append('0')
		elif flag == 1 and s[i] == '1':
			a.append('1')
			b.append('0')
		elif flag == 0 and s[i] == '1':
			a.append('0')
			b.append('1')
			flag = 1
		elif flag == 0 and s[i] == '2':
			a.append('1')
			b.append('1')
		elif flag == 1 and s[i] == '2':
			a.append('2')
			b.append('0')
	print(''.join(a))
	print(''.join(b))
for tt in range(int(input())):
	main()


a = int(input())
for i in range(a):
	ta = int(input())
	s = input()
	z = []
	for i in range(len(s)):
		z.append(int(s[i]))
	ans = []
	tam = []
	flag = 0
	for i in range(len(z)):
		if z[i] == 2 and flag == 0:
			ans.append(1)
			tam.append(1)
		if z[i] == 0 and flag == 0:
			ans.append(0)
			tam.append(0)
		if z[i] == 1 and flag == 0:
			ans.append(1)
			tam.append(0)
			flag = 1
			continue
		if flag == 1:
			ans.append(0)
			if z[i] == 0:
				tam.append(0)
			if z[i] == 1:
				tam.append(1)
			if z[i] == 2:
				tam.append(2)
	print(''.join(map(str, ans)))
	print(''.join(map(str, tam)))


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = []
	b = []
	ternary = input().rstrip()
	initialized = False
	for ch in ternary:
		if not initialized:
			if ch == '2':
				a.append('1')
				b.append('1')
			elif ch == '0':
				a.append('0')
				b.append('0')
			else:
				initialized = True
				a.append('1')
				b.append('0')
		else:
			a.append('0')
			b.append(ch)
	print(''.join([item for item in a]))
	print(''.join([item for item in b]))


t = int(input())
for _ in range(t):
	n = int(input())
	x = list(input())
	a = ''
	b = ''
	for i in range(n):
		if x[i] == '0':
			a = a + '0'
			b = b + '0'
			continue
		if x[i] == '1':
			if a >= b:
				a = a + '0'
				b = b + '1'
			else:
				a = a + '1'
				b = b + '0'
		if x[i] == '2':
			if a == b:
				a = a + '1'
				b = b + '1'
			elif a > b:
				a = a + '0'
				b = b + '2'
			else:
				a = a + '2'
				b = b + '0'
	print(a)
	print(b)


test = int(input())
for _ in range(test):
	n = int(input())
	x = input()
	a = ''
	b = ''
	for (i, c) in enumerate(x):
		if c == '1':
			a = a + '1' + '0' * (n - i - 1)
			b = b + '0' + x[i + 1:]
			break
		elif c == '0':
			a = a + '0'
			b = b + '0'
		else:
			a = a + '1'
			b = b + '1'
	print(a)
	print(b)


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	flag = False
	a = '1'
	b = '1'
	for x_ in x[1:]:
		if x_ == '1':
			if not flag:
				a += x_
				b += '0'
				flag = True
			else:
				a += '0'
				b += x_
		elif not flag:
			if x_ == '2':
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '0'
		else:
			a += '0'
			b += x_
	print(f'{a}\n{b}')


from sys import stdin

def func():
	return
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	s = stdin.readline().strip()
	m = '1'
	k = '1'
	f = 0
	for i in range(1, n):
		if s[i] == '1':
			if f == 0:
				m += '1'
				k += '0'
				f = 2
			elif f == 1:
				m += '1'
				k += '0'
			else:
				m += '0'
				k += '1'
		elif s[i] == '0':
			m += '0'
			k += '0'
		elif f == 0:
			m += '1'
			k += '1'
		elif f == 1:
			m += '2'
			k += '0'
		else:
			m += '0'
			k += '2'
	print(m)
	print(k)


t = int(input())
for zz in range(t):
	n = int(input())
	x = int(input())
	a = ''
	b = ''
	s = str(x)
	flag = 0
	for i in range(len(s)):
		if flag == 1:
			a += s[i]
			b += '0'
		elif flag == 0 and s[i] == '2':
			a += '1'
			b += '1'
		elif flag == 0 and s[i] == '1':
			a += '0'
			b += '1'
			flag = 1
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


for i in range(int(input())):
	n = int(input())
	x = int(input())
	a = x // 2
	b = x - a
	a = str(a)
	b = str(b)
	pos = 0
	if a.count('0') + a.count('1') + a.count('2') == n and b.count('0') + b.count('1') + b.count('2') == n:
		print(a)
		print(b)
	else:
		for i in range(n):
			if int(a[i]) > 2:
				pos = i - 1
				break
		m = list(a)
		for i in range(n):
			m[i] = int(m[i])
			if i == pos:
				m[i] = m[i] + 1
			if i > pos:
				m[i] = 0
		ans1 = ''
		for i in range(n):
			ans1 += str(m[i])
		ans1 = int(ans1)
		ans2 = x - ans1
		print(ans1)
		print(ans2)


from sys import stdin, stdout
t = int(input())
for i in range(t):
	n = int(input())
	s = stdin.readline().rstrip('\n')
	a = ''
	b = ''
	c = 0
	d = 0
	for i in s:
		if i == '2':
			if d == 0:
				a = a + '1'
				b = b + '1'
				d += 1
			elif c == 0:
				a = a + '1'
				b = b + '1'
			else:
				a = a + '0'
				b = b + '2'
		elif i == '1':
			if c == 0:
				a = a + '1'
				b = b + '0'
				c += 1
			else:
				a = a + '0'
				b = b + '1'
		else:
			a = a + '0'
			b = b + '0'
	stdout.write(a + '\n')
	stdout.write(b + '\n')


from math import ceil
for _ in range(int(input())):
	n = int(input())
	a = input()
	b = ['', '']
	fl = 0
	for i in a:
		if fl:
			if i == '2':
				b[0] += '0'
				b[1] += '2'
			elif i == '0':
				b[0] += '0'
				b[1] += '0'
			else:
				b[0] += '0'
				b[1] += '1'
		elif i == '2':
			b[0] += '1'
			b[1] += '1'
		elif i == '0':
			b[0] += '0'
			b[1] += '0'
		else:
			b[0] += '1'
			b[1] += '0'
			fl = 1
	print(''.join(b[0]))
	print(''.join(b[1]))


for _ in range(int(input())):
	n = input()
	num = input()
	a = b = ''
	key = False
	for i in num:
		if i == '2':
			if key == False:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
		elif i == '1':
			if key == False:
				a += '1'
				b += '0'
			else:
				a += '0'
				b += '1'
			key = True
		else:
			a += '0'
			b += '0'
	print(a, b, sep='\n')


for _ in range(int(input())):
	n = int(input())
	s = list(input().strip())
	a = []
	b = []
	flag = 0
	for i in s:
		if flag == 0 and i == '1':
			flag = 1
			a.append(1)
			b.append(0)
		elif flag == 1 and i == '1':
			a.append(0)
			b.append(1)
		elif flag == 0 and i == '2':
			a.append(1)
			b.append(1)
		elif flag == 1 and i == '2':
			a.append(0)
			b.append(2)
		elif i == '0':
			a.append(0)
			b.append(0)
	print(*a, sep='')
	print(*b, sep='')


from sys import stdin, stdout
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	x = stdin.readline()
	a = ''
	b = ''
	d = 0
	for i in range(n):
		if d != 1:
			if x[i] == '1':
				a = a + '0'
				b = b + '1'
				d = 1
			if x[i] == '2':
				a = a + '1'
				b = b + '1'
			if x[i] == '0':
				a = a + '0'
				b = b + '0'
		else:
			a = a + x[i]
			b = b + '0'
	print(a)
	print(b)


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	x = sys.stdin.readline()
	num1 = ''
	for i in range(n):
		if x[i] == '1':
			num1 = int(x[:i + 1]) // 2
			num1 += 1
			num1 = int(str(num1) + '0' * (n - i - 1))
			break
		elif i == n - 1 and x[i] != '1':
			num1 = int(x) // 2
	print(num1)
	print(int(x) - num1)


I = input
pr = print

def main():
	for _ in range(int(I())):
		n = int(I())
		m = I()
		a = []
		b = []
		f = 0
		for i in m:
			if f:
				a.append('0')
				b.append(i)
			elif i == '2':
				a.append('1')
				b.append('1')
			elif i == '1' and (not f):
				a.append('1')
				b.append('0')
				f = 1
			elif i == '0':
				a.append('0')
				b.append('0')
		pr(''.join(a), ''.join(b), sep='\n')
main()


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	a = ''
	b = ''
	bigger = False
	for c in x:
		if not bigger:
			if c == '0':
				b += '0'
				a += '0'
			elif c == '1':
				b += '1'
				a += '0'
				bigger = True
			else:
				b += '1'
				a += '1'
		elif c == '0':
			a += '0'
			b += '0'
		elif c == '1':
			a += '1'
			b += '0'
		else:
			b += '0'
			a += '2'
	print(b)
	print(a)


def Ternary(n, tri):
	flag = 0
	g = '1'
	s = '1'
	for i in range(1, n):
		if tri[i] == '0':
			g += '0'
			s += '0'
		elif tri[i] == '2':
			if flag < 1:
				g += '1'
				s += '1'
			else:
				g += '0'
				s += '2'
		elif flag < 1:
			g += '1'
			s += '0'
			flag = 1
		else:
			g += '0'
			s += '1'
	return [g, s]
t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	ans = Ternary(n, x)
	for i in ans:
		print(i)


for _ in range(int(input())):
	n = int(input())
	s = input()
	k = ''
	p = ''
	f = 0
	for i in range(n):
		if f == 1:
			p += s[i]
			k += '0'
		elif s[i] == '2':
			k += '1'
			p += '1'
		elif s[i] == '1':
			k += '1'
			p += '0'
			f = 1
		else:
			k += '0'
			p += '0'
	print(p)
	print(k)


def solve():
	n = int(input())
	x = input()
	f1 = -1
	a = ['']
	b = ['']
	for i in x:
		if i == '0':
			a.append('0')
			b.append('0')
		elif i == '1':
			if f1 == -1:
				f1 = 0
			if f1 == 0:
				f1 = 1
				a.append('1')
				b.append('0')
			else:
				a.append('0')
				b.append('1')
		elif f1 == -1:
			a.append('1')
			b.append('1')
		elif f1 == 0:
			a.append('2')
			b.append('0')
		else:
			a.append('0')
			b.append('2')
	for i in a:
		print(i, end='')
	print('')
	for i in b:
		print(i, end='')
	print('')
T = int(input())
for i in range(T):
	solve()


for _ in ' ' * int(input()):
	n = int(input())
	s = input()
	a = list('a' * n)
	b = list(a)
	f = 1
	for i in range(n):
		if f:
			if s[i] == '2':
				a[i] = '1'
				b[i] = '1'
			elif s[i] == '0':
				a[i] = '0'
				b[i] = '0'
			else:
				a[i] = '1'
				b[i] = '0'
				f = 0
		else:
			a[i] = '0'
			b[i] = s[i]
	print(''.join(a))
	print(''.join(b))


for t in range(int(input())):
	n = int(input())
	x = input()
	a = ''
	b = ''
	try:
		one = x.index('1')
		for i in range(n):
			if i < one:
				if x[i] == '2':
					a += '1'
					b += '1'
				else:
					a += '0'
					b += '0'
			elif i == one:
				a += '1'
				b += '0'
			else:
				if x[i] == '2':
					b += '2'
				elif x[i] == '1':
					b += '1'
				else:
					b += '0'
				a += '0'
	except:
		for i in range(n):
			if x[i] == '2':
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '0'
	print(a, '\n' + b)


t = int(input())
for k in range(t):
	n = int(input())
	str = input()
	str1 = '1'
	str2 = '1'
	for i in range(1, n):
		if str1 == str2:
			if str[i] == '1':
				str1 += '1'
				str2 += '0'
			elif str[i] == '2':
				str1 += '1'
				str2 += '1'
			else:
				str1 += '0'
				str2 += '0'
		elif str1 > str2:
			if str[i] == '1':
				str1 += '0'
				str2 += '1'
			elif str[i] == '2':
				str1 += '0'
				str2 += '2'
			else:
				str1 += '0'
				str2 += '0'
	print(str1)
	print(str2)


def main():
	test = int(input())
	for _ in range(test):
		n = int(input())
		num = input()
		ans1 = '1'
		ans2 = '1'
		for index in range(1, n):
			if num[index] == '1':
				ans1 += '1' + '0' * (n - index - 1)
				ans2 += '0' + num[index + 1:]
				break
			elif num[index] == '2':
				ans1 += '1'
				ans2 += '1'
			else:
				ans1 += '0'
				ans2 += '0'
		print(ans1)
		print(ans2)
main()


t = int(input())
for test in range(t):
	n = int(input())
	x = input()
	resa = '1'
	resb = '1'
	flag = False
	for i in range(1, n):
		if flag:
			resa += '0'
			resb += x[i]
		elif x[i] == '1':
			flag = True
			resa += '1'
			resb += '0'
		else:
			resa += str(int(x[i]) // 2)
			resb += str(int(x[i]) // 2)
	print(resa)
	print(resb)


for _ in range(int(input())):
	n = int(input())
	s = input()
	res = ''
	for i in s:
		if i != '1':
			res += str(int(i) // 2)
		else:
			res += i + '0' * (n - len(res) - 1)
			break
	res = int(res)
	res1 = int(s) - res
	print(res)
	print(res1)


import sys
input = sys.stdin.readline
print = sys.stdout.write
for _ in range(int(input())):
	n = int(input())
	s = input()
	a1 = []
	b1 = []
	ct = 0
	for i in s:
		if i == '0':
			a1.append('0')
			b1.append('0')
		if i == '2':
			if ct == 0:
				a1.append('1')
				b1.append('1')
			elif ct == 1:
				a1.append('0')
				b1.append('2')
		if i == '1':
			if ct == 0:
				a1.append('1')
				b1.append('0')
				ct = 1
			elif ct == 1:
				a1.append('0')
				b1.append('1')
		if i == '3':
			if ct == 0:
				a1.append('2')
				b1.append('1')
				ct = 1
			else:
				a1.append('0')
				b1.append('3')
	print(''.join(a1) + '\n')
	print(''.join(b1) + '\n')


t = int(input())
for _ in range(t):
	n = int(input())
	x = int(input())
	x = str(x)
	q1 = ''
	q2 = ''
	flag = 0
	for i in range(n):
		if i == n - 1:
			if flag == 0:
				if x[i] == '2':
					q1 += '1'
					q2 += '1'
				elif x[i] == '0':
					q1 += '0'
					q2 += '0'
				elif x[i] == '1':
					q1 += '0'
					q2 += '1'
			elif x[i] == '2':
				q1 += '2'
				q2 += '0'
			elif x[i] == '0':
				q1 += '0'
				q2 += '0'
			elif x[i] == '1':
				q1 += '1'
				q2 += '0'
		elif x[i] == '2':
			if flag == 0:
				q1 += '1'
				q2 += '1'
			else:
				q1 += '2'
				q2 += '0'
		elif x[i] == '0':
			q1 += '0'
			q2 += '0'
		elif x[i] == '1':
			if flag == 0:
				q1 += '0'
				q2 += '1'
				flag = 1
			else:
				q1 += '1'
				q2 += '0'
	print(int(q2))
	print(int(q1))


t = int(input())
for _ in range(t):
	n = int(input())
	x = int(input())
	xarr = [int(x) for x in str(x)]
	num1 = []
	num2 = []
	n1 = ''
	n2 = ''
	done = False
	for i in range(len(xarr)):
		if done == False:
			if xarr[i] == 2:
				num1.append('1')
				num2.append('1')
			elif xarr[i] == 0:
				num1.append('0')
				num2.append('0')
			else:
				num1.append('1')
				num2.append('0')
				done = True
		else:
			num1.append('0')
			num2.append(str(xarr[i]))
	for i in num1:
		n1 += i
	for i in num2:
		n2 += i
	print(int(n1))
	print(int(n2))


t = int(input())
for xx in range(t):
	input()
	s = input().strip()
	ans1 = ''
	ans2 = ''
	F_1 = False
	first1 = s.find('1')
	if first1 != -1:
		for i in range(first1):
			if s[i] == '2':
				ans1 += '1'
				ans2 += '1'
			else:
				ans1 += '0'
				ans2 += '0'
		ans1 += '1'
		ans2 += '0'
		for i in range(first1 + 1, len(s)):
			if s[i] == '1':
				ans1 += '0'
				ans2 += '1'
			elif s[i] == '2':
				ans1 += '0'
				ans2 += '2'
			else:
				ans1 += '0'
				ans2 += '0'
	else:
		for i in range(len(s)):
			if s[i] == '2':
				ans1 += '1'
				ans2 += '1'
			else:
				ans1 += '0'
				ans2 += '0'
	print(ans1)
	print(ans2)


for _ in range(int(input())):
	n = int(input())
	num = list(map(int, list(input())))
	ans1 = [0] * len(num)
	ans2 = [0] * len(num)
	if 1 in num:
		idx = num.index(1)
		for i in range(idx):
			ans1[i] = num[i] // 2
			ans2[i] = num[i] // 2
		ans1[idx] = 1
		for i in range(idx + 1, n):
			ans2[i] = num[i]
	else:
		for i in range(n):
			ans1[i] = num[i] // 2
			ans2[i] = num[i] // 2
	print(*ans1, sep='')
	print(*ans2, sep='')


t = int(input())
for _ in range(t):
	n = int(input())
	r = list(input())
	a = []
	b = []
	flag = 0
	flag1 = -1
	for i in r:
		if i == '2':
			if flag == 0:
				a.append('1')
				b.append('1')
				flag1 = 0
			else:
				a.append('0')
				b.append('2')
				flag1 = 1
		elif i == '1':
			if flag1 == -1:
				a.append('1')
				b.append('0')
				flag = 1
				flag1 = 1
			elif flag1 == 0:
				a.append('1')
				b.append('0')
				flag1 = 1
				flag = 1
			else:
				a.append('0')
				b.append('1')
				flag = 1
		else:
			a.append('0')
			b.append('0')
	for i in a:
		print(i, end='')
	print()
	for i in b:
		print(i, end='')
	print()


from sys import stdin, stdout
from math import *
input = stdin.readline
a = [1]
x = 2
for i in range(200005):
	a.append(x + a[-1])
	x += 1

def fl(a, n):
	l = 0
	r = len(a)
	ans = -1
	while l <= r:
		m = (l + r) // 2
		if a[m] < n:
			ans = m
			l = m + 1
		else:
			r = m - 1
	return ans
for __ in range(int(input())):
	n = int(input())
	s = input()
	a = '1'
	b = '1'
	temp = 0
	for i in range(1, n):
		if s[i] == '2':
			if temp == 0:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
		elif s[i] == '0':
			a += '0'
			b += '0'
		else:
			if temp == 0:
				a += '1'
				b += '0'
			else:
				a += '0'
				b += '1'
			temp = 1
	print(a)
	print(b)


for _ in range(int(input())):
	num = int(input())
	n = input()
	n = list(n)
	a = ''
	b = ''
	i = 0
	while i < num and (n[i] == '2' or n[i] == '0'):
		if n[i] == '2':
			a += '1'
			b += '1'
		elif n[i] == '0':
			a += '0'
			b += '0'
		i += 1
	if i < num:
		a += '1'
		b += '0'
		for j in range(i + 1, num):
			a += '0'
			b += n[j]
	print(a)
	print(b)


t = int(input())

def test():
	n = int(input())
	s = input()
	t = ['', '']
	index = n
	for i in range(n):
		if s[i] == '1':
			index = i + 1
			break
		if s[i] == '0':
			t[0] += '0'
			t[1] += '0'
		else:
			t[0] += '1'
			t[1] += '1'
	if index != n or s[n - 1] == '1':
		t[0] += '0'
		t[0] += s[index:]
		t[1] += '1'
		t[1] += '0' * (n - index)
	print(t[0])
	print(t[1])
while t:
	test()
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	s = list(input())
	a = []
	b = []
	c = 0
	for i in range(len(s)):
		if s[i] == '0':
			a.append('0')
			b.append('0')
		elif s[i] == '1':
			if c == 0:
				a.append('1')
				b.append('0')
				c = 1
			elif c == 1:
				a.append('0')
				b.append('1')
		elif s[i] == '2':
			if c == 1:
				a.append('0')
				b.append('2')
			elif c == 0:
				a.append('1')
				b.append('1')
	print(''.join(a))
	print(''.join(b))


for t in range(int(input())):
	n = int(input())
	s = input()
	(s1, s2) = ('', '')
	flag = 0
	for i in range(n):
		if flag == 0:
			if s[i] == '2':
				s1 += '1'
				s2 += '1'
			elif s[i] == '0':
				s1 += '0'
				s2 += '0'
			else:
				s1 += '1'
				s2 += '0'
				flag = 1
		else:
			s1 += '0'
			s2 += s[i]
	print(s1)
	print(s2)


for _ in range(int(input())):
	n = int(input())
	number = int(input())
	a = ''
	b = ''
	string = str(number)
	for i in range(n):
		if string[i] == '1':
			b = b + string[i]
			a = a + '0'
			break
		elif string[i] == '2':
			b = b + '1'
			a = a + '1'
		else:
			b = b + '0'
			a = a + '0'
	if i != n - 1:
		b = b + '0' * (n - 1 - i)
		a = a + string[i + 1:]
	print(int(b))
	print(int(a))


from sys import stdin
t = int(input())
for _ in range(t):
	(n,) = map(int, stdin.readline().split())
	c = stdin.readline().strip()
	a = []
	b = []
	zz = False
	for char in c:
		if char == '2':
			if zz == False:
				a.append('1')
				b.append('1')
			if zz == True:
				a.append('0')
				b.append('2')
		elif char == '0':
			a.append('0')
			b.append('0')
		elif zz == False:
			a.append('1')
			b.append('0')
			zz = True
		else:
			a.append('0')
			b.append('1')
	print(''.join(a))
	print(''.join(b))


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	num1 = []
	num2 = []
	flg = 0
	chk = 0
	for i in range(n):
		if i == 0:
			num1.append('1')
			num2.append('1')
		elif s[i] == '0':
			num1.append('0')
			num2.append('0')
		elif s[i] == '1':
			num1.append('0')
			num2.append('1')
			chk = 1
		elif s[i] == '2':
			num1.append('1')
			num2.append('1')
			flg = 1
	if flg == 1 and chk == 1:
		for i in range(n):
			if s[i] == '1':
				stop = i
				break
		for i in range(stop):
			if s[i] == '2':
				num1[i] = '1'
				num2[i] = '1'
		for i in range(stop, n):
			if s[i] == '2':
				num1[i] = '0'
				num2[i] = '2'
	for i in range(1, n):
		if num1[i] == '0' and num2[i] != '0':
			num1[i] = num2[i]
			num2[i] = '0'
			break
	print(''.join(num1))
	print(''.join(num2))


t = int(input())
for tt in range(t):
	n = int(input())
	x = input()
	h1 = False
	sol1 = ''
	sol2 = ''
	for xi in x:
		if h1:
			sol1 += '0'
			sol2 += xi
		elif xi == '0':
			sol1 += '0'
			sol2 += '0'
		elif xi == '2':
			sol1 += '1'
			sol2 += '1'
		else:
			sol1 += '1'
			sol2 += '0'
			h1 = True
	print(sol1)
	print(sol2)


T = int(input())
n = [0] * T
k = [0] * T
ns = [0] * T
for t in range(T):
	n[t] = int(input())
	ns[t] = list(input())

def ans(n, ns):
	an = []
	zn = []
	s = n - 1
	for i in range(n):
		if int(ns[i]) == 2:
			an.append('1')
			zn.append('1')
		elif int(ns[i]) == 0:
			an.append(str(0))
			zn.append(str(0))
		elif int(ns[i]) == 1:
			an.append(str(1))
			zn.append(str(0))
			s = i
			break
	if s != n - 1:
		an += [str(0)] * (n - s - 1)
		zn += ns[s + 1:]
	return str(''.join(an) + '\n' + ''.join(zn))
for t in range(T):
	print(ans(n[t], ns[t]))


t = int(input())
for foo in range(t):
	n = int(input())
	x = str(input())
	a = '1'
	b = '1'
	equal = 1
	for i in range(1, n):
		if x[i] == '0':
			a += '0'
			b += '0'
		if x[i] == '2':
			if equal == 1:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
		if x[i] == '1':
			if equal == 1:
				equal = 0
				a += '1'
				b += '0'
			else:
				a += '0'
				b += '1'
	print(a)
	print(b)


import sys
import math
import bisect
from math import sqrt

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def rinput():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
mod = int(1000000000.0) + 7
for _ in range(iinput()):
	n = iinput()
	x = input()
	a = ''
	b = ''
	f = True
	for i in range(n):
		if x[i] == '2':
			if f:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
		elif x[i] == '1':
			if f:
				a += '1'
				b += '0'
				f = False
			else:
				b += '1'
				a += '0'
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	x = input()
	a = ['1']
	b = ['1']
	for i in range(1, n):
		if x[i] == '0':
			a.append('0')
			b.append('0')
		if x[i] == '1':
			a.append('0')
			b.append('1')
		if x[i] == '2':
			a.append('1')
			b.append('1')
	flag = -1
	for i in range(1, n):
		if a[i] == '0' and b[i] == '1':
			flag = 1
			index = i
			break
	if flag == 1:
		for i in range(index + 1, n):
			if a[i] == '1' and b[i] == '1':
				(b[i], a[i]) = ('0', '2')
			if a[i] == '0' and b[i] == '1':
				(a[i], b[i]) = ('1', '0')
	a1 = ''
	b1 = ''
	for i in range(n):
		a1 += a[i]
		b1 += b[i]
	print(a1)
	print(b1)


t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	a = ''
	b = ''
	cnt = 0
	for i in range(len(x)):
		if cnt < 1:
			if x[i] == '2':
				a += '1'
				b += '1'
			elif x[i] == '1':
				a += '1'
				b += '0'
				cnt += 1
			else:
				a += '0'
				b += '0'
		else:
			a += '0'
			b += x[i]
	print(a)
	print(b)


def ternary_xor(tern_numb):
	tern_a = []
	tern_b = []
	done = False
	for i in tern_numb:
		if i == 2:
			if done:
				tern_a.append(0)
				tern_b.append(2)
			else:
				tern_a.append(1)
				tern_b.append(1)
		elif i == 1 and (not done):
			tern_a.append(1)
			tern_b.append(0)
			done = True
		elif i == 1 and done:
			tern_a.append(0)
			tern_b.append(1)
		else:
			tern_a.append(0)
			tern_b.append(0)
	return (tern_a, tern_b)

def test():
	number_of_tests = int(input())
	for i in range(number_of_tests):
		n = int(input())
		tern_numb = list(map(int, input()))
		sol = ternary_xor(tern_numb)
		output = ''.join(map(str, sol[0]))
		print(output)
		output = ''.join(map(str, sol[1]))
		print(output)
	return ()
test()


def answer(n, x):
	a = []
	b = []
	ocount = 0
	for e in x:
		if e == '0':
			a.append('0')
			b.append('0')
		elif e == '2':
			if ocount < 1:
				a.append('1')
				b.append('1')
			else:
				a.append('0')
				b.append('2')
		else:
			ocount += 1
			if ocount == 1:
				a.append('1')
				b.append('0')
			else:
				a.append('0')
				b.append('1')
	print(''.join(a))
	print(''.join(b))
	return

def main():
	t = int(input())
	n = [0] * t
	x = [0] * t
	for j in range(t):
		n[j] = int(input())
		x[j] = input()
	for j in range(t):
		answer(n[j], x[j])
main()


t = int(input())
for tt in range(0, t):
	n = int(input())
	s = input()
	penalty = 0
	first = ''
	second = ''
	ones = 0
	twos = 0
	for i in s:
		if i == '2':
			if twos == 0:
				first += '1'
				second += '1'
			else:
				first += '0'
				second += '2'
		if i == '1':
			if ones == 0:
				first += '1'
				second += '0'
				ones = 1
				twos = 1
			else:
				first += '0'
				second += '1'
		if i == '0':
			first += '0'
			second += '0'
	print(first)
	print(second)


t = int(input())
for i in range(t):
	n = int(input())
	st = input()
	a = ''
	b = ''
	tem = 0
	for j in range(n):
		if st[j] == '2':
			if tem == 0:
				a += '1'
				b += '1'
			else:
				tem = 1
				a += '0'
				b += '2'
		elif st[j] == '1':
			if tem == 0:
				a += '1'
				b += '0'
				tem = 1
			else:
				tem = 1
				a += '0'
				b += '1'
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


n = int(input())
l_ = []
s_ = []
for i in range(n):
	l_.append(int(input()))
	s_.append(input())
for i in range(len(l_)):
	a = '1'
	b = '1'
	j = 1
	l = l_[i]
	s = s_[i]
	while j < l and s[j] != '1':
		if s[j] == '0':
			a = a + '0'
			b = b + '0'
		elif s[j] == '2':
			a = a + '1'
			b = b + '1'
		j += 1
	if j < l:
		a = a + '1'
		b = b + '0'
		j += 1
	while j < l:
		if s[j] == '0':
			a = a + '0'
			b = b + '0'
		elif s[j] == '2':
			a = a + '0'
			b = b + '2'
		elif s[j] == '1':
			a = a + '0'
			b = b + '1'
		j += 1
	print(a)
	print(b)


def run(s, n):
	a = b = '1'
	flag = True
	for i in s[1:]:
		if i == '2':
			if flag:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
		elif i == '1':
			if flag:
				flag = False
				a += '1'
				b += '0'
			else:
				a += '0'
				b += '1'
		else:
			a += '0'
			b += '0'
	return (a, b)
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	(a, b) = run(s, n)
	print(a)
	print(b)


x = int(input())
for a in range(0, x):
	y = int(input())
	x1 = input()
	s = ''
	s1 = ''
	for b in range(0, y):
		if x1[b] == '2':
			if s == s1:
				s += '1'
				s1 += '1'
			elif s > s1:
				s += '0'
				s1 += '2'
			else:
				s1 += '0'
				s += '2'
		elif x1[b] == '1':
			if s >= s1:
				s1 += '1'
				s += '0'
			else:
				s1 += '0'
				s += '1'
		elif x1[b] == '0':
			if b != 0:
				s += '0'
				s1 += '0'
			else:
				s += '2'
				s1 += '1'
	print(max(s, s1))
	print(min(s, s1))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	s = input()
	l1 = [0] * n
	l2 = [0] * n
	f2 = 0
	f1 = 0
	f3 = 0
	for i in range(n):
		if s[i] == '2':
			if i == 0 or f1 == 0:
				l1[i] = 1
				l2[i] = 1
			else:
				l1[i] = 0
				l2[i] = 2
		elif s[i] == '1':
			if f1 == 1:
				l1[i] = 0
				l2[i] = 1
				f3 = 1
			else:
				l1[i] = 1
				l2[i] = 0
			f1 = 1
		else:
			l1[i] = 0
			l2[i] = 0
	s1 = ''.join([str(a) for a in l1])
	s2 = ''.join([str(a) for a in l2])
	print(s1 + '\n' + s2)


q = int(input())
for rewewre in range(q):
	n = int(input())
	s = input()
	a = ''
	b = ''
	k = False
	for i in s:
		if i == '2' and (not k):
			a += '1'
			b += '1'
		if i == '2' and k:
			a += '0'
			b += '2'
		if i == '1':
			if k:
				b += '1'
				a += '0'
			else:
				a += '1'
				b += '0'
				k = True
		if i == '0':
			a += '0'
			b += '0'
	print(a)
	print(b)


for _ in range(int(input())):
	n = int(input())
	s = input()
	(a, b) = ([], [])
	flag = 0
	for i in s:
		if i == '2':
			if flag == 0:
				a.append('1')
				b.append('1')
			else:
				a.append('0')
				b.append('2')
		elif i == '0':
			a.append('0')
			b.append('0')
		elif flag == 0:
			a.append('1')
			b.append('0')
			flag = 1
		else:
			a.append('0')
			b.append('1')
	print(''.join(a))
	print(''.join(b))


def printer(y, n):
	for i in range(0, n):
		print(y[i], end='')
	print()
t = int(input())
for i in range(0, t):
	n = int(input())
	s = input()
	x = 1
	y = [1]
	z = [1]
	for j in range(1, n):
		x += 1
		if s[j] == '1':
			y.append(1)
			z.append(0)
			break
		else:
			c = int(int(s[j]) / 2)
			y.append(c)
			z.append(c)
	for j in range(x, n):
		y.append(0)
		z.append(int(s[j]))
	printer(y, n)
	printer(z, n)


for t in range(int(input())):
	n = int(input())
	s = input()
	k = ''
	l = ''
	c = 0
	for i in s:
		if i == '1':
			if c == 0:
				k += '1'
				c = 1
			else:
				k += '0'
		elif i == '2':
			if c == 1:
				k += '0'
			else:
				k += '1'
		else:
			k += i
	c = 0
	l += '1'
	s1 = s[1:]
	for i in s1:
		if i == '1':
			if c == 0:
				l += '0'
				c = 1
			else:
				l += '1'
		elif i == '2':
			if c == 1:
				l += '2'
			else:
				l += '1'
		else:
			l += i
	print(k)
	print(l)


T = int(input())
for _ in range(0, T):
	N = int(input())
	astr = input()
	num1 = []
	num2 = []
	checked = 0
	for i in astr:
		if i == '2':
			if checked == 0:
				num1.append('1')
				num2.append('1')
			else:
				num1.append('0')
				num2.append('2')
		elif i == '1':
			if checked == 0:
				num1.append('1')
				num2.append('0')
				checked = 1
			else:
				num1.append('0')
				num2.append('1')
		else:
			num1.append('0')
			num2.append('0')
	for i in num1:
		print(i, end='')
	print()
	for i in num2:
		print(i, end='')
	print()


n = int(input())
for i in range(n):
	input()
	str = input()
	(a, b) = ([], [])
	one = False
	for s in str:
		if s == '2':
			if one:
				a.append('0')
				b.append('2')
			else:
				a.append('1')
				b.append('1')
		elif s == '1':
			if one:
				a.append('0')
				b.append('1')
			else:
				one = True
				a.append('1')
				b.append('0')
		else:
			a.append('0')
			b.append('0')
	print(''.join(a))
	print(''.join(b))


import sys
from functools import lru_cache
from heapq import merge, heapify, heappop, heappush
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf
from collections import defaultdict as dd, deque, Counter as c
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def outln(var):
	sys.stdout.write(str(var) + '\n')

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(int(data())):
	n = int(data())
	s = data()
	(a, b) = (['1'], ['1'])
	r = True
	for i in range(1, n):
		if s[i] == '0':
			a.append('0')
			b.append('0')
		elif r:
			if s[i] == '2':
				a.append('1')
				b.append('1')
			if s[i] == '1':
				a.append('1')
				b.append('0')
				r = False
		else:
			a.append('0')
			b.append(s[i])
	outln(''.join(a))
	outln(''.join(b))


t = int(input())
for hh in range(0, t):
	n = int(input())
	s = input()
	li1 = []
	li2 = []
	mx = -1
	if s[0] == '0':
		li1.append(1)
		li2.append(2)
		mx = 2
	elif s[0] == '1':
		li1.append(2)
		li2.append(2)
	else:
		li1.append(1)
		li2.append(1)
	for i in range(1, n):
		if s[i] == '1':
			if mx == -1:
				li1.append(0)
				li2.append(1)
				mx = 2
			elif mx == 1:
				li1.append(0)
				li2.append(1)
			else:
				li1.append(1)
				li2.append(0)
		elif s[i] == '0':
			li1.append(0)
			li2.append(0)
		elif s[i] == '2':
			if mx == -1:
				li1.append(1)
				li2.append(1)
			elif mx == 1:
				li1.append(0)
				li2.append(2)
			else:
				li1.append(2)
				li2.append(0)
	ans1 = ''
	ans2 = ''
	for i in range(0, n):
		ans1 += str(li1[i])
		ans2 += str(li2[i])
	print(ans1)
	print(ans2)


t = int(input())
for _ in range(t):
	n = int(input())
	x = list(input())
	a = []
	b = []
	for i in range(n):
		if x[i] is '2':
			a.append('1')
			b.append('1')
		elif x[i] is '0':
			a.append('0')
			b.append('0')
		else:
			a.append('1')
			a.extend(list('0' * (n - 1 - i)))
			b.append('0')
			b.extend(x[i + 1:])
			break
	print(''.join(a))
	print(''.join(b))


from sys import stdin, stdout
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input()))
	a = [0 for i in range(n)]
	b = [0 for i in range(n)]
	flag = False
	for i in range(n):
		if l[i] == 2:
			if flag:
				b[i] = 2
			else:
				a[i] = 1
				b[i] = 1
		elif l[i] == 1 and (not flag):
			flag = True
			a[i] = 1
		elif l[i] == 1 and flag:
			b[i] = 1
	print(''.join(map(str, a)))
	print(''.join(map(str, b)))


for _ in range(int(input())):
	n = int(input())
	c = input()
	boo = True
	a = ''
	b = ''
	s1 = '1'
	s2 = '1'
	for i in c:
		if i == '0':
			a += '0'
			b += '0'
		if i == '1':
			a += '1'
			b += '0'
		if i == '2':
			a += s1
			b += s2
		if a != b and boo:
			boo = False
			(a, b) = (b, a)
			s1 = '2'
			s2 = '0'
	print(b)
	print(a)


for _ in range(int(input())):
	n = int(input())
	x = list(map(int, list(input())))
	a = [0 for i in range(n)]
	b = [0 for i in range(n)]
	a[0] = 1
	b[0] = 1
	flag = 0
	for i in range(1, n):
		if x[i] == 0:
			continue
		elif x[i] == 1:
			if flag == 1:
				b[i] = 1
			else:
				a[i] = 1
				flag = 1
		elif flag == 1:
			b[i] = 2
		else:
			b[i] = 1
			a[i] = 1
	for i in range(n):
		print(a[i], end='')
	print('')
	for i in range(n):
		print(b[i], end='')
	print('')


from sys import stdin
input = stdin.readline
t = int(input())
for i in range(t):
	n = int(input())
	X = list(input())
	A = [None] * n
	B = [None] * n
	A[0] = 1
	B[0] = 1
	trig = 1
	for i in range(1, n):
		if X[i] == '0':
			A[i] = 0
			B[i] = 0
		elif X[i] == '1':
			if trig:
				A[i] = 1
				B[i] = 0
				trig = 0
			else:
				A[i] = 0
				B[i] = 1
		elif X[i] == '2':
			if trig:
				A[i] = 1
				B[i] = 1
			else:
				A[i] = 0
				B[i] = 2
	for i in A:
		print(i, end='')
	print()
	for i in B:
		print(i, end='')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	a = []
	b = []
	g = False
	for x in s:
		if g:
			a.append(0)
			b.append(int(x))
			continue
		if x == '1':
			a.append(1)
			b.append(0)
			g = True
		else:
			a.append(int(x) // 2)
			b.append(int(x) // 2)
	print(''.join(map(str, a)))
	print(''.join(map(str, b)))


from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
from collections import defaultdict as dd, deque

def data():
	return sys.stdin.readline().strip()

def mdata():
	return map(int, data().split())
mod = 998244353
for q in range(int(data())):
	n = int(data())
	x = data()
	a = b = ''
	k = 0
	for i in range(n):
		if k == 0:
			if x[i] == '2':
				a += '1'
				b += '1'
			elif x[i] == '1':
				a += '1'
				b += '0'
				k = 1
			else:
				a += '0'
				b += '0'
		else:
			a += '0'
			b += x[i]
	print(a)
	print(b)


t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	a = ''
	b = ''
	egyes = False
	for char in x:
		if egyes:
			a += '0'
			b += char
		elif char == '1':
			a += '1'
			b += '0'
			egyes = True
		elif char == '2':
			a += '1'
			b += '1'
		elif char == '0':
			a += '0'
			b += '0'
	print(a)
	print(b)


T = int(input())
for t in range(T):
	n = int(input())
	S = input()
	s1 = ''
	s2 = ''
	flag = 0
	for s in S:
		if s == '0':
			s1 += '0'
			s2 += '0'
		elif s == '1' and flag == 0:
			s1 += '1'
			s2 += '0'
			flag = 1
		elif s == '1' and flag == 1:
			s1 += '0'
			s2 += '1'
		elif flag == 0:
			s1 += '1'
			s2 += '1'
		else:
			s1 += '0'
			s2 += '2'
	print(s1)
	print(s2)


t = int(input())
for i in range(t):
	n = int(input())
	L = list(input())
	a = ''
	b = ''
	flag = 0
	for i in range(n):
		if L[i] == '2':
			if flag == 0:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
		elif L[i] == '1':
			if flag == 0:
				a += '1'
				b += '0'
				flag = 1
			else:
				a += '0'
				b += '1'
		elif L[i] == '0':
			a += '0'
			b += '0'
	print(a)
	print(b)


t = int(input())
while t:
	n = int(input())
	s = input()
	a = ''
	b = ''
	d = 0
	for i in range(n):
		if d == 0:
			if s[i] == '2':
				a += '1'
				b += '1'
			elif s[i] == '0':
				a += '0'
				b += '0'
			elif s[i] == '1':
				a += '1'
				b += '0'
				d += 1
		elif s[i] == '2':
			a += '0'
			b += '2'
		elif s[i] == '0':
			a += '0'
			b += '0'
		elif s[i] == '1':
			a += '0'
			b += '1'
	print(a)
	print(b)
	t -= 1


n = int(input())
for i in range(n):
	q = int(input())
	s = list(input())
	a = []
	b = []
	d = 0
	k = 0
	for i in s:
		if i == '2' and d != 1:
			a.append(1)
			b.append(1)
		if i == '1' and k != 1:
			d = 1
			a.append(1)
			b.append(0)
			k = 1
			y = 1
		if i == '2' and d == 1:
			a.append(0)
			b.append(2)
		if i == '1' and d == 1 and (y != 1):
			a.append(0)
			b.append(1)
		if i == '0':
			a.append(0)
			b.append(0)
		y = 0
	a = [str(i) for i in a]
	b = [str(i) for i in b]
	print(''.join(a))
	print(''.join(b))


for _ in range(int(input())):
	n = int(input())
	a = input()
	b = ''
	c = ''
	i = 0
	flag = 0
	while i < n:
		if a[i] is '0':
			b += '0'
			c += '0'
		elif a[i] is '2' and flag is 0:
			b += '1'
			c += '1'
		elif a[i] is '1' and flag is 0:
			b += '1'
			c += '0'
			flag = 1
		elif flag is 1:
			b += '0'
			c += a[i]
		i += 1
	print(b)
	print(c)


for i in range(int(input())):
	(n, s, a, b, t) = (int(input()), input(), '', '', 1)
	for i in s:
		if i == '2' and t:
			a += '1'
			b += '1'
		elif i == '1' and t:
			a += '1'
			b += '0'
			t = 0
		else:
			a += '0'
			b += i
	print(a, b, sep='\n')


for _ in range(int(input())):
	n = int(input())
	x = input()
	a = ''
	b = ''
	flag = True
	for i in x:
		if i == '0' and flag:
			a += '0'
			b += '0'
		elif i == '1' and flag:
			a += '1'
			b += '0'
			flag = False
		elif i == '2' and flag:
			a += '1'
			b += '1'
		else:
			a += '0'
			b += i
	print(a)
	print(b)


import sys
T = int(sys.stdin.readline())
for _ in range(T):
	n = int(sys.stdin.readline())
	x = list(sys.stdin.readline().strip())
	a = ['0'] * n
	b = ['0'] * n
	a[0] = '1'
	b[0] = '1'
	check = 1
	for i in range(1, n):
		if check:
			if x[i] == '2':
				a[i] = '1'
				b[i] = '1'
			elif x[i] == '1':
				a[i] = '1'
				check = 0
		else:
			b[i] = x[i]
	print(''.join(a))
	print(''.join(b))


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	a = x.find('1')
	b = x.find('0')
	d = ''
	e = ''
	if a == -1:
		for i in range(n):
			if x[i] == '2':
				d += '1'
				e += '1'
			else:
				d += '0'
				e += '0'
	else:
		for i in range(a):
			if x[i] == '2':
				d += '1'
				e += '1'
			else:
				d += '0'
				e += '0'
		d += '1'
		e += '0'
		d += '0' * (n - a - 1)
		e += x[a + 1:]
	print(d + '\n' + e)


import math
t = int(input())
while t:
	n = int(input())
	x = str(input())
	a = ''
	b = ''
	flag = False
	for char in x:
		if flag == False:
			if char == '2':
				a += '1'
				b += '1'
			if char == '1':
				flag = True
				a += '1'
				b += '0'
			if char == '0':
				a += '0'
				b += '0'
		else:
			if char == '2':
				a += '0'
				b += '2'
			if char == '1':
				a += '0'
				b += '1'
			if char == '0':
				a += '0'
				b += '0'
	print(a)
	print(b)
	t -= 1


t = int(input())
resa = []
resb = []
for i in range(t):
	n = int(input())
	num = input()
	a = ''
	b = ''
	if num[0] == '1':
		temp = '2'
	else:
		temp = '1'
	a += temp
	b += temp
	flag = False
	for j in range(1, len(num)):
		if not flag:
			if num[j] == '1':
				flag = True
			temp = int(num[j]) // 2
			b += str(temp)
			a += str(int(num[j]) - temp)
		else:
			a += '0'
			b += num[j]
	resa.append(a)
	resb.append(b)
for i in range(t):
	print(resa[i])
	print(resb[i])


t = int(input())
for _ in range(t):
	n = input()
	tt = input()
	a = ''
	b = ''
	chk = 1
	for x in tt:
		if x == '2':
			if chk == 1:
				a = a + '1'
				b = b + '1'
			else:
				a = a + '0'
				b = b + '2'
		elif x == '1':
			if chk == 1:
				a = a + '1'
				b = b + '0'
				chk = 0
				continue
			if chk == 0:
				a = a + '0'
				b = b + '1'
				continue
		elif x == '0':
			a = a + '0'
			b = b + '0'
	print(a)
	print(b)


from sys import stdin
input = lambda : stdin.readline()
from math import ceil
for _ in range(int(input())):
	n = int(input())
	s = input()
	b = []
	flag = 0
	for i in range(n):
		if flag == 0:
			if s[i] == '2':
				print('1', end='')
				b.append('1')
			elif s[i] == '1':
				flag = 1
				print('1', end='')
				b.append('0')
			elif s[i] == '0':
				print('0', end='')
				b.append('0')
		elif s[i] == '2':
			print('0', end='')
			b.append('2')
		elif s[i] == '1':
			print('0', end='')
			b.append('1')
		elif s[i] == '0':
			print('0', end='')
			b.append('0')
	print()
	for i in b:
		print(i, end='')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	c = list(input())
	a = []
	b = []
	ch = 0
	for j in range(n):
		x1 = int(c[j])
		if x1 % 2 == 0 and ch == 0:
			a.append(x1 // 2)
			b.append(x1 // 2)
		elif ch == 0:
			a.append(1)
			b.append(0)
			ch = 1
		else:
			b.append(x1)
			a.append(0)
	for j in range(n):
		if j != n - 1:
			print(a[j], end='')
		else:
			print(a[j])
	for j in range(n):
		if j != n - 1:
			print(b[j], end='')
		else:
			print(b[j])


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	(c1, c2) = (0, 0)
	(a, b) = ('', '')
	for i in range(len(x)):
		if x[i] == '1':
			if c1 == 0:
				a += '1'
				b += '0'
				c1 += 1
			else:
				b += '1'
				a += '0'
		elif x[i] == '2':
			if c2 == 0:
				a += '1'
				b += '1'
				c2 += 1
			elif c1 == 0:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


t = int(input())
for q in range(t):
	n = int(input())
	x = input()
	a = ''
	b = ''
	r = False
	for i in range(n):
		if not r:
			if x[i] == '1':
				r = True
				a += '1'
				b += '0'
			elif x[i] == '2':
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '0'
		else:
			a += '0'
			b += x[i]
	print(a)
	print(b)


for _ in range(int(input())):
	n = int(input())
	s = input()
	a = '1'
	b = '1'
	o = 0
	for i in range(1, n):
		if s[i] == '0':
			a += '0'
			b += '0'
		elif s[i] == '1':
			if o:
				a += '1'
				b += '0'
			else:
				a += '0'
				b += '1'
			o = 1
		elif o == 0:
			a += '1'
			b += '1'
		else:
			a += '2'
			b += '0'
	print(a)
	print(b)


tc = input()
for t in range(int(tc)):
	n = input()
	s = input()
	a = '1'
	b = '1'
	flag = 0
	for i in range(1, int(n)):
		if flag == 0:
			if s[i] == '0':
				a += '0'
				b += '0'
			elif s[i] == '1':
				a += '1'
				b += '0'
				flag = 1
			else:
				a += '1'
				b += '1'
		else:
			a += '0'
			b += s[i]
	print(a)
	print(b)


T = int(input().strip())
for t in range(T):
	N = int(input().strip())
	S = str(input().strip())
	a = '1'
	b = '1'
	maxGet = 0
	for i in range(1, N):
		if S[i] == '0':
			a += '0'
			b += '0'
		elif S[i] == '1':
			if maxGet == 1:
				a += '0'
				b += '1'
			else:
				a += '1'
				b += '0'
				maxGet = 1
		elif maxGet == 1:
			a += '0'
			b += '2'
			maxGet = 1
		else:
			a += '1'
			b += '1'
	print(a, b)


n = int(input())
while n > 0:
	len = int(input())
	a = ['0'] * len
	b = ['0'] * len
	L = [int(x) for x in str(input())]
	i = 0
	while i < len:
		if L[i] == 0:
			i += 1
		elif L[i] == 2:
			a[i] = '1'
			b[i] = '1'
			i += 1
		else:
			a[i] = '1'
			break
	b[i + 1:] = [str(x) for x in L[i + 1:]]
	print(int(''.join(a)))
	print(int(''.join(b)))
	n = n - 1


for i in range(int(input())):
	n = int(input())
	c = input()
	a = []
	b = []
	d = 0
	for i in range(n):
		if i == 0:
			a.append('1')
			b.append('1')
		elif c[i] == '0':
			a.append('0')
			b.append('0')
		elif c[i] == '1':
			if d == 0:
				a.append('1')
				b.append('0')
				d = 1
			else:
				a.append('0')
				b.append('1')
		elif d == 0:
			a.append('1')
			b.append('1')
		else:
			a.append('0')
			b.append('2')
	a = ''.join(map(str, a))
	b = ''.join(map(str, b))
	print(a)
	print(b)


t = int(input())
while t > 0:
	t -= 1
	n = input()
	s = input()
	p = ''
	q = ''
	cnt = 0
	for i in s:
		if i == '2':
			if cnt == 0:
				p += '1'
				q += '1'
			else:
				p += '2'
				q += '0'
		elif i == '1':
			if cnt == 0:
				cnt = 1
				p += '0'
				q += '1'
			else:
				p += '1'
				q += '0'
		else:
			p += '0'
			q += '0'
	print(q)
	print(p)


t = int(input())
for i in range(t):
	n = int(input())
	ar = input()
	a = ''
	b = ''
	count = 0
	if ar.count('2') == n:
		print('1' * n)
		print('1' * n)
	elif ar.count('1') == n:
		print(f"{('1', '0' * (n - 1))}")
		print(f"{('0', '1' * (n - 1))}")
	elif ar.count('0') == n:
		print('0' * n)
		print('0' * n)
	else:
		for i in range(n):
			if ar[i] == '2':
				if count == 0:
					a += '1'
					b += '1'
				else:
					a += '0'
					b += '2'
			elif ar[i] == '1':
				if count == 0:
					a += '1'
					b += '0'
					count += 1
				else:
					a += '0'
					b += '1'
			elif ar[i] == '0':
				a += '0'
				b += '0'
		print(a)
		print(b)


from collections import defaultdict
t = int(input())
for _ in range(t):
	counts = defaultdict(int)
	n = int(input())
	x = input()
	a = '1'
	b = '1'
	switch = False
	for c in x[1:]:
		if c == '2' and switch:
			a += '2'
			b += '0'
		elif c == '2':
			b += '1'
			a += '1'
		elif c == '1' and switch:
			a += '1'
			b += '0'
		elif c == '1':
			b += '1'
			a += '0'
			switch = True
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


t = int(input())

def convert(list):
	s = [str(i) for i in list]
	res = int(''.join(s))
	return res
while t > 0:
	n = int(input())
	a = int(input())
	arr = [int(x) for x in str(a)]
	res = []
	for k in range(n):
		if arr[k] == 1:
			index = k
			break
		else:
			index = 0
	if index:
		for i in range(index + 1):
			if arr[i] == 2:
				res.append(1)
			elif arr[i] == 0:
				res.append(0)
			elif arr[i] == 1:
				res.append(1)
		for j in range(index + 1, len(arr)):
			res.append(0)
	else:
		res.append(1)
		for i in range(1, len(arr)):
			if arr[i] == 2:
				res.append(1)
			elif arr[i] == 0:
				res.append(0)
	x = convert(res)
	y = a - x
	print(x)
	print(y)
	t = t - 1


for _ in range(int(input())):
	n = int(input())
	x = input()
	a = ''
	b = ''
	for i in range(n):
		if x[i] == '0':
			a += '0'
			b += '0'
		elif x[i] == '1':
			a += '1'
			b += '0'
			break
		else:
			a += '1'
			b += '1'
	for j in range(i + 1, n):
		if x[j] == '2':
			a += '0'
			b += '2'
		if x[j] == '1':
			a += '0'
			b += '1'
		if x[j] == '0':
			a += '0'
			b += '0'
	print(a)
	print(b)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	x = input()
	A = []
	B = []
	first_one = False
	for i in range(n):
		if first_one:
			A.append(0)
			B.append(x[i])
		elif x[i] == '2':
			A.append(1)
			B.append(1)
		elif x[i] == '0':
			A.append(0)
			B.append(0)
		else:
			A.append(1)
			B.append(0)
			first_one = True
	for i in range(n):
		print(A[i], end='')
	print()
	for i in range(n):
		print(B[i], end='')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	num = list(input())
	flag = 0
	val = 0
	a = ''
	b = ''
	for i in num:
		if i == '2':
			if flag == 0:
				a += '1'
				b += '1'
			else:
				b += '2'
				a += '0'
		elif i == '1':
			if flag == 0:
				a += '1'
				b += '0'
				flag = 1
			else:
				b += '1'
				a += '0'
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


for i in range(int(input())):
	n = int(input())
	x = input()
	a = '1'
	b = '1'
	equal = True
	for z in range(1, n):
		if equal:
			if x[z] == '2':
				a += '1'
				b += '1'
			elif x[z] == '1':
				a += '1'
				equal = False
				b += '0'
			else:
				a += '0'
				b += '0'
		elif x[z] == '2':
			a += '0'
			b += '2'
		elif x[z] == '1':
			a += '0'
			b += '1'
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


import sys, math
input = sys.stdin.readline
t = int(input())
for r in range(t):
	n = int(input())
	s = input().strip('\n')
	a = '1'
	b = '1'
	comp = 0
	for i in range(1, n):
		if s[i] == '0':
			a += '0'
			b += '0'
		elif s[i] == '1':
			if comp == 0:
				a += '1'
				b += '0'
				comp = 1
			else:
				a += '0'
				b += '1'
		elif comp == 0:
			a += '1'
			b += '1'
		else:
			a += '0'
			b += '2'
	print(a)
	print(b)


t = int(input())
sol = []
for _ in range(t):
	n = int(input())
	arr = list(map(int, list(input())))
	a = []
	b = []
	flag = False
	for i in range(n):
		if not flag:
			if arr[i] == 2:
				a.append(1)
				b.append(1)
			elif arr[i] == 0:
				a.append(0)
				b.append(0)
			else:
				a.append(1)
				b.append(0)
				flag = True
		elif arr[i] == 2:
			a.append(0)
			b.append(2)
		elif arr[i] == 0:
			a.append(0)
			b.append(0)
		else:
			a.append(0)
			b.append(1)
	sa = ''.join(map(str, a))
	sb = ''.join(map(str, b))
	sol.append(sa)
	sol.append(sb)
for s in sol:
	print(s)


for _ in range(int(input())):
	n = int(input())
	s = input()
	max_s = []
	min_s = []
	max_s.append('1')
	min_s.append('1')
	count = 0
	for i in range(1, n):
		if count == 0:
			if s[i] == '2':
				max_s.append('1')
				min_s.append('1')
			if s[i] == '1':
				max_s.append('1')
				min_s.append('0')
				count += 1
			if s[i] == '0':
				max_s.append('0')
				min_s.append('0')
			continue
		if count != 0:
			if s[i] == '2':
				max_s.append('0')
				min_s.append('2')
			if s[i] == '1':
				max_s.append('0')
				min_s.append('1')
				count += 1
			if s[i] == '0':
				max_s.append('0')
				min_s.append('0')
	print(''.join(max_s))
	print(''.join(min_s))


t = int(input())
for _ in range(t):
	n = int(input())
	a = input()
	(f, s) = ('', '')
	was = False
	for i in range(n):
		if a[i] == '0':
			s += '0'
			f += '0'
		elif a[i] == '2':
			if not was:
				f += '1'
				s += '1'
			else:
				f += '0'
				s += '2'
		elif not was:
			f += '1'
			s += '0'
			was = True
		else:
			f += '0'
			s += '1'
	print(f)
	print(s)


tc = int(input().strip())
for t in range(tc):
	n = int(input().strip())
	x = [int(x) for x in list(input().strip())]
	mx = 0
	(a, b) = ([], [])
	for i in range(n):
		if x[i] == 0:
			a.append(0)
			b.append(0)
		elif x[i] == 1:
			if mx == 1:
				a.append(0)
				b.append(1)
			else:
				a.append(1)
				b.append(0)
				mx = 1
		elif mx == 1:
			a.append(0)
			b.append(2)
		else:
			a.append(1)
			b.append(1)
	print(''.join([str(d) for d in a]))
	print(''.join([str(d) for d in b]))


from sys import stdin, stdout
import math

def main():
	t = int(input())
	while t:
		n = int(input())
		x = input()
		a = ''
		b = ''
		ch = 0
		for i in range(n):
			if x[i] == '2':
				if ch > 0:
					b += '2'
					a += '0'
				else:
					a += '1'
					b += '1'
			elif x[i] == '0':
				a += '0'
				b += '0'
			else:
				if ch == 0:
					a += '1'
					b += '0'
				else:
					b += '1'
					a += '0'
				ch += 1
		print(a)
		print(b)
		t -= 1
main()


for _ in range(int(input())):
	x = int(input())
	y = str(input())
	a = '1'
	b = '1'
	temp = 0
	for i in range(1, x):
		if y[i] == '2':
			a += '1'
			b += '1'
		elif y[i] == '1':
			a += '1'
			b += '0'
			temp = i
			break
		else:
			a += '0'
			b += '0'
	if temp != 0:
		for i in range(temp + 1, x):
			a += '0'
			b += y[i]
	print(a)
	print(b)


for _ in '0' * int(input()):
	n = int(input())
	s = input()
	(a, b) = ('1', '1')
	c = 0
	for i in s[1:]:
		if i == '1' and c == 0:
			c = 1
			b += '0'
			a += i
			continue
		if c == 0 and i == '2':
			a += '1'
			b += '1'
		elif c == 0 and i == '0':
			a += '0'
			b += '0'
		else:
			b += i
			a += '0'
	print(a, b, sep='\n')


import sys
input = sys.stdin.readline

def main():

	def solve(x):
		a = ''
		b = ''
		aislarger = 0
		for (i, d) in enumerate(str(x)):
			if i == 0:
				a += '1'
				b += '1'
			elif d == '0':
				a += '0'
				b += '0'
			elif d == '1':
				if aislarger == 0:
					a += '1'
					b += '0'
					aislarger = 1
				elif aislarger == 1:
					a += '0'
					b += '1'
				else:
					a += '1'
					b += '0'
			elif aislarger == 0:
				a += '1'
				b += '1'
			elif aislarger == 1:
				a += '0'
				b += '2'
			else:
				a += '2'
				b += '0'
		return (int(a), int(b))
	t = int(input())
	for _ in range(t):
		n = int(input())
		x = int(input())
		(a, b) = solve(x)
		print(a)
		print(b)
main()


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	a = ''
	b = ''
	for j in range(len(s)):
		if s[j] == '2':
			a += str(1)
			b += str(1)
		elif s[j] == '0':
			a += str(0)
			b += str(0)
		elif s[j] == '1':
			a += str(1)
			b += str(0)
			for k in range(j + 1, len(s), 1):
				a += str(0)
				b += str(s[k])
			break
	print(a)
	print(b)


for i in range(int(input())):
	n = int(input())
	x = input()
	a = ['0'] * n
	b = a.copy()
	(a[0], b[0]) = ('1', '1')
	flag = True
	i = 1
	while i < n and x[i] != '1':
		if x[i] == '2':
			(a[i], b[i]) = ('1', '1')
		else:
			(a[i], b[i]) = ('0', '0')
		i += 1
	else:
		if i < n:
			a[i] = x[i]
	for j in range(i + 1, n):
		if x[j] == '0':
			(a[j], b[j]) = ('0', '0')
		else:
			b[j] = x[j]
	print(''.join(a))
	print(''.join(b))


from sys import stdin
tc = int(input())
for i in range(tc):
	n = stdin.readline()
	x = stdin.readline()
	a = [1]
	b = [1]
	larger = -1
	for j in range(1, len(x)):
		if x[j] == '0':
			a.append('0')
			b.append('0')
		elif x[j] == '1':
			if larger == 1 or larger == -1:
				a.append('0')
				b.append('1')
				if larger == -1:
					larger = 2
			elif larger == 2:
				a.append('1')
				b.append('0')
		elif x[j] == '2':
			if larger == 1:
				a.append('0')
				b.append('2')
			elif larger == 2:
				a.append('2')
				b.append('0')
			else:
				a.append('1')
				b.append('1')
	print(*a, sep='')
	print(*b, sep='')


t = int(input())
for j in range(t):
	n = int(input())
	result1 = []
	result2 = []
	x = input()
	m_a = 0
	n_b = 0
	last_index = 0
	for i in range(n):
		if x[i] == '0':
			result1.append(0)
			result2.append(0)
		elif x[i] == '2':
			result1.append(1)
			result2.append(1)
		elif x[i] == '1':
			result1.append(1)
			result2.append(0)
			last_index = i + 1
			break
	for i in range(last_index, n):
		result1.append(0)
		result2.append(int(x[i]))
	for i in range(n):
		print(result1[i], end='')
	print('')
	for i in range(n):
		print(result2[i], end='')
	print('')


for _ in range(int(input())):
	n = int(input())
	x = list(map(int, list(input())))
	(a, b) = ([], [])
	i = 0
	while i < n and (x[i] == 2 or x[i] == 0):
		if x[i] == 2:
			(a.append(1), b.append(1))
		elif x[i] == 0:
			(a.append(0), b.append(0))
		i += 1
	if i < n:
		(a.append(1), b.append(0))
		i += 1
	while i < n:
		(a.append(0), b.append(x[i]))
		i += 1
	print(''.join(map(str, a)))
	print(''.join(map(str, b)))


T = int(input())
for t in range(T):
	n = int(input())
	y = list(str(input()))
	(a, b) = ('1', '1')
	flag = False
	for i in range(1, n):
		c = y[i]
		if flag:
			a += '0'
			b += c
		else:
			x = int(c)
			if x == 1:
				a += '1'
				b += '0'
				flag = True
			else:
				a += str(int(x / 2))
				b += str(int(x / 2))
	print(a)
	print(b)


from math import *
from bisect import bisect_left, bisect_right
from sys import stdin, stdout, setrecursionlimit
from collections import Counter
input = lambda : stdin.readline().strip()
print = stdout.write
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	flag = 0
	a = []
	b = []
	for i in s:
		if i == '0':
			a.append('0')
			b.append('0')
		if i == '1':
			if flag == 1:
				a.append('0')
				b.append('1')
			if flag == 0:
				a.append('1')
				b.append('0')
				flag = 1
		if i == '2':
			if flag == 0:
				a.append('1')
				b.append('1')
			if flag == 1:
				a.append('0')
				b.append('2')
	print(str(''.join(a)) + '\n')
	print(str(''.join(b)) + '\n')


for _ in range(int(input())):
	n = int(input())
	c = input()
	(a, b) = ('', '')
	for i in range(n):
		if c[i] != '1':
			a += str(int(c[i]) // 2)
			b += str(int(c[i]) // 2)
		else:
			a += '1'
			b += '0'
			for j in range(i + 1, n):
				a += '0'
				b += c[j]
			break
	print(a)
	print(b)


from sys import stdin, stdout
import math, sys
from itertools import permutations, combinations
from collections import defaultdict, deque
import bisect as bi
import heapq as hq

def I():
	return int(input())

def In():
	return map(int, input().split())

def main():
	try:
		for _ in range(int(input())):
			n = I()
			l = list(input())
			x = list(map(int, l))
			(a1, a2) = ([1], [1])
			(q, t) = (0, 0)
			for i in range(1, n):
				if x[i] == 2 and q == 0 and (t == 0):
					a1.append(1)
					a2.append(1)
				elif x[i] == 2 and t == 1:
					a1.append(0)
					a2.append(2)
				elif x[i] == 0:
					a1.append(0)
					a2.append(0)
				elif x[i] == 2 and t == 0:
					a1.append(2)
					a2.append(0)
					t = 1
				elif x[i] == 1 and t == 0:
					a1.append(1)
					a2.append(0)
					t = 1
					q = 1
				elif x[i] == 1 and t == 1:
					a1.append(0)
					a2.append(1)
					q = 1
			for x in a1:
				print(x, end='')
			print()
			for x in a2:
				print(x, end='')
			print()
	except:
		pass
M = 998244353
P = 1000000007
main()


t = int(input())
for T in range(t):
	n = int(input())
	x = input()
	a = ''
	b = ''
	eq = True
	for i in range(len(x)):
		if x[i] == '2':
			if eq:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
		elif x[i] == '1':
			if eq:
				a += '1'
				b += '0'
				eq = False
			else:
				a += '0'
				b += '1'
		else:
			a += '0'
			b += '0'
	print(a + '\n' + b)


t = int(input())
while t > 0:
	a = '1'
	b = '1'
	mx = True
	n = int(input())
	k = input()
	for i in range(1, n):
		if k[i] == '2':
			if mx:
				a = a + '1'
				b = b + '1'
			else:
				a = a + '0'
				b = b + '2'
		elif k[i] == '0':
			a = a + '0'
			b = b + '0'
		elif mx:
			a = a + '1'
			b = b + '0'
			mx = False
		else:
			a = a + '0'
			b = b + '1'
	print(a)
	print(b)
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	a = ''
	b = ''
	check = False
	for i in range(n):
		if x[i] == '0':
			a = a + '0'
			b = b + '0'
		if x[i] == '1':
			if not check:
				a = a + '1'
				b = b + '0'
				check = True
			else:
				a = a + '0'
				b = b + '1'
		if x[i] == '2':
			if not check:
				a = a + '1'
				b = b + '1'
			else:
				a = a + '0'
				b = b + '2'
	print(a)
	print(b)


n = int(input())
for i in range(n):
	k = int(input())
	s = input()
	a = ''
	b = ''
	who_is_large = -1
	for i in range(len(s)):
		if i == 0:
			a += '1'
			b += '1'
		elif s[i] == '2':
			if who_is_large == -1:
				a += '1'
				b += '1'
			elif who_is_large == 1:
				a += '0'
				b += '2'
		elif s[i] == '1':
			if who_is_large == -1:
				a += '1'
				b += '0'
				who_is_large = 1
			else:
				a += '0'
				b += '1'
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


def solve():
	n = int(input())
	digs = input().strip()
	used = False
	out1 = []
	out2 = []
	for d in digs:
		if d == '2':
			if not used:
				out1 += '1'
				out2 += '1'
			else:
				out1 += '0'
				out2 += '2'
		elif d == '0':
			out1 += '0'
			out2 += '0'
		elif not used:
			out1 += '1'
			out2 += '0'
			used = True
		else:
			out1 += '0'
			out2 += '1'
	print(''.join(out1))
	print(''.join(out2))
	return 0
t = int(input())
for i in range(t):
	solve()


ca = int(input())
for i in range(ca):
	x = int(input())
	n = int(input())
	y = str(n)
	ma = ''
	mi = ''
	i = 0
	f = True
	while i < x and f:
		if y[i] == '2':
			ma += '1'
			mi += '1'
		elif y[i] == '0':
			ma += '0'
			mi += '0'
		else:
			ma += '1'
			mi += '0'
			f = False
		i += 1
	while i < x:
		ma += '0'
		mi += y[i]
		i += 1
	print(ma)
	print(mi)


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		ss = input()
		a = ''
		b = ''
		for s in ss:
			if s == '2':
				if a == b:
					a += '1'
					b += '1'
				elif a > b:
					a += '0'
					b += '2'
			if s == '1':
				if a > b:
					a += '0'
					b += '1'
				else:
					a += '1'
					b += '0'
			if s == '0':
				a += '0'
				b += '0'
		print(a)
		print(b)
	return
main()


t = int(input())
for i in range(t):
	m = int(input())
	s = input()
	(yo, yo2) = ('', '')
	f = 1
	for j in range(m):
		if s[j] == '2':
			if f == 1:
				yo += '1'
				yo2 += '1'
			else:
				yo += '0'
				yo2 += '2'
		elif s[j] == '1':
			if f == 1:
				yo += '1'
				yo2 += '0'
				f = 0
			else:
				yo += '0'
				yo2 += '1'
		else:
			yo += '0'
			yo2 += '0'
	print(yo)
	print(yo2)


q = int(input())
for i in range(0, q):
	a1 = ''
	b2 = ''
	f = True
	n = int(input())
	x = input()
	if x[0] == '1':
		a1 += '2'
		b2 += '2'
	else:
		a1 += '1'
		b2 += '1'
	for s in range(1, n):
		if x[s] == '0':
			a1 += '0'
			b2 += '0'
		elif x[s] == '1' and f:
			a1 += '1'
			b2 += '0'
			f = False
		elif x[s] == '2' and f:
			a1 += '1'
			b2 += '1'
		elif x[s] == '1' and (not f):
			a1 += '0'
			b2 += '1'
		elif x[s] == '2' and (not f):
			a1 += '0'
			b2 += '2'
	print(a1)
	print(b2)


import sys
for _ in range(int(sys.stdin.readline())):
	n = int(sys.stdin.readline())
	x = sys.stdin.readline()
	(c1, c2) = ('', '')
	c = 0
	for i in range(n):
		if x[i] == '0':
			c1 = c1 + '0'
			c2 = c2 + '0'
		elif x[i] == '2':
			c1 = c1 + '1'
			c2 = c2 + '1'
		else:
			c = 1
			break
	if c == 0:
		print(c1)
		print(c2)
	else:
		c1 = c1 + '1'
		c2 = c2 + '0'
		for i in range(i + 1, n):
			c1 = c1 + '0'
			c2 = c2 + x[i]
		print(c1)
		print(c2)


import math
DEBUG = False
if DEBUG:
	import sys
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def solve():
	n = int(input())
	x = input()
	(a, b) = ('', '')
	flag = 0
	for c in x:
		if flag == 0:
			if c == '2':
				a += '1'
				b += '1'
			elif c == '1':
				a += '1'
				b += '0'
				flag = 1
			else:
				a += '0'
				b += '0'
		else:
			a += '0'
			b += c
	print(a)
	print(b)
t = int(input())
for _ in range(t):
	solve()


import sys
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	n = int(input())
	s = [int(i) for i in input()]
	a = []
	b = []
	for i in range(len(s)):
		if s[i] == 0:
			a.append(0)
			b.append(0)
		elif s[i] == 1:
			a.append(1)
			b.append(0)
			break
		if s[i] == 2:
			a.append(1)
			b.append(1)
	a += [0] * (n - len(a))
	b += s[len(b):]
	print(''.join(map(str, a)))
	print(''.join(map(str, b)))


for _ in range(int(input())):
	l = input()
	t_ = input()
	(f, s) = ('1', '1')
	flag = False
	for t in t_[1:]:
		if t == '0':
			f += '0'
			s += '0'
			continue
		if t == '1' and (not flag):
			f += '1'
			s += '0'
			flag = True
			continue
		if t == '2' and (not flag):
			f += '1'
			s += '1'
			continue
		if flag and t == '2':
			f += '0'
			s += '2'
			continue
		if flag and t == '1':
			f += '0'
			s += '1'
	print(int(f))
	print(int(s))


a = int(input())
for i in range(0, a):
	c = input()
	s = input()
	arr = []
	brr = []
	k = 0
	for i in s:
		if i == '2' and k == 0:
			arr.append('1')
			brr.append('1')
		elif i == '2' and k == 1:
			arr.append('0')
			brr.append('2')
		if i == '1' and k == 0:
			arr.append('1')
			brr.append('0')
			k = 1
		elif i == '1' and k == 1:
			arr.append('0')
			brr.append('1')
		if i == '0':
			arr.append('0')
			brr.append('0')
	print(''.join(arr))
	print(''.join(brr))


t = int(input())
for i in range(t):
	n = int(input())
	l = list(input())
	final1 = ''
	final2 = ''
	for j in range(n):
		if l[j] == '2':
			final1 += '1'
			final2 += '1'
		elif l[j] == '0':
			final1 += '0'
			final2 += '0'
		else:
			final1 += '1'
			final2 += '0'
			final1 += '0' * (n - j - 1)
			final2 += ''.join(l[j + 1:])
			break
	print(final1)
	print(final2)


from sys import stdin, stdout
st = lambda : list(stdin.readline().strip())
li = lambda : list(map(int, stdin.readline().split()))
mp = lambda : map(int, stdin.readline().split())
inp = lambda : int(stdin.readline())
pr = lambda n: stdout.write(str(n) + '\n')
mod = 1000000007

def solve():
	n = inp()
	s = input()
	ans = '1'
	ans2 = '1'
	i = 1
	while i < n:
		if s[i] == '1':
			ans += '1'
			ans2 += '0'
			ans += '0' * (n - len(ans))
			ans2 += s[i + 1:]
			print(ans)
			print(ans2)
			return
		elif s[i] == '0':
			ans += '0'
			ans2 += '0'
		else:
			ans += '1'
			ans2 += '1'
		i += 1
	print(ans)
	print(ans2)
for _ in range(inp()):
	solve()


t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	a = '1'
	b = '1'
	for j in range(1, n):
		if a == b:
			if x[j] == '0':
				a += '0'
				b += '0'
			elif x[j] == '1':
				a += '1'
				b += '0'
			elif x[j] == '2':
				a += '1'
				b += '1'
		elif x[j] == '0':
			a += '0'
			b += '0'
		elif x[j] == '1':
			a += '0'
			b += '1'
		elif x[j] == '2':
			a += '0'
			b += '2'
	print(a)
	print(b)


n = int(input())
for i in range(n):
	l = int(input())
	s = input()
	flag = False
	a = '1'
	b = '1'
	if l == 1:
		print(a)
		print(b)
	else:
		for j in range(1, l):
			if s[j] == '0':
				a += '0'
				b += '0'
			elif s[j] == '1' and flag == False:
				a += '1'
				b += '0'
				flag = True
			elif s[j] == '1' and flag == True:
				a += '0'
				b += '1'
			elif s[j] == '2' and flag == False:
				a += '1'
				b += '1'
			elif s[j] == '2' and flag == True:
				a += '0'
				b += '2'
		print(a)
		print(b)


import sys

def input():
	return sys.stdin.readline()[:-1]
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	(a, b) = ('', '')
	one = False
	for i in range(n):
		if s[i] == '0':
			a += '0'
			b += '0'
		elif s[i] == '1':
			if not one:
				a += '1'
				b += '0'
				one = True
			else:
				a += '0'
				b += '1'
		elif not one:
			a += '1'
			b += '1'
		else:
			a += '0'
			b += '2'
	print(a)
	print(b)


for j in range(int(input())):
	n = int(input())
	a = str(input())
	maxx = ''
	minn = ''
	count = 0
	check = 0
	keepindex = n + 1
	for i in range(n):
		if a[i] == '1' and check == 0:
			keepindex = i
			check = 1
			break
	if keepindex == n + 1:
		keepindex -= 1
		for i in range(keepindex):
			maxx += str(int(a[i]) // 2)
			minn += str(int(a[i]) // 2)
	else:
		for i in range(keepindex):
			maxx += str(int(a[i]) // 2)
			minn += str(int(a[i]) // 2)
		minn += '0' + a[keepindex + 1:]
		maxx += '1' + '0' * (n - keepindex - 1)
	print(maxx)
	print(minn)


for t in range(int(input())):
	n = int(input())
	s = input()
	(a, b) = ('', '')
	flag = False
	for i in range(n):
		if i == 0:
			a += '1'
			b += '1'
		elif s[i] == '2':
			if not flag:
				a += '1'
				b += '1'
			else:
				a += '2'
				b += '0'
		elif s[i] == '1':
			if not flag:
				a += '0'
				b += '1'
				flag = True
			else:
				a += '1'
				b += '0'
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


def solve():
	n = int(input())
	x = input()
	a = b = ''
	for (i, s) in enumerate(x):
		if s == '1':
			a += '1' + '0' * (n - i - 1)
			b += '0' + x[i + 1:]
			break
		elif s == '2':
			a += '1'
			b += '1'
		elif s == '0':
			a += '0'
			b += '0'
	print(a)
	print(b)

def main():
	t = int(input())
	for _ in range(t):
		solve()
main()


t = int(input())
for x in range(t):
	length = int(input())
	result = input()
	num1 = num2 = ''
	flag = 0
	for x in result:
		if x == '2':
			if flag == 0:
				num1 += '1'
				num2 += '1'
			else:
				num1 += '0'
				num2 += '2'
		elif x == '1':
			if flag == 0:
				num1 += '1'
				num2 += '0'
				flag = 1
			else:
				num1 += '0'
				num2 += '1'
		else:
			num1 += '0'
			num2 += '0'
	print(int(num1))
	print(int(num2))


import sys

def read_line():
	return sys.stdin.readline()[:-1]

def read_int():
	return int(sys.stdin.readline())

def read_int_line():
	return [int(v) for v in sys.stdin.readline().split()]
t = read_int()
for i in range(t):
	n = read_int()
	x = read_line()
	a = ''
	b = ''
	f = False
	for i in x:
		if i == '0':
			a += '0'
			b += '0'
		if i == '1':
			if not f:
				a += '1'
				b += '0'
			else:
				a += '0'
				b += '1'
			f = True
		if i == '2':
			if not f:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
	print(a)
	print(b)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	small = '1'
	big = '1'
	hasDiffer = False
	for i in range(1, len(s)):
		if s[i] == '2':
			if hasDiffer:
				small += '2'
				big += '0'
			else:
				small += '1'
				big += '1'
		elif s[i] == '0':
			small += '0'
			big += '0'
		elif s[i] == '1':
			if not hasDiffer:
				big += '1'
				small += '0'
				hasDiffer = True
			else:
				big += '0'
				small += '1'
	print(big)
	print(small)


for _ in range(int(input())):
	n = int(input())
	number = input()
	a = []
	b = []
	flag = 0
	for c in number:
		if c == '2':
			if flag == 0:
				a.append('1')
				b.append('1')
			else:
				b.append('2')
				a.append('0')
		elif c == '0':
			a.append('0')
			b.append('0')
		elif flag == 0:
			a.append('1')
			b.append('0')
			flag = 1
		else:
			a.append('0')
			b.append('1')
	print(''.join(a))
	print(''.join(b))


t = int(input())
for x in range(t):
	n = int(input())
	a = list(map(int, list(input())))
	b = []
	t = True
	for x in a:
		if t and x != 1:
			b.append(x // 2)
		elif t and x == 1:
			b.append(1)
			t = False
		else:
			b.append(0)
	c = []
	for x in range(n):
		c.append((a[x] - b[x]) % 3)
	print(''.join(map(str, b)))
	print(''.join(map(str, c)))


def ternary(x):
	(a, b) = ('', '')
	L = False
	for d in str(x):
		if not L:
			if d == '0':
				a += '0'
				b += '0'
			elif d == '2':
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '1'
				L = True
		elif d == '0':
			a += '0'
			b += '0'
		elif d == '2':
			a += '2'
			b += '0'
		else:
			a += '1'
			b += '0'
	return (a, b)
t = int(input())
for i in range(t):
	n = int(input())
	x = int(input())
	ans = ternary(x)
	print(ans[0])
	print(ans[1])


t = int(input())
for i in range(t):
	n = int(input())
	string = input()
	first = []
	second = []
	max_exists = False
	for i in range(len(string)):
		if string[i] == '2':
			if not max_exists:
				first.append('1')
				second.append('1')
			else:
				first.append('0')
				second.append('2')
		elif string[i] == '1':
			if not max_exists:
				first.append('1')
				second.append('0')
				max_exists = True
			else:
				first.append('0')
				second.append('1')
		else:
			first.append('0')
			second.append('0')
	print(''.join(first))
	print(''.join(second))


num1 = int(input())
for i in range(0, num1):
	len1 = int(input())
	x = input()
	a = ''
	b = ''
	for j in range(0, len(x)):
		if x[j] == '1':
			a = a + '1' + '0' * (len1 - j - 1)
			b = b + '0' + x[j + 1:]
			break
		else:
			a += str(int(x[j]) // 2)
			b += str(int(x[j]) // 2)
	print(a)
	print(b)


for _ in range(int(input())):
	n = int(input())
	s = input()
	a1 = ''
	a2 = ''
	for i in range(n):
		if s[i] == '1':
			a1 += '1' + '0' * (n - i - 1)
			a2 += '0' + s[i + 1:]
			break
		else:
			a1 += str(int(s[i]) // 2)
			a2 += str(int(s[i]) // 2)
	print(a1)
	print(a2)


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	al = []
	bl = []
	s = []
	for i in x:
		s.append(int(i))
	first = 0
	for i in range(n):
		if s[i] == 2:
			if first == 0:
				al.append('1')
				bl.append('1')
			else:
				al.append('0')
				bl.append('2')
		elif s[i] == 1:
			if first == 0:
				al.append('1')
				bl.append('0')
				first = 1
			else:
				al.append('0')
				bl.append('1')
		elif s[i] == 0:
			al.append('0')
			bl.append('0')
	ans1 = ''.join(al)
	ans2 = ''.join(bl)
	print(int(ans1))
	print(int(ans2))


def solve():
	a = '1'
	b = '1'
	bigger = -1
	for i in range(1, n):
		if x[i] == '0':
			a += '0'
			b += '0'
		elif x[i] == '1':
			if bigger == 1:
				a += '0'
				b += '1'
			elif bigger == -1:
				a += '1'
				b += '0'
				bigger = 1
			else:
				a += '1'
				b += '0'
				beforea = 1
				beforeb = 0
		elif bigger == 1:
			a += '0'
			b += '2'
		elif bigger == -1:
			a += '1'
			b += '1'
		else:
			a += '2'
			b += '0'
	return [a, b]
import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	res = solve()
	print(res[0])
	print(res[1])


n = int(input())
flag = 0
while n:
	len = input()
	num = int(input())
	res = [int(x) for x in str(num)]
	a = []
	b = []
	for i in res:
		if i == 1 and flag == 1:
			a.append(0)
			b.append(1)
		elif i == 2 and flag == 0:
			a.append(1)
			b.append(1)
		elif i == 1 and flag == 0:
			a.append(1)
			b.append(0)
			flag = 1
		elif i == 2 and flag == 1:
			a.append(0)
			b.append(2)
		elif i == 0:
			a.append(0)
			b.append(0)
	n -= 1
	flag = 0
	for j in a:
		print(j, end='')
	print()
	for k in b:
		print(k, end='')
	print()


from sys import stdin

def solve(n, x):
	flag = False
	(a, b) = ([], [])
	for ch in x:
		if flag == True:
			a.append('0')
			b.append(ch)
		elif (ord(ch) - ord('0')) % 2 == 1:
			a.append('1')
			b.append('0')
			flag = True
		else:
			k = chr((ord(ch) - ord('0')) // 2 + ord('0'))
			a.append(k)
			b.append(k)
	print('{}\n{}'.format(''.join(a), ''.join(b)))
input()
for (a, b) in zip(*[iter(stdin)] * 2):
	n = int(a)
	x = b.strip()
	solve(n, x)


import sys
sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline

def solve():
	t = int(rl())
	ans = []
	for _ in range(t):
		n = int(rl())
		digits = input()
		(a, b) = ('', '')
		for i in range(n):
			if digits[i] == '1':
				a += '1' + '0' * (n - i - 1)
				b += '0' + digits[i + 1:]
				break
			else:
				a += str(int(digits[i]) // 2)
				b += str(int(digits[i]) // 2)
		ans.append(a)
		ans.append(b)
	print(*ans, sep='\n')
solve()


import collections, heapq, itertools, math
rs = lambda : input()
ri = lambda : int(input())
rm = lambda : map(int, input().split())
ras = lambda : [x for x in input().split()]
rai = lambda : [int(x) for x in input().split()]

def solve(n, x):
	a = ''
	b = ''
	switch = False
	for (i, num) in enumerate(x):
		if i != 0 and x[i - 1] == '1':
			switch = True
		if num == '0':
			a += '0'
			b += '0'
		elif num == '1' and (not switch):
			a += '1'
			b += '0'
		elif num == '1' and switch:
			a += '0'
			b += '1'
		elif num == '2' and (not switch):
			a += '1'
			b += '1'
		else:
			a += '0'
			b += '2'
	return [a, b]
for t in range(1, 1 + ri()):
	n = rm()
	x = rs()
	(a, b) = solve(n, x)
	print('{}'.format(a))
	print('{}'.format(b))


num = int(input())
t = 0
while t < num:
	n = int(input())
	s = str(input())
	arr1 = []
	arr2 = []
	m = 0
	for i in range(n):
		if s[i] == '2':
			arr1.append(1)
			arr2.append(1)
		elif s[i] == '0':
			arr1.append(0)
			arr2.append(0)
		else:
			arr1.append(1)
			arr2.append(0)
			break
		m += 1
	m += 1
	while m < n:
		arr1.append(0)
		arr2.append(int(s[m]))
		m += 1
	for z in arr1:
		print(z, end='')
	print()
	for z in arr2:
		print(z, end='')
	print()
	t += 1


t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	nof1 = 0
	p1 = ''
	p2 = ''
	for j in range(n):
		if x[j] == '0':
			p1 += '0'
			p2 += '0'
		elif x[j] == '1':
			if nof1 == 0:
				p1 += '1'
				p2 += '0'
				nof1 = 1
			else:
				p1 += '0'
				p2 += '1'
		elif nof1 == 0:
			p1 += '1'
			p2 += '1'
		else:
			p1 += '0'
			p2 += '2'
	print(p1)
	print(p2)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	a = ''
	b = ''
	if '1' not in s:
		for i in range(n):
			if s[i] == '2':
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '0'
		print(a)
		print(b)
		continue
	x = s.index('1')
	for i in range(x):
		if s[i] == '2':
			a += '1'
			b += '1'
		else:
			a += '0'
			b += '0'
	a += '1'
	b += '0'
	for i in range(x + 1, n):
		if s[i] == '1':
			a += '0'
			b += '1'
		elif s[i] == '2':
			a += '0'
			b += '2'
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


t = int(input())
for _ in range(t):
	n = int(input())
	(a, b) = ('', '')
	larger = False
	for d in input():
		i = int(d)
		if larger:
			if i == 2:
				a += '0'
				b += '2'
			elif i == 1:
				a += '0'
				b += '1'
			elif i == 0:
				a += '0'
				b += '0'
		elif i == 2:
			a += '1'
			b += '1'
		elif i == 1:
			a += '1'
			b += '0'
			larger = True
		elif i == 0:
			a += '0'
			b += '0'
	print(a)
	print(b)


for _ in range(int(input())):
	n = int(input())
	x = input()
	ar = list(x)
	a = [0] * n
	b = [0] * n
	flag = 0
	for i in range(n):
		if flag == 0:
			if ar[i] == '1':
				flag = 1
				a[i] = '1'
				b[i] = '0'
			elif ar[i] == '2':
				a[i] = '1'
				b[i] = '1'
			else:
				a[i] = '0'
				b[i] = '0'
		else:
			a[i] = '0'
			b[i] = ar[i]
	print(*a, sep='')
	print(*b, sep='')


A = []
B = []
t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	a = [1]
	b = [1]
	f = 0
	for s in x[1:]:
		if f == 1:
			a.append(0)
			b.append(s)
			continue
		if s == '1':
			a.append(1)
			b.append(0)
			f = 1
			continue
		if s == '0':
			a.append(0)
			b.append(0)
		if s == '2':
			a.append(1)
			b.append(1)
	c = listToStr = ''.join(map(str, a))
	d = listToStr = ''.join(map(str, b))
	A.append(c)
	B.append(d)
for i in range(t):
	print(A[i])
	print(B[i])


import math
from collections import defaultdict
ml = lambda : map(int, input().split())
ll = lambda : list(map(int, input().split()))
ii = lambda : int(input())
ip = lambda : input()
t = ii()
for _ in range(t):
	x = ii()
	n = ip()
	lol = []
	yo = []
	f = 0
	flag = 0
	for i in n:
		if i == '0':
			if f == 0:
				lol.append('1')
				yo.append('2')
				flag = 1
				p = 1
			else:
				lol.append('0')
				yo.append('0')
		elif i == '1':
			if flag:
				lol.append('1')
				yo.append('0')
			else:
				lol.append('0')
				yo.append('1')
			flag = 1
		elif i == '2':
			if flag:
				lol.append('2')
				yo.append('0')
			else:
				lol.append('1')
				yo.append('1')
		f = 1
	print(''.join(lol))
	print(''.join(yo))


for _ in range(int(input())):
	n = int(input())
	num = input()
	a = b = ''
	f = 1
	for i in num:
		if f == 1:
			if i == '2':
				a += '1'
				b += '1'
			elif i == '1':
				a += '1'
				b += '0'
				f = 0
			else:
				a += '0'
				b += '0'
		else:
			a += '0'
			b += i
	print(a)
	print(b)


def main():
	d = int(input())
	for i in range(d):
		c = int(input())
		d = input()
		s = 0
		a1 = []
		a2 = []
		b = None
		for i in range(c):
			if d[i] == '0':
				a1.append('0')
				a2.append('0')
			elif d[i] == '1':
				if not b:
					a1.append('1')
					a2.append('0')
					b = True
				else:
					a2.append('1')
					a1.append('0')
			elif d[i] == '2':
				if b is None:
					a1.append('1')
					a2.append('1')
				else:
					a1.append('0')
					a2.append('2')
		print(''.join(a1))
		print(''.join(a2))
main()


for _ in range(int(input())):
	N = int(input())
	X = list(map(int, input()))
	A = [0] * N
	B = [0] * N
	F = 0
	for I in range(N):
		if X[I] == 2 and F == 0:
			A[I] = 1
			B[I] = 1
		elif X[I] == 1 and F == 0:
			A[I] = 1
			B[I] = 0
			F = 1
		elif X[I] == 2 and F == 1:
			A[I] = 0
			B[I] = 2
		elif X[I] == 1 and F == 1:
			A[I] = 0
			B[I] = 1
	print(''.join(map(str, A)))
	print(''.join(map(str, B)))


from sys import stdin, stdout
from collections import defaultdict, Counter
from functools import lru_cache
from math import gcd, floor, ceil

def ilist():
	return [int(x) for x in stdin.readline().strip().split(' ')]

def iint():
	return int(stdin.readline())

def istr():
	return stdin.readline()
t = iint()
for _ in range(t):
	n = iint()
	Str = istr()
	(str1, str2) = ('', '')
	change = False
	for x in Str:
		if x == '2':
			if change:
				str1 += '0'
				str2 += '2'
			else:
				str1 += '1'
				str2 += '1'
		if x == '1':
			if not change:
				str1 += '1'
				str2 += '0'
				change = True
			else:
				str1 += '0'
				str2 += '1'
		if x == '0':
			str1 += '0'
			str2 += '0'
	print(str1)
	print(str2)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	a = ['1']
	b = ['1']
	flag = True
	for i in range(1, n):
		if s[i] == '0':
			a.append('0')
			b.append('0')
		elif s[i] == '1':
			if flag:
				a.append('1')
				b.append('0')
				flag = False
			else:
				a.append('0')
				b.append(s[i])
		elif flag:
			a.append('1')
			b.append('1')
		else:
			a.append('0')
			b.append(s[i])
	print(''.join(a))
	print(''.join(b))


def main():
	T = int(input())
	for _ in range(T):
		N = int(input())
		S = input()
		(a, b) = ('', '')
		greater = -1
		for ch in S:
			if ch == '2':
				if greater == -1:
					a += '1'
					b += '1'
				elif greater == 1:
					a += '0'
					b += '2'
				else:
					a += '2'
					b += '0'
			elif ch == '1':
				if greater == -1:
					a += '0'
					b += '1'
				elif greater == 1:
					a += '0'
					b += '1'
				else:
					a += '1'
					b += '0'
			else:
				a += '0'
				b += '0'
			if greater == -1:
				if a[-1] > b[-1]:
					greater = 1
				elif a[-1] < b[-1]:
					greater = 2
		print(a + '\n' + b)
main()


def find(n, c):
	(x1, x2) = ('', '')
	for i in range(n):
		if c[i] == '0':
			x1 += '0'
			x2 += '0'
		elif c[i] == '2':
			x1 += '1'
			x2 += '1'
		elif c[i] == '1':
			x1 += '1'
			x2 += '0'
			break
	x1 += '0' * (len(c) - i - 1)
	x2 += c[i + 1:]
	return (x1, x2)
for _ in range(int(input())):
	n = int(input())
	c = int(input())
	(a, b) = find(n, str(c))
	print(a)
	print(b)


for _ in range(int(input())):
	a = int(input())
	b = input()
	upper = ''
	lower = ''
	state = 0
	for i in b:
		if i == '2' and state == 0:
			upper += '1'
			lower += '1'
			state = 0
		elif i == '1' and state == 0:
			upper += '1'
			lower += '0'
			state = 1
		elif i == '1' and state == 1:
			upper += '0'
			lower += '1'
			state = 1
		elif i == '0':
			upper += '0'
			lower += '0'
		elif i == '2' and state == 1:
			upper += '0'
			lower += '2'
			state = 1
	print(upper)
	print(lower)


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	x = x[1:]
	(a, b) = ('1', '1')
	k = 0
	for i in x:
		if i == '0':
			a += '0'
			b += '0'
		elif i == '2' and k == 0:
			a += '1'
			b += '1'
		elif i == '2' and k == 1:
			a += '0'
			b += '2'
		elif k == 0:
			a += '1'
			b += '0'
			k = 1
		else:
			a += '0'
			b += '1'
	print(a, b, sep='\n')


t = int(input())
for case in range(t):
	n = int(input())
	x = input()
	a = []
	b = []
	status = True
	for i in range(n):
		if x[i] == '2':
			if status:
				a.append('1')
				b.append('1')
			else:
				a.append('0')
				b.append('2')
		elif x[i] == '0':
			a.append('0')
			b.append('0')
		elif x[i] == '1':
			if status:
				a.append('1')
				b.append('0')
				status = False
			else:
				a.append('0')
				b.append('1')
	a = int(''.join(a))
	b = int(''.join(b))
	print(a)
	print(b)


def fun(n, number):
	ans = ['1', '1']
	number = str(number)
	equal = True
	(great, less) = (0, 0)
	i = 1
	while i < n:
		if equal:
			if number[i] == '0':
				ans[0] += '0'
				ans[1] += '0'
			elif number[i] == '1':
				ans[0] += '0'
				ans[1] += '1'
				great = 1
				less = 0
				equal = False
			else:
				ans[0] += '1'
				ans[1] += '1'
		elif number[i] == '0':
			ans[0] += '0'
			ans[1] += '0'
		elif number[i] == '1':
			ans[great] += '0'
			ans[less] += '1'
		else:
			ans[great] += '0'
			ans[less] += '2'
		i += 1
	return ans
for _ in range(int(input())):
	n = int(input())
	number = int(input())
	ans = fun(n, number)
	for i in ans:
		print(int(i))


def ternary():
	test = int(input())
	for _ in range(test):
		dig = int(input())
		n = input()
		ans1 = '1'
		ans2 = '1'
		for i in n[1:]:
			if i == '0':
				ans1 = ans1 + '0'
				ans2 = ans2 + '0'
			if i == '1':
				if ans1 == ans2:
					ans1 = ans1 + '0'
					ans2 = ans2 + '1'
				elif ans1 >= ans2:
					ans1 = ans1 + '0'
					ans2 = ans2 + '1'
				else:
					ans1 = ans1 + '1'
					ans2 = ans2 + '0'
			if i == '2':
				if ans1 == ans2:
					ans1 = ans1 + '1'
					ans2 = ans2 + '1'
				elif ans1 > ans2:
					ans1 = ans1 + '0'
					ans2 = ans1 + '2'
				else:
					ans1 = ans1 + '2'
					ans2 = ans2 + '0'
		print(ans1)
		print(ans2)
ternary()


def solve(c):
	a = ''
	b = ''
	isALarge = False
	for i in range(0, len(c)):
		if isALarge:
			if c[i] == '0':
				a += '0'
				b += '0'
			elif c[i] == '2':
				a += '0'
				b += '2'
			elif c[i] == '1':
				a += '0'
				b += '1'
		elif c[i] == '0':
			a += '0'
			b += '0'
		elif c[i] == '2':
			a += '1'
			b += '1'
		elif c[i] == '1':
			a += '1'
			b += '0'
			isALarge = True
	print(a)
	print(b)
t = int(input())
for i in range(0, t):
	input()
	c = input()
	solve(c)


for _ in range(int(input())):
	n = int(input())
	s = input()
	(a, b) = ('', '')
	if s[0] == '1':
		a += '2'
		b += '2'
	if s[0] == '2':
		a += '1'
		b += '1'
	for i in s[1:]:
		if i == '0':
			a += '0'
			b += '0'
		elif i == '2':
			a += '1'
			b += '1'
		else:
			a += '0'
			b += '1'
			break
	t = n - len(a)
	print(a + s[len(a):], b + '0' * t, sep='\n')


t = int(input())
for q in range(0, t):
	n = int(input())
	s = input()
	l = len(s)
	a = ''
	b = ''
	flag = False
	for i in range(0, l):
		if s[i] == '0':
			a += '0'
			b += '0'
		if s[i] == '1' and flag:
			a += '0'
			b += '1'
		if s[i] == '1' and (not flag):
			a += '1'
			b += '0'
			flag = True
		if s[i] == '2' and flag:
			a += '0'
			b += '2'
		if s[i] == '2' and (not flag):
			a += '1'
			b += '1'
	print(a)
	print(b)


for _ in range(int(input())):
	d = int(input())
	g = input()
	count = 0
	s = ''
	f = ''
	count = 0
	for i in range(len(g)):
		if g[i] == '1':
			if count == 0:
				s = s + '1'
				f = f + '0'
				count += 1
				i = i + 1
				while i < len(g):
					s = s + '0'
					if g[i] == '2':
						f = f + '2'
					elif g[i] == '1':
						f = f + '1'
					else:
						f = f + '0'
					i = i + 1
				break
		elif g[i] == '2':
			s = s + '1'
			f = f + '1'
		else:
			s = s + '0'
			f = f + '0'
	print(s)
	print(f)


def checker(n, s):
	(s1, s2, count) = ('1', '1', 0)
	for i in range(1, n):
		if s[i] == '2' and count == 0:
			s1 += '1'
			s2 += '1'
		elif s[i] == '1' and count == 0:
			count = 1
			s1 += '1'
			s2 += '0'
			continue
		elif s[i] == '0':
			s1 += '0'
			s2 += '0'
		elif count == 1:
			s1 += '0'
			s2 += s[i]
	return (s1, s2)
for _ in range(int(input())):
	m = int(input())
	t = input()
	print(*checker(m, t), sep='\n')


tests = int(input())

def solve():
	n = int(input())
	a = [0 for i in range(n)]
	b = [0 for i in range(n)]
	x = [0 for i in range(n)]
	x_str = input()
	for i in range(len(x_str)):
		x[i] = int(x_str[i])
	i = 0
	one = False
	for i in range(n):
		if x[i] == 2 and (not one):
			a[i] = 1
			b[i] = 1
		elif x[i] == 2 and one:
			a[i] = 0
			b[i] = 2
		elif x[i] == 1 and (not one):
			a[i] = 1
			b[i] = 0
			one = True
		elif x[i] == 1 and one:
			a[i] = 0
			b[i] = 1
		elif x[i] == 0:
			a[i] = 0
			b[i] = 0
	for i in range(n):
		print(a[i], end='')
	print()
	for i in range(n):
		print(b[i], end='')
	print()
while tests > 0:
	solve()
	tests -= 1


def solve(x, i, n):
	a = '1'
	b = '1'
	while i < n:
		if x[i] == '1':
			a += '1'
			b += '0'
			i += 1
			break
		elif x[i] == '0':
			a += '0'
			b += '0'
		else:
			a += '1'
			b += '1'
		i += 1
	while i < n:
		if x[i] == '1':
			a += '0'
			b += '1'
		elif x[i] == '0':
			a += '0'
			b += '0'
		else:
			a += '0'
			b += '2'
		i += 1
	return (a, b)
for t in range(int(input())):
	n = int(input())
	x = input()
	(a, b) = solve(x, 1, n)
	print(a)
	print(b)


import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)
t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	ok = False
	a = ''
	b = ''
	for j in x:
		if j == '0':
			a += '0'
			b += '0'
		elif j == '1':
			if not ok:
				ok = True
				a += '0'
				b += '1'
			else:
				a += '1'
				b += '0'
		elif not ok:
			a += '1'
			b += '1'
		else:
			a += '2'
			b += '0'
	print(a)
	print(b)


N = int(input())
for _ in range(N):
	n = int(input())
	number = input()
	one = False
	a = ''
	b = ''
	for i in range(n):
		if number[i] == '1' and (not one):
			one = True
			poz1 = i
	if not one:
		for i in range(n):
			if number[i] == '2':
				a = a + '1'
			else:
				a = a + '0'
		print(a)
		print(a)
	else:
		for i in range(n):
			if i < poz1:
				if number[i] == '2':
					a = a + '1'
					b = b + '1'
				else:
					a = a + '0'
					b = b + '0'
			elif i == poz1:
				a = a + '1'
				b = b + '0'
			elif i > poz1:
				a = a + '0'
				b = b + number[i]
		print(a)
		print(b)


n = int(input())
for i in range(n):
	a = int(input())
	b = int(input())
	c = b // 2
	d = b - c
	d = str(d)
	c = str(c)
	x = 0
	if d.count('0') + d.count('1') + d.count('2') == a and c.count('0') + c.count('1') + c.count('2') == a:
		print(c)
		print(d)
	else:
		for i in range(a):
			if int(d[i]) > 2:
				x = i - 1
				break
		h = list(d)
		for i in range(a):
			h[i] = int(h[i])
			if i == x:
				h[i] = h[i] + 1
			if i > x:
				h[i] = 0
		for i in range(a):
			h[i] = str(h[i])
		l = ''.join(h)
		l = int(l)
		print(l)
		print(b - l)


t = int(input())
for _ in range(t):
	n = int(input())
	c = int(input())
	a = ['1']
	b = ['1']
	cc = str(c)
	m = False
	for i in range(1, n):
		if cc[i] == '0':
			a.append('0')
			b.append('0')
		if cc[i] == '1':
			a.append('0' if m else '1')
			b.append('1' if m else '0')
			m = True
		elif cc[i] == '2':
			a.append('0' if m else '1')
			b.append('2' if m else '1')
	print(''.join(a))
	print(''.join(b))


import math
t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	f = -1
	a = ''
	b = ''
	for i in range(n):
		if f == -1:
			if x[i] == '1':
				f = 0
				a = a + '1'
				b = b + '0'
			elif x[i] == '2':
				a = a + '1'
				b = b + '1'
			else:
				a = a + '0'
				b = b + '0'
		else:
			a = a + '0'
			b = b + x[i]
	print(a)
	print(b)


t = int(input())
for o in range(t):
	n = int(input())
	x = input()
	x1 = int(x)
	flag = 1
	ans1 = []
	for i in list(x):
		if flag == 0:
			ans1.append('0')
		elif i == '2':
			ans1.append('1')
		elif i == '0':
			ans1.append('0')
		elif i == '1':
			ans1.append('1')
			flag = 0
	ans_1 = ''.join(ans1)
	ans_11 = int(ans_1)
	ans_2 = x1 - ans_11
	print(ans_11)
	print(ans_2)


ans_list = []
t = int(input())
for i in range(t):
	n = int(input())
	x = list(input())
	ans = []
	frag = False
	for g in range(n):
		if x[g] == '2':
			ans.append('1')
		elif x[g] == '0':
			ans.append('0')
		else:
			frag = True
			break
	if frag:
		ans_list.append([''.join(ans) + '1' + '0' * (n - g - 1), ''.join(ans + ['0'] + x[g + 1:])])
	else:
		ans_list.append([''.join(ans), ''.join(ans)])
for i in range(t):
	print(ans_list[i][0])
	print(ans_list[i][1])


import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		N = int(input())
		X = input().strip()
		a = []
		b = []
		f = False
		for x in X:
			if int(x) == 2:
				if f:
					a.append(0)
					b.append(2)
				else:
					a.append(1)
					b.append(1)
			elif int(x) == 0:
				a.append(0)
				b.append(0)
			elif f:
				a.append(0)
				b.append(1)
			else:
				a.append(1)
				b.append(0)
				f = True
		print(''.join(map(str, a)))
		print(''.join(map(str, b)))
main()


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
BUFSIZE = 8192
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		x = str(input())
		(a, b) = (['1'] * n, ['1'] * n)
		index = x.find('1')
		if index == -1:
			print(int(x) // 2)
			print(int(x) // 2)
			continue
		(a[index], b[index]) = ('0', '1')
		for j in range(1, len(x)):
			if x[j] == '2':
				if j < index:
					(a[j], b[j]) = ('1', '1')
				else:
					(a[j], b[j]) = ('2', '0')
			elif x[j] == '1':
				if j != index:
					(a[j], b[j]) = ('1', '0')
			else:
				(a[j], b[j]) = ('0', '0')
		print(''.join(a))
		print(''.join(b))
main()


for _ in range(int(input())):
	n = int(input())
	s = input()
	ans1 = '1'
	ans2 = '1'
	s = s[1:]
	first = False
	for i in range(len(s)):
		if not first and s[i] == '1':
			first = True
			ans1 += '1'
			ans2 += '0'
			continue
		if first:
			ans1 += '0'
			ans2 += s[i]
		elif s[i] == '2':
			ans1 += '1'
			ans2 += '1'
		else:
			ans1 += '0'
			ans2 += '0'
	print(ans1)
	print(ans2)


def solve(n, x):
	a = ''
	b = ''
	turn = True
	for i in x:
		if turn:
			if i == '2':
				a += '1'
				b += '1'
			elif i == '0':
				a += '0'
				b += '0'
			else:
				a += '1'
				b += '0'
				turn = False
		else:
			a += '0'
			b += i
	print(a)
	print(b)
t = int(input())
while t != 0:
	n = int(input())
	x = input()
	solve(n, x)
	t -= 1


inp = lambda cast=int: [cast(x) for x in input().split()]
printf = lambda s='', *args, **kwargs: print(str(s).format(*args), flush=True, **kwargs)
(t,) = inp()
for _ in range(t):
	(n,) = inp()
	(x,) = inp(str)
	i = 0
	(a, b) = ('', '')
	while i < n and x[i] == '2':
		a += '1'
		b += '1'
		i += 1
	done = False
	while i < n:
		if x[i] == '2':
			if done:
				a += '0'
				b += '2'
			else:
				a += '1'
				b += '1'
		elif x[i] == '1':
			if done:
				a += '0'
				b += '1'
			else:
				a += '1'
				b += '0'
				done = True
		elif x[i] == '0':
			a += '0'
			b += '0'
		i += 1
	print(a)
	print(b)


t = int(input())
for rep in range(t):
	n = int(input())
	x = list(map(int, list(input())))
	a = []
	b = []
	f = 0
	for i in range(n):
		if f == 0:
			if x[i] == 2:
				a.append('1')
				b.append('1')
			elif x[i] == 0:
				a.append('0')
				b.append('0')
			else:
				a.append('1')
				b.append('0')
				f = 1
		else:
			a.append('0')
			b.append(str(x[i]))
	print(''.join(a))
	print(''.join(b))


import sys
from random import choice, randint
inp = sys.stdin.readline
out = sys.stdout.write
flsh = sys.stdout.flush
sys.setrecursionlimit(10 ** 9)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def MI():
	return map(int, inp().strip().split())

def LI():
	return list(map(int, inp().strip().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]

def LI_():
	return [int(x) - 1 for x in inp().strip().split()]

def LF():
	return [float(x) for x in inp().strip().split()]

def LS():
	return inp().strip().split()

def I():
	return int(inp().strip())

def F():
	return float(inp().strip())

def S():
	return inp().strip()

def pf(s):
	return out(s + '\n')

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def main():
	t = I()
	l = []
	for _ in range(t):
		n = I()
		x = I()
		s = str(x)
		a = '1'
		b = '1'
		for i in range(1, len(s)):
			if s[i] == '1':
				if a <= b:
					a += '1'
					b += '0'
				else:
					a += '0'
					b += '1'
			elif s[i] == '0':
				a += '0'
				b += '0'
			elif a == b:
				a += '1'
				b += '1'
			elif a < b:
				a += '2'
				b += '0'
			else:
				a += '0'
				b += '2'
		print(a)
		print(b)
main()


for _ in range(int(input())):
	n = int(input())
	x = input()
	(a, b) = ([], [])
	good = True
	for i in x:
		if i == '2' and good:
			a.append('1')
			b.append('1')
		elif i == '2':
			a.append('0')
			b.append('2')
		elif i == '1' and good:
			good = False
			a.append('1')
			b.append('0')
		elif i == '1':
			a.append('0')
			b.append('1')
		else:
			a.append('0')
			b.append('0')
	print(''.join(a))
	print(''.join(b))


for _ in range(int(input())):
	n = int(input())
	x = input()
	a = ''
	b = ''
	j = False
	for i in range(len(x)):
		if x[i] == '2' and (not j):
			a += '1'
			b += '1'
		elif x[i] == '0':
			a += '0'
			b += '0'
		elif x[i] == '1' and (not j):
			a += '1'
			b += '0'
			j = True
		elif j:
			a += '0'
			b += x[i]
	print(a)
	print(b)


t = int(input())
ans = []
for x in range(t):
	n = int(input())
	x = input()
	a = ''
	b = ''
	k = 0
	for c in range(0, n):
		if x[c] == '2':
			a += '1'
			b += '1'
		elif x[c] == '1':
			a += '1'
			b += '0'
			k = c
			break
		else:
			a += '0'
			b += '0'
	if k > 0:
		for c in range(k + 1, n):
			if x[c] == '2':
				a += '0'
				b += '2'
			elif x[c] == '1':
				a += '0'
				b += '1'
			else:
				a += '0'
				b += '0'
	ans.append(a)
	ans.append(b)
for elem in ans:
	print(elem)


for ttt in range(int(input())):
	n = int(input())
	s = input()
	a = ''
	b = ''
	flag = 0
	for i in range(n):
		if s[i] == '0':
			a += '0'
			b += '0'
		elif s[i] == '2':
			if flag == 0:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += s[i]
		elif s[i] == '1':
			if flag == 0:
				a += '1'
				b += '0'
				flag = 1
			else:
				a += '0'
				b += s[i]
	print(a)
	print(b)


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	a = ''
	b = ''
	i = 0
	while i < n and (x[i] == '2' or x[i] == '0'):
		if x[i] == '2':
			a += '1'
			b += '1'
		elif x[i] == '0':
			a += '0'
			b += '0'
		i += 1
	if i < n and x[i] == '1':
		a += '1'
		b += '0'
	for j in range(i + 1, n):
		if x[j] == '1':
			a += '0'
			b += '1'
		elif x[j] == '2':
			a += '0'
			b += '2'
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


for _ in range(int(input())):
	n = int(input())
	s = input()
	l1 = []
	l2 = []
	flag = 0
	for i in s:
		if flag == 0:
			if i == '2':
				l1.append('1')
				l2.append('1')
			elif i == '1':
				l1.append('1')
				l2.append('0')
				flag = 1
			else:
				l1.append('0')
				l2.append('0')
		else:
			l1.append('0')
			l2.append(i)
	print(''.join(l1))
	print(''.join(l2))


t = int(input())
result = []
while t > 0:
	size = int(input())
	string = input()
	a = ''
	b = ''
	noMin = True
	for x in string:
		if noMin:
			if x == '2':
				a = a + '1'
				b = b + '1'
			if x == '0':
				a = a + '0'
				b = b + '0'
			if x == '1':
				a = a + '1'
				b = b + '0'
				noMin = False
		else:
			a = a + '0'
			b = b + x
	result.append([a, b])
	t = t - 1
for x in result:
	print(x[0])
	print(x[1])


for _ in range(int(input())):
	n = int(input())
	s = input()
	(ans, ans1) = ('', '')
	for i in range(n):
		if s[i] == '1':
			ans += '1' + '0' * (n - 1 - i)
			ans1 += '0' + s[i + 1:]
			break
		else:
			ans += str(int(s[i]) // 2)
			ans1 += str(int(s[i]) // 2)
	print(ans)
	print(ans1)


t = int(input())
for i in range(t):
	n = int(input())
	c = input()
	a = ''
	b = ''
	check = 0
	for j in range(n):
		if j == 0:
			a = a + '1'
			b = b + '1'
		elif c[j] == '0':
			a = a + '0'
			b = b + '0'
		elif c[j] == '1':
			if check == 0:
				a = a + '1'
				b = b + '0'
				check = 1
			else:
				a = a + '0'
				b = b + '1'
		elif check == 0:
			a = a + '1'
			b = b + '1'
		else:
			a = a + '0'
			b = b + '2'
	print(a)
	print(b)


t = int(input())
p = []
for _ in range(t):
	n = int(input())
	s = str(input())
	a = '1'
	b = '1'
	h = 1
	while True:
		if h >= len(s):
			break
		if s[h] == '0':
			a += '0'
			b += '0'
		elif s[h] == '1':
			a += '1'
			b += '0'
			break
		else:
			a += '1'
			b += '1'
		h += 1
	for i in range(h + 1, n):
		if s[i] == '0':
			a += '0'
			b += '0'
		if s[i] == '1':
			a += '0'
			b += '1'
		if s[i] == '2':
			a += '0'
			b += '2'
	print(a)
	print(b)


n = int(input())
for x in range(n):
	a = int(input())
	s = str(input())
	out_1 = ''
	out_2 = ''
	b_out = False
	for y in s:
		if y == '0':
			out_1 += '0'
			out_2 += '0'
		elif y == '2':
			if b_out == False:
				out_1 += '1'
				out_2 += '1'
			else:
				out_1 += '0'
				out_2 += '2'
		elif b_out == False:
			out_1 += '1'
			out_2 += '0'
			b_out = True
		else:
			out_1 += '0'
			out_2 += '1'
	print(out_1)
	print(out_2)


T = int(input())
while T:
	n = int(input())
	s = input()
	(a, b) = ('', '')
	flag = True
	for c in s:
		if not flag:
			a += '0'
			b += c
		elif c == '0':
			a += '0'
			b += '0'
		elif c == '1':
			a += '1'
			b += '0'
			flag = False
		elif c == '2':
			a += '1'
			b += '1'
	print(a)
	print(b)
	T -= 1


for tc in range(int(input())):
	n = int(input())
	s = input()
	ch = 0
	a = ''
	b = ''
	for c in s:
		if c == '2':
			if ch:
				a += '0'
				b += '2'
			else:
				a += '1'
				b += '1'
		elif c == '1':
			if ch:
				a += '0'
				b += '1'
			else:
				ch = 1
				a += '1'
				b += '0'
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


t = int(input())
for i in range(t):
	a = int(input())
	b = input()
	b = b[1:]
	lower = '1'
	higher = '1'
	i = 0
	while i < len(b):
		if b[i] == '1':
			break
		if b[i] == '0':
			lower += '0'
			higher += '0'
		if b[i] == '2':
			lower += '1'
			higher += '1'
		i += 1
	if i == len(b):
		print(lower)
		print(higher)
	else:
		lower += '0'
		higher += '1'
		b = b[i + 1:]
		i = 0
		while i < len(b):
			if b[i] == '1':
				lower += '1'
				higher += '0'
			if b[i] == '0':
				lower += '0'
				higher += '0'
			if b[i] == '2':
				lower += '2'
				higher += '0'
			i += 1
		print(lower)
		print(higher)


import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *

class Scanner:

	@staticmethod
	def int():
		return int(sys.stdin.readline().rstrip())

	@staticmethod
	def string():
		return sys.stdin.readline().rstrip()

	@staticmethod
	def map_int():
		return [int(x) for x in Scanner.string().split()]

	@staticmethod
	def string_list(n):
		return [input() for i in range(n)]

	@staticmethod
	def int_list_list(n):
		return [Scanner.map_int() for i in range(n)]

	@staticmethod
	def int_cols_list(n):
		return [int(input()) for i in range(n)]

class Math:

	@staticmethod
	def gcd(a, b):
		if b == 0:
			return a
		return Math.gcd(b, a % b)

	@staticmethod
	def lcm(a, b):
		return a * b // Math.gcd(a, b)

	@staticmethod
	def divisor(n):
		res = []
		i = 1
		for i in range(1, int(n ** 0.5) + 1):
			if n % i == 0:
				res.append(i)
				if i != n // i:
					res.append(n // i)
		return res

	@staticmethod
	def round_up(a, b):
		return -(-a // b)

	@staticmethod
	def is_prime(n):
		if n < 2:
			return False
		if n == 2:
			return True
		if n % 2 == 0:
			return False
		d = int(n ** 0.5) + 1
		for i in range(3, d + 1, 2):
			if n % i == 0:
				return False
		return True

class PriorityQueue:

	def __init__(self, l=[]):
		self.q = l
		heapq.heapify(self.q)
		return

	def push(self, n):
		heapq.heappush(self.q, n)
		return

	def pop(self):
		return heapq.heappop(self.q)

def pop_count(x):
	x = x - (x >> 1 & 6148914691236517205)
	x = (x & 3689348814741910323) + (x >> 2 & 3689348814741910323)
	x = x + (x >> 4) & 1085102592571150095
	x = x + (x >> 8)
	x = x + (x >> 16)
	x = x + (x >> 32)
	return x & 127
MOD = int(1000000000.0) + 7
INF = int(1000000000000000.0)

def main():
	T = Scanner.int()
	for _ in range(T):
		N = Scanner.int()
		X = Scanner.string()
		(a, b) = ('0', '0')
		for n in range(N):
			if a > b:
				a += '0'
				b += X[n]
			elif X[n] == '0':
				a += '0'
				b += '0'
				pass
			elif X[n] == '1':
				a += '1'
				b += '0'
			else:
				a += '1'
				b += '1'
		print(a[1:])
		print(b[1:])
main()


for _ in range(int(input())):
	n = int(input())
	s = input()
	s1 = ''
	s2 = ''
	is_1 = True
	for i in s:
		if is_1:
			if i == '2':
				s1 += '1'
				s2 += '1'
			elif i == '0':
				s1 += '0'
				s2 += '0'
			else:
				s1 += '1'
				s2 += '0'
				is_1 = False
		else:
			s1 += '0'
			s2 += i
	print(s1)
	print(s2)


from collections import defaultdict
t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	a = []
	b = []
	flagA = False
	for i in s:
		if flagA:
			a.append('0')
			b.append(i)
		elif i == '2':
			a.append('1')
			b.append('1')
		elif i == '0':
			a.append('0')
			b.append('0')
		elif i == '1':
			a.append('1')
			b.append('0')
			flagA = True
	print(''.join(a))
	print(''.join(b))


for _ in range(int(input())):
	n = int(input())
	c = input()
	(a, b) = ('1', '1')
	isAdone = False
	for i in range(1, n):
		if isAdone:
			b += c[i]
			a += '0'
		elif c[i] == '0':
			a += '0'
			b += '0'
		elif c[i] == '2':
			a += '1'
			b += '1'
		else:
			a += '1'
			b += '0'
			isAdone = True
	print(a)
	print(b)


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		s = input()
		one = 0
		a = ''
		b = ''
		if s.count('1') == 0:
			print(int(s) // 2)
			print(int(s) // 2)
		else:
			for i in range(n):
				if s[i] == '1':
					one = i
					break
			for i in range(one + 1):
				if s[i] == '2':
					a += '1'
					b += '1'
				elif s[i] == '1':
					a += '1'
					b += '0'
				else:
					a += '0'
					b += '0'
			a += '0' * (n - one - 1)
			b += s[one + 1:]
			print(a)
			print(b)
main()


for _ in range(int(input())):
	n = int(input())
	a = list(input())
	x = []
	y = []
	flag = False
	for i in range(n):
		if a[i] == '2':
			x.append('1')
			y.append('1')
		elif a[i] == '0':
			x.append('0')
			y.append('0')
		elif a[i] == '1':
			x.append('1')
			y.append('0')
			x = x + ['0'] * (n - i - 1)
			y = y + a[i + 1:]
			break
	print(''.join(x))
	print(''.join(y))


t = int(input())
for i in range(t):
	n = int(input())
	s = input().strip()
	a = ''
	b = ''
	j = 0
	while j < n:
		if s[j] == '1':
			a = a + '1'
			b = b + '0'
			j = j + 1
			break
		else:
			v = int(s[j]) // 2
			a = a + str(v)
			b = b + str(v)
		j = j + 1
	a = a + '0' * (n - j)
	b = b + s[j:]
	print(a)
	print(b)


n = int(input())
for i in range(n):
	v1 = v2 = 0
	a = b = ''
	l = int(input())
	x = input()
	for i in x:
		if i == '0':
			a += '0'
			b += '0'
		elif i == '1':
			if v1 > v2:
				a += '0'
				b += '1'
			else:
				b += '0'
				a += '1'
				v1 = 1
		elif i == '2':
			if v1 == v2:
				a += '1'
				b += '1'
			elif v1 > v2:
				a += '0'
				b += '2'
			elif v1 < v2:
				b += '0'
				a += '2'
	print(int(a))
	print(int(b))


def find(ss):
	f = False
	one = ''
	two = ''
	for i in ss:
		if f:
			if i == '2':
				one += '0'
				two += '2'
			elif i == '1':
				one += '0'
				two += '1'
				f = True
			elif i == '0':
				one += '0'
				two += '0'
		elif i == '2':
			one += '1'
			two += '1'
		elif i == '1':
			one += '1'
			two += '0'
			f = True
		elif i == '0':
			one += '0'
			two += '0'
	return (one, two)
for i in range(int(input())):
	n = int(input())
	ss = input()
	ans = find(ss)
	print(ans[0])
	print(ans[1])


x = int(input())
while x > 0:
	x -= 1
	n = int(input())
	s = str(input())
	n1 = ''
	n2 = ''
	i = 0
	while i < n and s[i] != '1':
		n1 += str(int(int(s[i]) / 2))
		i += 1
	n2 = n1
	if i < n:
		n1 += '0'
		n2 += '1'
		i += 1
	while i < n:
		n1 += str(int(s[i]))
		n2 += '0'
		i += 1
	print(n1)
	print(n2)


t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	which = 0
	a = []
	b = []
	for j in range(n):
		if x[j] == '0':
			a.append(0)
			b.append(0)
		elif x[j] == '1':
			if which == 0:
				a.append(1)
				b.append(0)
				which = 1
			elif which == 1:
				a.append(0)
				b.append(1)
			else:
				a.append(1)
				b.append(0)
		elif x[j] == '2':
			if which == 0:
				a.append(1)
				b.append(1)
			elif which == 1:
				a.append(0)
				b.append(2)
			else:
				a.append(2)
				b.append(0)
	for val in a:
		print(val, end='')
	print()
	for val in b:
		print(val, end='')
	print()


for _ in range(int(input())):
	n = int(input())
	s = input()
	(an, an1) = ('', '')
	for i in range(n):
		if s[i] == '1':
			an += '1' + '0' * (n - 1 - i)
			an1 += '0' + s[i + 1:]
			break
		else:
			an += str(int(s[i]) // 2)
			an1 += str(int(s[i]) // 2)
	print(an)
	print(an1)


import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
	n = int(input())
	s = input().strip()
	ANSA = []
	ANSB = []
	oneflag = 0
	for x in s:
		if oneflag == 0:
			if x == '2':
				ANSA.append('1')
				ANSB.append('1')
			elif x == '0':
				ANSA.append('0')
				ANSB.append('0')
			else:
				ANSA.append('1')
				ANSB.append('0')
				oneflag = 1
		elif x == '2':
			ANSA.append('0')
			ANSB.append('2')
		elif x == '0':
			ANSA.append('0')
			ANSB.append('0')
		else:
			ANSA.append('0')
			ANSB.append('1')
	print(''.join(ANSA))
	print(''.join(ANSB))


t = int(input())
for i in range(t):
	n = int(input())
	string = input()
	a = [None] * n
	b = [None] * n
	for i in range(n):
		if string[i] == '1':
			a[i] = 1
			b[i] = 0
			for j in range(i + 1, n):
				a[j] = 0
				b[j] = string[j]
			break
		else:
			if string[i] == '0':
				a[i] = 0
				b[i] = 0
			if string[i] == '2':
				a[i] = 1
				b[i] = 1
	print(''.join(map(str, a)))
	print(''.join(map(str, b)))


t = int(input())
for _ in range(t):
	n = int(input())
	r = list(input())
	a = [0 for x in range(n)]
	b = [0 for x in range(n)]
	flag = 0
	for i in range(n):
		if r[i] == '2':
			if not flag:
				a[i] = 1
				b[i] = 1
			else:
				b[i] = 2
		elif r[i] == '1':
			if not flag:
				flag = 1
				a[i] = 1
			else:
				b[i] = 1
	a = ''.join(list(map(str, a)))
	b = ''.join(list(map(str, b)))
	print(a)
	print(b)


t = int(input())
while t > 0:
	n = int(input())
	samp = input()
	a = ''
	b = ''
	flag = 0
	for i in range(0, n):
		if flag == 0 and samp[i] == '2':
			a += '1'
			b += '1'
		elif flag == 1 and samp[i] == '2':
			a += '0'
			b += '2'
		elif flag == 0 and samp[i] == '1':
			a += '1'
			b += '0'
			flag = 1
		elif flag == 1 and samp[i] == '1':
			a += '0'
			b += '1'
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)
	t -= 1


t = int(input())
for k in range(t):
	a = ['1']
	b = ['1']
	n = int(input())
	l = str(input())
	l = list(l)
	flag = 0
	for i in range(1, n):
		if flag == 0:
			if l[i] == '2':
				a.append('1')
				b.append('1')
			elif l[i] == '1':
				a.append('1')
				b.append('0')
				flag = 1
			elif l[i] == '0':
				a.append('0')
				b.append('0')
		elif flag == 1:
			if l[i] == '0':
				a.append('0')
				b.append('0')
			else:
				a.append('0')
				b.append(l[i])
	print(*a, sep='')
	print(*b, sep='')


for _ in range(int(input())):
	n = int(input())
	x = input()
	l = [0] * n
	l1 = [0] * n
	l2 = [0] * n
	fg = 0
	for i in range(n):
		l[i] = int(x[i])
	for i in range(n):
		if fg == 0:
			if l[i] == 2:
				l1[i] = 1
				l2[i] = 1
			elif l[i] == 1:
				l1[i] = 1
				l2[i] = 0
				fg = 1
		else:
			l2[i] = l[i]
	s1 = ''
	s2 = ''
	for i in l1:
		s1 += str(i)
	for i in l2:
		s2 += str(i)
	print(s1)
	print(s2)


for _ in range(int(input())):
	(size, array) = (int(input()), input())
	if size == 1:
		print(1, 1)
	else:
		(stop, a, b) = (1, '1', '1')
		for c in array[1:]:
			stop += 1
			if c == '1':
				a += '1'
				b += '0'
				break
			elif c == '2':
				a += '1'
				b += '1'
			else:
				a += c
				b += c
		print(a + '0' * (size - stop), b + array[stop:])


t = int(input())
while t:
	n = int(input())
	s = input()
	a = ''
	b = ''
	flaga = 0
	flagb = 0
	for i in range(n):
		if s[i] == '1' and flaga == 0:
			a += '0'
			b += '1'
			flaga = 1
		elif s[i] == '1' and flaga == 1:
			a += '1'
			b += '0'
			flagb = 1
		elif s[i] == '0':
			a += '0'
			b += '0'
		elif s[i] == '2' and flaga == 1:
			a += '2'
			b += '0'
			flagb = 1
		elif s[i] == '2' and flagb == 1:
			a += '0'
			b += '2'
			flaga = 1
		elif s[i] == '2':
			a += '1'
			b += '1'
	print(a)
	print(b)
	t -= 1


import sys, math, cmath
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
t = 1
t = inp()
for tt in range(t):
	n = inp()
	s = insr()
	qq = 2
	q = ''
	w = ''
	for i in range(len(s)):
		qw = int(s[i])
		if qw == 0:
			q = q + '0'
			w = w + '0'
		elif qw == 1:
			if qq == 0:
				q = q + '0'
				w = w + '1'
				if qq == 2:
					qq = 1
			else:
				q = q + '1'
				w = w + '0'
				if qq == 2:
					qq = 0
		elif qq == 0:
			q = q + '0'
			w = w + '2'
		elif qq == 1:
			q = q + '2'
			w = w + '0'
		else:
			q = q + '1'
			w = w + '1'
	print(q)
	print(w)


def solve(n, x):
	a = '1'
	b = '1'
	flag = False
	for i in range(1, n):
		if x[i] == '2':
			if flag == False:
				a += '1'
				b += '1'
			else:
				a += '2'
				b += '0'
		elif x[i] == '0':
			a += '0'
			b += '0'
		elif x[i] == '1':
			if flag == False:
				a += '0'
				b += '1'
			else:
				a += '1'
				b += '0'
			flag = True
	return print(a + '\n' + b)
t = int(input())
for _n in range(0, t):
	n = int(input())
	x = input()
	solve(n, x)


t = int(input())
while t:
	t -= 1
	n = int(input())
	s = input()
	ma = ''
	mi = ''
	if '1' not in s:
		ma = s.replace('2', '1')
		print(ma, ma, sep='\n')
	else:
		k = s.index('1')
		ma = s[:k].replace('2', '1')
		mi = ma
		ma += '1'
		mi += '0'
		ma += '0' * (n - 1 - k)
		mi += s[k + 1:]
		print(ma, mi, sep='\n')


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_int = lambda : int(sys.stdin.readline())
for _ in range(get_int()):
	n = get_int() - 1
	s = get_string()
	num1 = '1'
	num2 = '1'
	turn = 0
	i = 0
	while i < n:
		i += 1
		c = s[i]
		if turn == 0:
			if c == '2':
				num1 += '1'
				num2 += '1'
			elif c == '0':
				num1 += '0'
				num2 += '0'
			elif turn == 0:
				num1 += '1'
				num2 += '0'
				turn = 1
		elif c == '2':
			num1 += '0'
			num2 += '2'
		elif c == '0':
			num1 += '0'
			num2 += '0'
		else:
			num2 += '1'
			num1 += '0'
	print(num1)
	print(num2)


def solve():
	n = int(input())
	s = input()
	(ans1, ans2, f) = ('1', '1', True)
	for i in range(1, len(s)):
		if s[i] == '2' and f:
			ans1 += '1'
			ans2 += '1'
		elif s[i] == '2' and (not f):
			ans1 += '0'
			ans2 += '2'
		elif s[i] == '1' and f:
			ans1 += '1'
			ans2 += '0'
			f = False
		elif s[i] == '1' and (not f):
			ans1 += '0'
			ans2 += '1'
		elif s[i] == '0':
			ans1 += '0'
			ans2 += '0'
	print(ans1)
	print(ans2)

def main():
	t = int(input())
	for i in range(0, t):
		solve()
main()


def split(w):
	return [c for c in w]
n = int(input())
for i in range(n):
	t = int(input())
	a = input()
	e = split(a)
	c = ''
	d = ''
	u = '5'
	v = '5'
	jk = 0
	for j in range(t):
		if j == 0:
			c += '1'
			d += '1'
			u = '1'
			v = '1'
		elif u == v and jk == 0:
			if e[j] == '2':
				c += '1'
				d += '1'
				u = '1'
				v = '1'
			elif e[j] == '1':
				c += '1'
				d += '0'
				u = '1'
				v = '0'
			else:
				c += '0'
				d += '0'
				u = '0'
				v = '0'
		else:
			jk = 1
			if e[j] == '2':
				c += '0'
				d += '2'
			elif e[j] == '1':
				c += '0'
				d += '1'
			else:
				c += '0'
				d += '0'
	print(c)
	print(d)


for _ in range(int(input())):
	n = int(input())
	x = list(input())
	a = ''
	b = ''
	yes = 0
	for i in range(n):
		if yes == 0 and x[i] == '2':
			a += '1'
			b += '1'
		elif yes == 0 and x[i] == '1':
			a += '1'
			b += '0'
			yes = 1
		elif yes == 0 and x[i] == '0':
			b += '0'
			a += '0'
		elif x[i] == '2':
			b += '2'
			a += '0'
		elif x[i] == '1':
			a += '0'
			b += '1'
		elif x[i] == '0':
			a += '0'
			b += '0'
	print(a)
	print(b)


for _ in range(int(input())):
	n = int(input())
	k = input()
	a = b = ''
	c = 0
	i = 0
	while i < n and k[i] != '1':
		if k[i] == '2':
			a += '1'
			b += '1'
		else:
			a += '0'
			b += '0'
		i += 1
	if i < n:
		b += '1'
		a += '0'
		i += 1
	while i < n:
		if k[i] == '1':
			a += '1'
		elif k[i] == '2':
			a += '2'
		else:
			a += '0'
		b += '0'
		i += 1
	print(a, b, sep='\n')


t = int(input())
while t:
	n = int(input())
	x = input().rstrip()
	T = True
	pos = []
	for i in range(len(x)):
		if x[i] == '0':
			pos.append(('0', '0'))
		elif x[i] == '1':
			pos.append(('1', '0'))
			T = False
		elif T:
			pos.append(('1', '1'))
		else:
			pos.append(('2', '0'))
	a = ''
	b = ''
	T = True
	for i in pos:
		if (i[0] == '1' or i[0] == '2') and i[1] == '0':
			if T:
				a += i[0]
				b += i[1]
				T = False
			else:
				a += i[1]
				b += i[0]
		else:
			a += i[0]
			b += i[0]
	print(a)
	print(b)
	t -= 1


from sys import stdin, stdout
import math
n = int(stdin.readline())
for i in range(n):
	t = int(stdin.readline())
	ar = stdin.readline()
	str1 = []
	str2 = []
	encountered = 0
	for j in ar[:-1]:
		if encountered:
			str1.append('0')
			str2.append(j)
		elif j == '1':
			encountered = 1
			str1.append('1')
			str2.append('0')
		else:
			str1.append(str(int(int(j) / 2)))
			str2.append(str(int(int(j) / 2)))
	stdout.write(''.join(str1) + '\n')
	stdout.write(''.join(str2) + '\n')


for i in range(int(input())):
	n = int(input())
	x = input()
	num1 = '1'
	num2 = '1'
	flag = False
	for i in range(1, n):
		if x[i] == '0':
			num1 += '0'
			num2 += '0'
		elif x[i] == '1':
			if not flag:
				num1 += '1'
				num2 += '0'
				flag = True
			else:
				num1 += '0'
				num2 += '1'
		elif not flag:
			num1 += '1'
			num2 += '1'
		else:
			num1 += '0'
			num2 += '2'
	print(num1)
	print(num2)


t = int(input())
for _ in range(t):
	n = int(input())
	x = input().strip()
	mode = False
	ans1 = ''
	ans2 = ''
	for i in range(n):
		d = x[i]
		if not mode:
			if d == '2':
				ans1 += '1'
				ans2 += '1'
			elif d == '0':
				ans1 += '0'
				ans2 += '0'
			else:
				ans1 += '1'
				ans2 += '0'
				mode = True
		else:
			ans1 += '0'
			ans2 += d
	print(ans1)
	print(ans2)


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	a = ['0' for _ in range(n)]
	b = ['0' for _ in range(n)]
	idx = n
	for i in range(n):
		if x[i] == '1':
			idx = i
			a[i] = '1'
			b[i] = '0'
			break
		elif x[i] == '2':
			a[i] = '1'
			b[i] = '1'
	for i in range(idx + 1, n):
		if x[i] == '1':
			b[i] = '1'
		elif x[i] == '2':
			b[i] = '2'
	a = ''.join(a)
	b = ''.join(b)
	print(a)
	print(b)


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		x = input()
		a = b = '1'
		killed = False
		for i in range(1, n):
			c = x[i]
			if c == '0':
				a += '0'
				b += '0'
			elif c == '1':
				if killed:
					a += '1'
					b += '0'
				else:
					killed = True
					a += '0'
					b += '1'
			elif c == '2':
				if killed:
					a += '2'
					b += '0'
				else:
					a += '1'
					b += '1'
		print(a)
		print(b)
main()


t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	l = []
	p = []
	mx = -1
	ind = 0
	for v in x:
		ind += 1
		if v == '2':
			if ind == 1 or mx == -1:
				l.append('1')
				p.append('1')
			else:
				l.append('0')
				p.append('2')
		elif v == '1':
			if mx == -1:
				mx = 0
				l.append('1')
				p.append('0')
			else:
				l.append('0')
				p.append('1')
		else:
			l.append('0')
			p.append('0')
	print(''.join(l))
	print(''.join(p))


t = int(input())
for _ in range(t):
	n = int(input())
	x = list(map(int, input()))
	a_larger = False
	a = []
	b = []
	for d in x:
		if a_larger:
			a += ['0']
			b += [str(d)]
		elif d == 0:
			a += ['0']
			b += ['0']
		elif d == 1:
			a += ['1']
			b += ['0']
			a_larger = True
		else:
			a += ['1']
			b += ['1']
	print(''.join(a))
	print(''.join(b))


import sys

class CTernaryXOR:

	def solve(self):
		for _ in range(int(input())):
			n = int(input())
			x = input().strip()
			a = ''
			b = ''
			flag = None
			smaller = None
			for i in range(n):
				if x[i] == '2':
					if smaller is None:
						a += '1'
						b += '1'
					else:
						a += '0'
						b += '2'
				elif x[i] == '0':
					a += '0'
					b += '0'
				elif smaller is None:
					a += '1'
					b += '0'
					smaller = 0
				else:
					a += '0'
					b += '1'
			print(a)
			print(b)
solver = CTernaryXOR()
input = sys.stdin.readline
solver.solve()


t = int(input())
for _ in range(t):
	n = int(input())
	c = list(input())
	a = '1'
	b = '1'
	flag = 2
	for x in c[1:]:
		if x == '2' and flag == 2:
			a += '1'
			b += '1'
		elif x == '2' and flag == 1:
			a += '0'
			b += '2'
		if x == '1' and flag == 1:
			a += '0'
			b += '1'
		elif x == '0':
			a += '0'
			b += '0'
		if x == '1' and flag == 2:
			a += '1'
			b += '0'
			flag = 1
	print(a)
	print(b)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def solve(n, x):
	(a, b) = ([0 for i in range(n)], [0 for i in range(n)])
	switch = True
	for i in range(n):
		if x[i] == '0':
			(a[i], b[i]) = (0, 0)
		elif x[i] == '1':
			if i == 0:
				(a[i], b[i]) = (2, 2)
			elif switch:
				(a[i], b[i]) = (0, 1)
				switch = False
			else:
				(a[i], b[i]) = (1, 0)
		elif switch:
			(a[i], b[i]) = (1, 1)
		else:
			(a[i], b[i]) = (2, 0)
	return (a, b)

def output():
	t = inp()
	for i in range(t):
		n = inp()
		x = insr()
		(a, b) = solve(n, x)
		print(''.join(map(str, a)))
		print(''.join(map(str, b)))
output()


n = int(input())
for i in range(n):
	n = int(input())
	s = input()
	a = ''
	b = ''
	q = 0
	for j in range(n):
		if s[j] == '0':
			a += '0'
			b += '0'
		elif s[j] == '2' and q == 0:
			a += '1'
			b += '1'
		elif s[j] == '2' and q == 1:
			a += '0'
			b += '2'
		elif q == 0:
			a += '1'
			b += '0'
			q = 1
		else:
			a += '0'
			b += '1'
	print(a)
	print(b)


for _ in range(int(input())):
	n = int(input())
	x = input()
	arr = []
	brr = []
	f = 0
	for i in range(n):
		if x[i] == '2' and f == 0:
			arr.append('1')
			brr.append('1')
		elif x[i] == '1' and f == 0:
			arr.append('1')
			brr.append('0')
			f = 1
		elif x[i] == '1' and f == 1:
			arr.append('0')
			brr.append('1')
		elif x[i] == '2' and f == 1:
			arr.append('0')
			brr.append('2')
		else:
			arr.append('0')
			brr.append('0')
	ans = ''
	for i in range(n):
		ans += arr[i]
	print(ans)
	ans = ''
	for i in range(n):
		ans += brr[i]
	print(ans)


def func(n, x):
	a = ''
	b = ''
	f = 0
	l = list(map(int, x))
	for i in l:
		if f == 0:
			if i == 2:
				a += '1'
				b += '1'
			elif i == 0:
				a += '0'
				b += '0'
			else:
				f = 1
				a += '1'
				b += '0'
		else:
			a += '0'
			b += str(i)
	print(a)
	print(b)
for _ in range(int(input())):
	n = int(input())
	x = input()
	func(n, x)


from collections import Counter
from collections import defaultdict
import math
t = int(input())
for _ in range(0, t):
	(lis, mis) = (list(), list())
	n = input()
	n = int(n)
	x = input()
	x = list(x)
	x = list(map(int, x))
	s1 = x[0]
	if s1 > 1:
		mis.append(1)
		lis.append(1)
		g = 1
		i = g
		while i < n:
			if x[i] == 0:
				lis.append(0)
				mis.append(0)
			elif x[i] == 2:
				lis.append(1)
				mis.append(1)
			elif x[i] == 1:
				lis.append(1)
				mis.append(0)
				i += 1
				break
			i = i + 1
		while i < n:
			k = 0
			lis.append(k)
			mis.append(x[i])
			i = i + 1
	lis = map(str, lis)
	mis = map(str, mis)
	s1 = ''.join(list(lis))
	s2 = ''.join(list(mis))
	print(s1)
	print(s2)


def solution():
	test = int(input())
	for i in range(0, test):
		n = int(input())
		x = int(input())
		digits = [int(x) for x in str(x)]
		a = ''
		b = ''
		flag = False
		for num in digits:
			if num == 2:
				if flag == False:
					a += '1'
					b += '1'
				else:
					a += '0'
					b += '2'
			elif num == 1:
				if flag == False:
					flag = True
					a += '1'
					b += '0'
				else:
					a += '0'
					b += '1'
			elif num == 0:
				a += '0'
				b += '0'
		print(a)
		print(b)
solution()


import sys
t = int(input())
for i in range(t):
	n = int(sys.stdin.readline().strip())
	x = sys.stdin.readline().strip()
	flag = False
	a = '1'
	b = '1'
	for j in range(1, n):
		dig = x[j]
		if dig == '0':
			a += '0'
			b += '0'
			continue
		if flag:
			if dig == '2':
				a += '0'
				b += '2'
			else:
				a += '0'
				b += '1'
		elif dig == '2':
			a += '1'
			b += '1'
		else:
			a += '1'
			b += '0'
			flag = True
	print(a)
	print(b)


import math
t = int(input())
for kl in range(t):
	n = int(input())
	a = list(input())
	res1 = ''
	res2 = ''
	deff = 0
	for i in range(n):
		if a[i] == '2':
			if deff == 0:
				res1 += '1'
				res2 += '1'
			else:
				res1 += '0'
				res2 += '2'
		elif a[i] == '1':
			if deff == 0:
				res1 += '1'
				res2 += '0'
				deff = 1
			else:
				res2 += '1'
				res1 += '0'
		else:
			res1 += '0'
			res2 += '0'
	print(res1)
	print(res2)


number_test = int(input())

def find_n(k):
	n = 1
	somme = 1
	while somme < k:
		n += 1
		somme = n * (n + 1) / 2
	return n
for k in range(number_test):
	n = int(input())
	c = input()
	nb1 = ''
	nb2 = ''
	verif = True
	for k in range(n):
		e = int(c[k])
		if e == 2:
			if verif:
				nb1 = nb1 + '1'
				nb2 = nb2 + '1'
			else:
				nb1 = nb1 + '0'
				nb2 = nb2 + '2'
		elif e == 1:
			if verif:
				nb1 = nb1 + '1'
				nb2 = nb2 + '0'
				verif = False
			else:
				nb1 = nb1 + '0'
				nb2 = nb2 + '1'
		else:
			nb1 = nb1 + '0'
			nb2 = nb2 + '0'
	print(nb1)
	print(nb2)


from math import *
import sys, random

def nextInt():
	return int(input())

def nextStrs():
	return input().split()

def nextInts():
	return list(map(int, nextStrs()))

def main():
	t = nextInt()
	for _ in range(t):
		n = nextInt()
		S = input()
		a = b = '1'
		for i in range(1, len(S)):
			if S[i] == '0':
				a += '0'
				b += '0'
			elif S[i] == '2':
				a += '1'
				b += '1'
			else:
				a += '1'
				b += '0'
				for j in range(len(S) - i - 1):
					a += '0'
				b += S[i + 1:]
				break
		print(a, b, sep='\n')
exit(main())


t = int(input())
for _ in range(t):
	n = int(input())
	x = int(input())
	a = ['-' for _ in range(n)]
	b = ['-' for _ in range(n)]
	a[0] = 1
	b[0] = 1
	alt = True
	for (i, c) in enumerate(str(x)):
		if c == '0':
			a[i] = 0
			b[i] = 0
		elif c == '1':
			if alt:
				a[i] = 1
				b[i] = 0
				alt = False
			else:
				a[i] = 0
				b[i] = 1
		elif alt:
			a[i] = 1
			b[i] = 1
		else:
			a[i] = 0
			b[i] = 2
	a = [str(x) for x in a]
	b = [str(x) for x in b]
	print(''.join(a))
	print(''.join(b))


t = int(input())
for _ in range(0, t):
	n = int(input())
	x = input()
	ch1 = ''
	ch2 = ''
	test = True
	for c in x:
		if c == '0':
			ch1 += '0'
			ch2 += '0'
		elif test == True:
			if c == '2':
				ch1 += '1'
				ch2 += '1'
			if c == '1':
				ch1 += '1'
				ch2 += '0'
				test = False
		else:
			if c == '2':
				ch1 += '0'
				ch2 += '2'
			if c == '1':
				ch1 += '0'
				ch2 += '1'
	print(ch1)
	print(ch2)


t = int(input())
for test in range(t):
	n = int(input())
	s = input()
	curr = ''
	done = False
	for i in range(n):
		if s[i] == '1':
			curr1 = curr
			curr2 = curr
			curr1 += '1'
			curr2 += '0'
			for j in range(i + 1, n):
				curr1 += '0'
				curr2 += s[j]
			print(curr1)
			print(curr2)
			done = True
			break
		else:
			curr += str(int(s[i]) // 2)
	if not done:
		print(curr)
		print(curr)


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	res = ['1' for _ in x]
	res2 = ['1' for _ in x]
	first_one = True
	for i in range(1, n):
		if x[i] == '1':
			res[i] = '1' if first_one else '0'
			res2[i] = '0' if first_one else '1'
			first_one = False
		else:
			res[i] = '1' if x[i] == '2' else '0'
			res[i] = '0' if x[i] == '2' and (not first_one) else res[i]
			res2[i] = str((int(x[i]) - int(res[i]) + 3) % 3)
	print(''.join(res))
	print(''.join(res2))


from math import ceil

def main():
	for test in range(int(input())):
		n = int(input())
		x = list(map(int, input()))
		print(*solution(x, n), sep='\n')

def solution(x, n):
	a = [0] * n
	b = [0] * n
	flag = False
	for i in range(n):
		if x[i] == 2:
			if not flag:
				a[i] = 1
				b[i] = 1
				continue
			else:
				a[i] = 0
				b[i] = 2
		elif x[i] == 1:
			if not flag:
				a[i] = 1
				b[i] = 0
				flag = True
			else:
				a[i] = 0
				b[i] = 1
	return (list_to_str(a), list_to_str(b))

def list_to_str(l):
	s = ''
	for i in l:
		s += str(i)
	return s
main()


for i in range(int(input())):
	i = int(input())
	s = input()
	a = [0 for _ in range(i)]
	b = [0 for _ in range(i)]
	(a[0], b[0]) = ('1', '1')
	key = False
	for i in range(1, i):
		if key:
			if s[i] == '2':
				(a[i], b[i]) = ('0', '2')
			elif s[i] == '0':
				(a[i], b[i]) = ('0', '0')
			else:
				(a[i], b[i]) = ('0', '1')
		elif s[i] == '2':
			(a[i], b[i]) = ('1', '1')
		elif s[i] == '0':
			(a[i], b[i]) = ('0', '0')
		else:
			(a[i], b[i]) = ('1', '0')
			key = True
	print(''.join(a))
	print(''.join(b))


import math
t = int(input())
for _ in range(t):
	n = int(input())
	a = input()
	v1 = ''
	v2 = ''
	f = True
	for i in a:
		if i == '2':
			if f:
				v1 += '1'
				v2 += '1'
			else:
				v1 += '2'
				v2 += '0'
		elif i == '1':
			if f:
				v1 += '0'
				v2 += '1'
				f = False
			else:
				v1 += '1'
				v2 += '0'
		elif i == '0':
			v1 += '0'
			v2 += '0'
	print(v1)
	print(v2)


for i in range(int(input())):
	n = int(input())
	a = list(input())
	x = [1]
	y = [1]
	c = 0
	for i in range(1, len(a)):
		if a[i] == '1':
			if c == 0:
				x.append(1)
				c += 1
				y.append(0)
			else:
				y.append(1)
				x.append(0)
		elif a[i] == '2':
			if c == 0:
				x.append(1)
				y.append(1)
			if c == 1:
				x.append(0)
				y.append(2)
		else:
			x.append(0)
			y.append(0)
	(u, v) = ('', '')
	for i in range(len(a)):
		u += str(x[i])
		v += str(y[i])
	print(u)
	print(v)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	flag = False
	r1 = ''
	r2 = ''
	for e in s:
		if e == '1':
			u = 0
			v = 1
			if flag:
				(u, v) = (v, u)
				flag = True
			flag = True
		elif e == '0':
			u = 0
			v = 0
		elif e == '2' and flag is False:
			u = 1
			v = 1
		else:
			u = 2
			v = 0
		r1 += str(u)
		r2 += str(v)
	print(r2)
	print(r1)


n = int(input())
for i in range(n):
	x = int(input())
	y = input()
	(a, b) = ('', '')
	same = True
	for (id, j) in enumerate(y):
		if j == '1':
			if same:
				a += '1'
				b += '0'
			else:
				a += '0'
				b += '1'
			same = False
		if j == '0':
			a += '0'
			b += '0'
		elif j == '2':
			if same:
				a += '1'
				b += '1'
			elif not same:
				a += '0'
				b += '2'
	print(a)
	print(b)


q = int(input())
for _ in range(q):
	n = int(input())
	num = str(input())
	a = ''
	b = ''
	bool1 = True
	if num[0] == 0:
		a += '2'
		b += '1'
		for each in num[1:]:
			if each == '0':
				a += '0'
				b += '0'
			elif each == '1':
				a += '0'
				b += '1'
			elif each == '2':
				a += '0'
				b += '2'
	else:
		for each in num:
			if bool1:
				if each == '0':
					a += '0'
					b += '0'
				elif each == '1':
					a += '1'
					b += '0'
					bool1 = False
				elif each == '2':
					a += '1'
					b += '1'
			elif each == '0':
				a += '0'
				b += '0'
			elif each == '1':
				a += '0'
				b += '1'
			elif each == '2':
				a += '0'
				b += '2'
	print(a)
	print(b)


q = int(input())
for _ in range(q):
	input()
	x = input()
	ans1 = ['1']
	ans2 = ['1']
	is_one = False
	for i in x[1:]:
		if i == '0':
			ans1.append('0')
			ans2.append('0')
		elif i == '1':
			if is_one:
				ans1.append('0')
				ans2.append('1')
			else:
				ans1.append('1')
				ans2.append('0')
				is_one = True
		elif is_one:
			ans1.append('0')
			ans2.append('2')
		else:
			ans1.append('1')
			ans2.append('1')
	for i in ans1:
		print(i, end='')
	print()
	for i in ans2:
		print(i, end='')
	print()


t = int(input())
for tt in range(t):
	n = int(input())
	x = [int(i) for i in list(input())]
	a = list()
	b = list()
	lst = 0
	for l in x:
		if l == 0:
			a.append(0)
			b.append(0)
		elif l == 1:
			if lst == 0:
				lst = 1
				a.append(1)
				b.append(0)
			else:
				a.append(0)
				b.append(1)
		elif lst == 0:
			a.append(1)
			b.append(1)
		else:
			a.append(0)
			b.append(2)
	for x in a:
		print(x, end='')
	print()
	for x in b:
		print(x, end='')
	print()


import sys
inputlist = sys.stdin.readlines()
number_of_testcases = int(inputlist[0].strip())

def form_larger_smaller(n, numbers_list, numbers_to_be_used_dict):
	larger = []
	smaller = []
	for i in range(n):
		larger.append(numbers_to_be_used_dict[numbers_list[i]][0])
		smaller.append(numbers_to_be_used_dict[numbers_list[i]][1])
		if numbers_list[i] == '1':
			break
	return (larger, smaller, i)

def continue_larger_smaller(n, numbers_list, numbers_to_be_used_dict, larger, smaller, index_done):
	for i in range(index_done + 1, n):
		larger.append(numbers_to_be_used_dict[numbers_list[i]][0])
		smaller.append(numbers_to_be_used_dict[numbers_list[i]][1])
	return (larger, smaller)
for i in range(number_of_testcases):
	n = int(inputlist[2 * i + 1].strip())
	numbers_list = inputlist[2 * i + 2].strip()
	numbers_to_be_used_dict = {}
	numbers_to_be_used_dict['0'] = ['0', '0']
	numbers_to_be_used_dict['1'] = ['1', '0']
	numbers_to_be_used_dict['2'] = ['1', '1']
	(larger, smaller, index_done) = form_larger_smaller(n, numbers_list, numbers_to_be_used_dict)
	numbers_to_be_used_dict['1'] = ['0', '1']
	numbers_to_be_used_dict['2'] = ['0', '2']
	(larger, smaller) = continue_larger_smaller(n, numbers_list, numbers_to_be_used_dict, larger, smaller, index_done)
	print(''.join(larger))
	print(''.join(smaller))


T = int(input())
for _ in range(0, T):
	n = int(input())
	s = input()
	L1 = ['1'] * n
	L2 = ['1'] * n
	c = 0
	for i in range(1, len(s)):
		if s[i] == '0':
			L1[i] = '0'
			L2[i] = '0'
		elif s[i] == '1':
			if c == 0:
				c = 1
				L1[i] = '0'
				L2[i] = '1'
			else:
				L1[i] = '1'
				L2[i] = '0'
		elif c == 0:
			L1[i] = '1'
			L2[i] = '1'
		else:
			L1[i] = '2'
			L2[i] = '0'
	L1 = ''.join(L1)
	L2 = ''.join(L2)
	print(L1)
	print(L2)


t = int(input())
while t > 0:
	t -= 1
	k = int(input())
	n = input()
	l = [int(x) for x in str(n)]
	a = ''
	b = ''
	a1 = 0
	b1 = 0
	for i in range(len(l)):
		if l[i] == 2:
			if a1 == 1:
				a = a + '0'
				b = b + str(l[i])
				b1 = 1
			else:
				a = a + '1'
				b = b + '1'
		elif l[i] == 1:
			if a1 == 1 or b1 == 1:
				a = a + '0'
				b = b + str(l[i])
			elif b1 == 0:
				a = a + str(l[i])
				b = b + '0'
			a1 = 1
		else:
			a = a + '0'
			b = b + '0'
	print(a)
	print(b)


from sys import *
for _ in range(int(input())):
	n = int(input())
	s = stdin.readline()
	t = ''
	ind = 0
	for i in range(n):
		if s[i] == '2':
			t += '1'
		elif s[i] == '0':
			t += '0'
		else:
			ind = i
			break
	else:
		ind = n
	r = ''
	r += t
	if ind < n:
		r += '0'
	for i in range(ind + 1, n):
		r += s[i]
	if ind < n:
		t += '1'
	for i in range(n - len(t)):
		t += '0'
	stdout.write(t + '\n')
	stdout.write(r + '\n')


for _ in range(1, int(input()) + 1):
	N = int(input())
	bit = input()
	(a, b) = ('', '')
	idx = 0
	while idx < N and bit[idx] != '1':
		if bit[idx] == '2':
			a += '1'
			b += '1'
		elif bit[idx] == '0':
			a += '0'
			b += '0'
		idx += 1
	if idx < N and bit[idx] == '1':
		a += '1'
		b += '0'
	for i in range(idx + 1, N):
		a += '0'
		b += bit[i]
	print(a)
	print(b)


for _ in range(int(input())):
	l = int(input())
	s = input()
	big = ''
	small = ''
	flag = True
	for i in s:
		if i == '2':
			if flag:
				big += '1'
				small += '1'
			else:
				big += '0'
				small += '2'
		elif i == '0':
			big += '0'
			small += '0'
		elif flag:
			big += '1'
			small += '0'
			flag = False
		else:
			big += '0'
			small += '1'
	print(big)
	print(small)


from math import *
for zz in range(int(input())):
	n = int(input())
	x = input()
	a = '1'
	b = '1'
	gr = False
	for i in range(1, n):
		if x[i] == '2':
			if not gr:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
		elif x[i] == '0':
			a += '0'
			b += '0'
		elif not gr:
			a += '1'
			b += '0'
			gr = True
		else:
			b += '1'
			a += '0'
	print(a)
	print(b)


for _ in range(int(input())):
	n = int(input())
	x = input()
	first = True
	a = ''
	b = ''
	for s in x:
		if s == '2' and first:
			a += '1'
			b += '1'
		elif s == '2':
			a += '0'
			b += '2'
		elif s == '1' and first:
			a += '1'
			b += '0'
			first = False
		elif s == '1':
			a += '0'
			b += '1'
		elif s == '0':
			a += '0'
			b += '0'
	print(a)
	print(b)


tc = int(input())
for _ in range(tc):
	n = int(input())
	s = input()
	a = b = '1'
	flag = None
	for i in s[1:]:
		if int(i) % 2 == 0 and (not flag):
			num = int(i) // 2
			a += str(num)
			b += str(num)
		else:
			num = int(i) // 2
			if not flag:
				a += str(num + 1)
				b += str(num)
				flag = True
			else:
				a += str(0)
				b += str(i)
	print(a, b, sep='\n')


import sys
I = sys.stdin.readline
ans = ''
for _ in range(int(I())):
	n = int(I())
	c = I().strip()
	a = '1'
	b = '1'
	for i in c[1:]:
		if i == '2' and a == b:
			a += '1'
			b += '1'
		elif a > b:
			a += '0'
			b += i
		else:
			a += i
			b += '0'
	ans += a + '\n' + b + '\n'
print(ans)


def ternary_split(x):
	a = ''
	b = ''
	n = len(x)
	if n == 0:
		return (a, b)
	else:
		for i in range(n):
			if x[i] == '1':
				a += '1' + '0' * (n - 1 - i)
				b += '0' + x[i + 1:]
				return (a, b)
			else:
				d = int(x[i])
				a += str(d // 2)
				b += str(d // 2)
		return (a, b)

def cut_zeros(x):
	i = 0
	while x[i] == '0':
		i += 1
	return x[i:]
t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	(a, b) = ternary_split(x)
	print(cut_zeros(a))
	print(cut_zeros(b))


testCases = int(input())
for i1 in range(testCases):
	length = int(input())
	sequence = input()
	result = []
	oneFound = False
	for i2 in range(length):
		if i2 == 0:
			result.append(1)
		elif sequence[i2] == '0':
			result.append(0)
		elif sequence[i2] == '2' and (not oneFound):
			result.append(1)
		elif sequence[i2] == '2' and oneFound:
			result.append(0)
		elif sequence[i2] == '1' and (not oneFound):
			result.append(1)
			oneFound = True
		elif sequence[i2] == '1' and oneFound:
			result.append(0)
	for i3 in result:
		print(i3, end='')
	print('')
	for i3 in range(length):
		temp = int(sequence[i3]) - result[i3]
		print(temp, end='')
	print('')


for _ in range(int(input())):
	n = int(input())
	x = input()
	mark = 'none'
	a = ''
	b = ''
	i = 0
	while mark != 'up' and i < n:
		if x[i] == '0':
			a += '0'
			b += '0'
		if x[i] == '1':
			a += '1'
			b += '0'
			mark = 'up'
		if x[i] == '2':
			a += '1'
			b += '1'
		i += 1
	a += '0' * (n - i)
	b += x[i:]
	print(a)
	print(b)


for _ in range(int(input())):
	input()
	x = input()
	(a, b) = ('', '')
	if x[0] == '2':
		a = '1'
		b = '1'
	else:
		a = '2'
		b = '2'
	switch = False
	for e in x[1:]:
		if e == '0':
			a += '0'
			b += '0'
		elif e == '1':
			if switch:
				a += '0'
				b += '1'
			else:
				b += '0'
				a += '1'
				switch = True
		elif e == '2':
			if switch:
				a += '0'
				b += '2'
			else:
				b += '1'
				a += '1'
	print(a)
	print(b)


for _ in range(int(input())):
	n = int(input())
	a = list(input())
	a1 = []
	a2 = []
	eq = True
	for x in a:
		if x == '0':
			a1.append('0')
			a2.append('0')
		elif x == '1':
			if eq:
				a1.append('1')
				a2.append('0')
				eq = False
			else:
				a1.append('0')
				a2.append('1')
		elif not eq:
			a1.append('0')
			a2.append('2')
		else:
			a1.append('1')
			a2.append('1')
	print(''.join(a1))
	print(''.join(a2))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def main():
	t = I()
	rr = []
	for _ in range(t):
		n = I()
		s = S()
		a = [1]
		b = [1]
		f = 0
		for c in s[1:]:
			c = int(c)
			if c == 0:
				a.append(0)
				b.append(0)
			elif f == 1:
				b.append(c)
				a.append(0)
			elif c == 2:
				a.append(1)
				b.append(1)
			else:
				f = 1
				a.append(c)
				b.append(0)
		rr.append(JA(a, ''))
		rr.append(JA(b, ''))
	return JA(rr, '\n')
print(main())


t = int(input())
for _ in range(t):
	n = int(input())
	split = False
	a = ''
	b = ''
	for c in input():
		if split:
			a += '0'
			b += c
		elif c == '2':
			a += '1'
			b += '1'
		elif c == '0':
			a += '0'
			b += '0'
		else:
			split = True
			a += '1'
			b += '0'
	print(a)
	print(b)


n = int(input())
for i in range(n):
	l = input()
	x = input()
	a = ''
	b = ''
	AisBigger = False
	for c in x:
		if c == '2' and AisBigger == False:
			a += '1'
			b += '1'
		elif c == '2' and AisBigger:
			a += '0'
			b += '2'
		elif c == '1' and AisBigger == False:
			a += '1'
			b += '0'
			AisBigger = True
		elif c == '1' and AisBigger:
			a += '0'
			b += '1'
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


t = int(input())
for i in range(0, t):
	n = int(input())
	x = input()
	x = list(x)
	larger = ''
	smaller = ''
	larger += '1'
	smaller += '1'
	j = 1
	while j < n:
		if x[j] != '1':
			if x[j] == '0':
				larger += '0'
				smaller += '0'
			if x[j] == '2':
				larger += '1'
				smaller += '1'
			j += 1
		else:
			break
	if j < n:
		larger += '1'
		smaller += '0'
		j += 1
	while j < n:
		larger += '0'
		smaller += str(x[j])
		j += 1
	print(larger)
	print(smaller)


import sys
for _ in range(int(sys.stdin.readline())):
	n = int(sys.stdin.readline())
	x = sys.stdin.readline()
	a = []
	b = []
	i = f = 0
	for i in range(n):
		if x[i] == '2' and f == 0:
			a.append(1)
			b.append(1)
		elif x[i] == '1' and f == 0:
			f = 1
			a.append(1)
			b.append(0)
		elif x[i] == '1' and f == 1:
			a.append(0)
			b.append(1)
		elif x[i] == '2' and f == 1:
			a.append(0)
			b.append(2)
		elif x[i] == '0':
			a.append(0)
			b.append(0)
	for i in range(n):
		print(a[i], end='')
	print('')
	for i in range(n):
		print(b[i], end='')
	print('')


alph = 'abcdefghijklmnopqrstuvwxyz'
t = int(input())
for i in range(t):
	n = int(input())
	x = str(input())
	p1 = ''
	p2 = ''
	flag = False
	for j in x:
		if flag:
			p1 += '0'
			p2 += j
		elif j == '1':
			flag = True
			p1 += '1'
			p2 += '0'
		elif j == '2':
			p1 += '1'
			p2 += '1'
		else:
			p1 += j
			p2 += j
	print(p1)
	print(p2)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	a = [1]
	b = [1]
	ch = 0
	for i in range(1, n):
		if s[i] == '0':
			a.append(0)
			b.append(0)
		elif s[i] == '1':
			if ch == 0:
				a.append(1)
				b.append(0)
				ch = 1
			else:
				a.append(0)
				b.append(1)
		elif s[i] == '2':
			if ch == 0:
				a.append(1)
				b.append(1)
			else:
				a.append(0)
				b.append(2)
	for i in a:
		print(i, end='')
	print()
	for i in b:
		print(i, end='')
	print()


t = int(input())
for j in range(t):
	s = int(input())
	n = input()
	num1 = ''
	num2 = ''
	flag = True
	for i in range(len(n)):
		if n[i] == '1' and flag == True:
			num1 = num1 + '1'
			num2 = num2 + '0'
			break
		if n[i] == '2':
			num1 = num1 + '1'
			num2 = num2 + '1'
		if n[i] == '0':
			num1 = num1 + '0'
			num2 = num2 + '0'
	for j in range(i + 1, len(n)):
		num1 = num1 + '0'
	num2 = num2 + n[i + 1:]
	print(num1)
	print(num2)


t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	x = int(input())
	x = str(x)
	x = [int(i) for i in x]
	a = []
	a.append(1)
	b = []
	b.append(1)
	max = None
	pos = 0
	for i in range(1, n):
		if x[i] == 0:
			a.append(0)
			b.append(0)
		elif x[i] == 1:
			a.append(1)
			b.append(0)
			max = a
			pos = i + 1
			break
		elif x[i] == 2:
			a.append(1)
			b.append(1)
	for i in range(pos, n):
		if x[i] == 0:
			a.append(0)
			b.append(0)
		elif x[i] == 1:
			a.append(0)
			b.append(1)
		else:
			a.append(0)
			b.append(2)
	for i in range(n):
		print(a[i], end='')
	print()
	for i in range(n):
		print(b[i], end='')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	x = list(input())
	a = 0
	ans1 = []
	ans2 = []
	for i in range(n):
		if a == 0:
			if x[i] == '0':
				ans1.append('0')
				ans2.append('0')
			elif x[i] == '1':
				ans1.append('1')
				ans2.append('0')
				a = 1
			elif x[i] == '2':
				ans1.append('1')
				ans2.append('1')
		elif x[i] == '0':
			ans1.append('0')
			ans2.append('0')
		elif x[i] == '1':
			ans1.append('0')
			ans2.append('1')
		elif x[i] == '2':
			ans1.append('0')
			ans2.append('2')
	print(''.join(ans1))
	print(''.join(ans2))


t = int(input())
l_len = []
l_str = []
for i in range(t):
	l_len.append(int(input()))
	l_str.append(input())
for i in range(t):
	s1 = ''
	s2 = ''
	diff = False
	for j in range(l_len[i]):
		if diff or l_str[i][j] == '0':
			s1 += '0'
			s2 += l_str[i][j]
		if l_str[i][j] == '2' and (not diff):
			s1 += '1'
			s2 += '1'
		if l_str[i][j] == '1' and (not diff):
			diff = True
			s1 += '1'
			s2 += '0'
	print(s1)
	print(s2)


from functools import reduce
import operator
import itertools
from bisect import bisect_left
import functools
from itertools import cycle

def unpack(func):
	return lambda iterator: func(*iterator)

def vzip(iterator, value):
	return zip(iterator, cycle([value]))

def tryOr(exp, value):
	try:
		return exp()
	except Exception:
		return value

def solve():
	l = int(input())
	n = list(map(int, input()))
	p = l
	p = tryOr(lambda : n.index(1), l)
	fp = list(map(unpack(operator.floordiv), vzip(n, 2)))
	print(*fp[:p] + ([1] if p != l else []) + [0] * (l - p - 1), sep='')
	print(*fp[:p] + ([0] if p != l else []) + n[p + 1:], sep='')
t = int(input())
for i in range(t):
	solve()


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	x = input()
	x = list(x)
	a = []
	b = []
	q = 0
	for i in range(n):
		if x[i - 1] == '1' and i > 0:
			q = 1
		if x[i] == '0':
			a.append('0')
			b.append('0')
		if q == 0:
			if x[i] == '2':
				a.append('1')
				b.append('1')
			if x[i] == '1':
				a.append('1')
				b.append('0')
		elif q == 1:
			if x[i] == '2':
				a.append('0')
				b.append('2')
			if x[i] == '1':
				a.append('0')
				b.append('1')
	print(''.join(a))
	print(''.join(b))


tests = int(input())
nnn = []
strings = []
for i in range(0, tests):
	nnn.append(int(input()))
	strings.append(input())
for i in range(0, tests):
	n = nnn[i]
	string = strings[i]
	big = ''
	small = ''
	flag = 0
	for j in string:
		if j == '2':
			if flag == 0:
				big += '1'
				small += '1'
			if flag == 1:
				big += '0'
				small += '2'
		if j == '1' and flag == 1:
			big += '0'
			small += '1'
		if j == '0':
			big += '0'
			small += '0'
		if j == '1' and flag == 0:
			big += '1'
			small += '0'
			flag = 1
	print(big)
	print(small)


t = int(input())
for _ in range(t):
	n = int(input())
	a = input()
	b = ''
	c = ''
	d = 0
	for i in range(n):
		if a[i] == '0':
			b = b + '0'
			c = c + '0'
		if a[i] == '2':
			if d == 0:
				b = b + '1'
				c = c + '1'
			else:
				b = b + '0'
				c = c + '2'
		if a[i] == '1':
			if d == 1:
				b = b + '0'
				c = c + '1'
			else:
				b = b + '1'
				c = c + '0'
				d = d + 1
	print(b)
	print(c)


t = int(input())
for abc in range(t):
	n = int(input())
	x = input()
	a = ''
	b = ''
	for (i, c) in enumerate(x):
		if c == '0':
			a += '0'
			b += '0'
		elif c == '2':
			a += '1'
			b += '1'
		else:
			a += '1' + '0' * (n - i - 1)
			b += '0' + x[i + 1:]
			break
	print(a)
	print(b)


import math, sys
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	s = input()
	flag = 0
	ans1 = ''
	ans2 = ''
	for i in range(n):
		if s[i] == '0':
			ans1 += '0'
			ans2 += '0'
		elif flag == 0:
			if s[i] == '2':
				ans1 += '1'
				ans2 += '1'
			else:
				ans1 += '1'
				ans2 += '0'
				flag = 1
		else:
			ans1 += '0'
			ans2 += s[i]
	print(ans1)
	print(ans2)


t = int(input())
for _ in range(t):
	n = int(input())
	a = input()
	(p, q) = ('', '')
	k = 1
	for i in range(n):
		if k == 1:
			if a[i] == '2':
				p += '1'
				q += '1'
			if a[i] == '0':
				p += '0'
				q += '0'
			if a[i] == '1':
				k += 1
				p += '1'
				q += '0'
				continue
		if k == 2:
			q += a[i]
			p += '0'
	print(p)
	print(q)


for h in range(int(input())):
	n = int(input())
	x = [int(i) for i in input()]
	a = [0] * n
	a[0] = 1
	b = [0] * n
	b[0] = 1
	fl = 0
	for i in range(1, n):
		if fl:
			b[i] = x[i]
		elif x[i] == 1:
			a[i] = 1
			fl = 1
		elif x[i] == 2:
			a[i] = 1
			b[i] = 1
	[print(i, end='') for i in a]
	print()
	[print(i, end='') for i in b]
	print()


t = int(input())
while t > 0:
	try:
		flag = 1
		n = int(input())
		s = input()
		a = ''
		b = ''
		for i in range(n):
			if flag == 1:
				if s[i] == '2':
					a += '1'
					b += '1'
				elif s[i] == '1':
					a += '0'
					b += '1'
					flag = 0
				else:
					a += '0'
					b += '0'
			else:
				a += s[i]
				b += '0'
		print(a)
		print(b)
		t -= 1
	except:
		break


t = int(input())
for w in range(t):
	n = int(input())
	x = list(input())
	a = [0] * n
	b = [0] * n
	c = 0
	if '1' in x:
		k = x.index('1')
		for i in range(k):
			if x[i] == '2':
				a[i] = '1'
				b[i] = '1'
			else:
				a[i] = '0'
				b[i] = '0'
		a[k] = '1'
		b[k] = '0'
		for i in range(k + 1, n):
			a[i] = '0'
			b[i] = x[i]
	else:
		for i in range(n):
			if x[i] == '2':
				a[i] = '1'
				b[i] = '1'
			else:
				a[i] = '0'
				b[i] = '0'
	print(''.join(a))
	print(''.join(b))


for _ in range(int(input())):
	n = int(input())
	x = list(input())
	a = []
	b = []
	k = 0
	for i in x:
		if i == '2':
			if k == 0:
				a.append('1')
				b.append('1')
			else:
				a.append('0')
				b.append('2')
		if i == '1':
			if k == 0:
				a.append('1')
				b.append('0')
				k = 1
			else:
				a.append('0')
				b.append('1')
		if i == '0':
			a.append('0')
			b.append('0')
	print(''.join(a))
	print(''.join(b))


t = int(input())
for i in range(t):
	l = int(input())
	num = input()
	a = ''
	b = ''
	p = 0
	if l == 1:
		a = '1'
		b = '1'
	else:
		for i in range(0, l - 1):
			if num[i] == '1':
				a += '1'
				b += '0'
				a += '0' * (l - i - 1)
				b += num[i + 1:l]
				p = 1
				break
			else:
				if num[i] == '2':
					a += '1'
					b += '1'
				if num[i] == '0':
					a += '0'
					b += '0'
		if p == 0:
			if num[l - 1] == '2':
				a += '1'
				b += '1'
			if num[l - 1] == '0':
				a += '0'
				b += '0'
			if num[l - 1] == '1':
				a += '1'
				b += '0'
	print(a)
	print(b)


t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	c = list(map(int, x))
	a = []
	b = []
	flag = True
	for j in range(n):
		if j == 0:
			a.append(1)
			b.append(1)
			continue
		if c[j] == 2 and flag:
			a.append(1)
			b.append(1)
			continue
		if c[j] == 1 and flag:
			a.append(1)
			b.append(0)
			flag = False
			continue
		a.append(0)
		b.append(c[j])
	for j in range(n):
		a[j] = str(a[j])
		b[j] = str(b[j])
	print(''.join(a))
	print(''.join(b))


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	a = []
	b = []
	ind = n
	for i in range(n):
		if s[i] == '1':
			a += [0]
			b += [1]
			ind = i
			break
		if s[i] == '0':
			a += [0]
			b += [0]
		else:
			a += [1]
			b += [1]
	for i in range(ind + 1, n):
		a += [s[i]]
		b += [0]
	print(*a, sep='')
	print(*b, sep='')


t = int(input())
while t:
	l = int(input())
	s = input()
	flag = -1
	fone = False
	(a, b) = ('', '')
	for i in range(len(s)):
		if i == 0:
			if s[i] == '1':
				a += '2'
				b += '2'
			else:
				a += '1'
				b += '1'
		elif s[i] == '1':
			if fone is False:
				a += '0'
				b += '1'
				fone = True
			else:
				a += '1'
				b += '0'
		elif s[i] == '0':
			a += '0'
			b += '0'
		elif fone is True:
			a += '2'
			b += '0'
		else:
			a += '1'
			b += '1'
	print(b)
	print(a)
	t -= 1


def solve(n, x):
	(n1, n2) = ([], [])
	spl = False
	for c in x:
		n1c = n2c = '0'
		if c == '0':
			pass
		elif c == '1' and (not spl):
			n1c = '1'
			spl = True
		elif c == '1' and spl:
			n2c = '1'
		elif c == '2' and (not spl):
			n1c = n2c = '1'
		elif c == '2' and spl:
			n2c = '2'
		n1.append(n1c)
		n2.append(n2c)
	return (''.join(n1), ''.join(n2))
output = []
t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	(a, b) = solve(n, x)
	output.append(a)
	output.append(b)
for line in output:
	print(line)


def solve(n, g):
	s = list(str(g))
	a = [0] * n
	b = [0] * n
	p = 1
	for i in range(n):
		if s[i] == '2':
			if p == 1:
				a[i] = '1'
				b[i] = '1'
			else:
				a[i] = '0'
				b[i] = '2'
		if s[i] == '0':
			a[i] = '0'
			b[i] = '0'
		if s[i] == '1':
			if p == 1:
				a[i] = '1'
				b[i] = '0'
				p -= 1
			else:
				a[i] = '0'
				b[i] = '1'
	print(int(''.join(a)))
	print(int(''.join(b)))
t = int(input())
while t:
	n = int(input())
	g = int(input())
	solve(n, g)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	x = input()
	a = []
	b = []
	flag = True
	for i in x:
		if flag:
			if i == '2':
				a.append('1')
				b.append('1')
			if i == '1':
				a.append('1')
				b.append('0')
				flag = False
			if i == '0':
				a.append('0')
				b.append('0')
		else:
			if i == '2':
				a.append('0')
				b.append('2')
			if i == '1':
				a.append('0')
				b.append('1')
			if i == '0':
				a.append('0')
				b.append('0')
	print(''.join(a))
	print(''.join(b))


t = int(input())
out = ''
while t > 0:
	t -= 1
	n = int(input())
	a = ''
	b = ''
	big_a = False
	for c in input():
		if c == '2':
			if big_a:
				a += '0'
				b += '2'
				continue
			a += '1'
			b += '1'
		elif c == '1':
			if not big_a:
				a += '1'
				b += '0'
				big_a = True
				continue
			a += '0'
			b += '1'
		else:
			a += '0'
			b += '0'
	out += f'{a}\n{b}\n'
print(out)


t = int(input())
for _ in range(t):
	n = int(input())
	x = list(map(int, list(input())))
	a = [1]
	b = [1]
	flag = True
	for i in range(1, n):
		if x[i] == 2:
			if flag:
				a.append(1)
				b.append(1)
			else:
				a.append(0)
				b.append(2)
		elif x[i] == 1:
			if flag:
				a.append(1)
				b.append(0)
				flag = False
			else:
				a.append(0)
				b.append(1)
		else:
			a.append(0)
			b.append(0)
	print(''.join(map(str, a)))
	print(''.join(map(str, b)))


t = int(input())
for j in range(t):
	nn = int(input())
	n = input()
	lsa = []
	lsb = []
	a = b = ''
	flag = 0
	for i in n:
		if i == '2':
			if flag == 0:
				a = a + '1'
				b = b + '1'
			else:
				a = a + '0'
				b = b + '2'
		elif i == '1':
			if flag == 0:
				a = a + '1'
				b = b + '0'
				flag = 1
			else:
				a = a + '0'
				b = b + '1'
		else:
			a = a + '0'
			b = b + '0'
	print(a)
	print(b)


t = int(input())
for testcase in range(t):
	n = int(input())
	x = input()
	a = b = ''
	bsmaller = False
	for xi in x:
		if xi == '2':
			if bsmaller:
				a += '0'
				b += '2'
			else:
				a += '1'
				b += '1'
		elif xi == '1':
			if bsmaller:
				a += '0'
				b += '1'
			else:
				bsmaller = True
				a += '1'
				b += '0'
		elif xi == '0':
			a += '0'
			b += '0'
	print(a)
	print(b)


t = int(input())
while t > 0:
	n = int(input())
	str = input()
	a = ''
	b = ''
	temp = 0
	for i in str:
		if i == '2' and temp == 0:
			a += '1'
			b += '1'
		elif i == '2' and temp == 1:
			a += '0'
			b += '2'
		elif i == '1' and temp == 0:
			a += '1'
			b += '0'
			temp = 1
		elif i == '1' and temp == 1:
			a += '0'
			b += '1'
		elif i == '0':
			a += '0'
			b += '0'
	print(a)
	print(b)
	t = t - 1


def main():
	result = str()
	for _ in range(int(input())):
		input()
		x = list(map(int, list(str(input()))))
		a = b = str()
		for i in x:
			if i == 2:
				if a < b:
					a += '2'
					b += '0'
				elif a > b:
					a += '0'
					b += '2'
				else:
					a += '1'
					b += '1'
			elif i == 1:
				if a < b:
					a += '1'
					b += '0'
				elif a > b:
					a += '0'
					b += '1'
				else:
					a += '1'
					b += '0'
			elif i == 0:
				a += '0'
				b += '0'
		result += f'{a}\n{b}\n'
	print(result.strip())
main()


from math import floor, ceil
for _ in range(int(input())):
	n = int(input())
	c = [int(x) for x in input()]
	a = [0] * n
	b = [0] * n
	for i in range(n):
		a[i] = str(ceil(c[i] / 2))
		b[i] = str(floor(c[i] / 2))
		if c[i] == 1:
			break
	for x in range(i + 1, n):
		a[x] = str(0)
		b[x] = str(c[x])
	print(''.join(a))
	print(''.join(b))


t = int(input())
for i in range(0, t):
	n = int(input())
	a = input()
	k = '1'
	l = '1'
	for j in range(1, n):
		if a[j] == '1':
			k = k + '1' + (n - j - 1) * '0'
			l = l + '0' + a[j + 1:n]
			break
		else:
			k = k + str(int(a[j]) // 2)
			l = l + str(int(a[j]) // 2)
	print(k)
	print(l)


t = int(input())
ans = []
for i in range(0, t):
	n = int(input())
	x = input()
	answer1 = []
	answer2 = []
	flag = 0
	for i in range(0, n):
		if x[i] == '2':
			if flag == 0:
				answer1.append('1')
				answer2.append('1')
			else:
				answer1.append('2')
				answer2.append('0')
		elif x[i] == '1':
			if flag == 0:
				answer1.append('0')
				answer2.append('1')
				flag = 1
			else:
				answer1.append('1')
				answer2.append('0')
		else:
			answer1.append('0')
			answer2.append('0')
	a = ''.join(answer1)
	b = ''.join(answer2)
	ans.append(a)
	ans.append(b)
for i in range(0, len(ans)):
	print(ans[i])


import math
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	(a, b) = ('1', '1')
	status = False
	for i in range(1, len(s)):
		if s[i] == '0':
			a += '0'
			b += '0'
		elif s[i] == '2':
			if status == False:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
		elif status == False:
			a += '1'
			b += '0'
			status = True
		else:
			a += '0'
			b += '1'
	print(a)
	print(b)


t = int(input())
while t:
	n = int(input())
	l = list(input())
	a = []
	b = []
	j = 0
	for i in range(len(l)):
		if j > 0:
			a.append('0')
			b.append(l[i])
		elif l[i] == '0':
			a.append('0')
			b.append('0')
		elif l[i] == '2':
			a.append('1')
			b.append('1')
		else:
			a.append('1')
			b.append('0')
			j = i
	print(''.join(a))
	print(''.join(b))
	t = t - 1


import math
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	l = []
	l1 = []
	flag = 0
	uper = 0
	lower = 0
	for i in range(n):
		if s[i] == '2' and flag == 0:
			l.append('1')
			l1.append('1')
		elif s[i] == '1' and flag == 0:
			l.append('1')
			l1.append('0')
			flag = 1
			uper = 0
		elif s[i] == '0' and flag == 0:
			l.append('0')
			l1.append('0')
		elif flag == 1:
			if s[i] == '1':
				l.append('0')
				l1.append('1')
			if s[i] == '2':
				l.append('0')
				l1.append('2')
			if s[i] == '0':
				l.append('0')
				l1.append('0')
	print(''.join(l))
	print(''.join(l1))


t = int(input())
for test in range(t):
	n = int(input())
	x = list(input())
	y = 0
	a = []
	b = []
	for i in range(n):
		if x[i] == '2':
			if y == 0:
				a.append(1)
				b.append(1)
			else:
				a.append(0)
				b.append(2)
		elif x[i] == '0':
			a.append(0)
			b.append(0)
		elif x[i] == '1':
			if y == 0:
				a.append(1)
				b.append(0)
				y = 1
			else:
				a.append(0)
				b.append(1)
	for i in range(n):
		print(a[i], end='')
	print()
	for i in range(n):
		print(b[i], end='')
	print()


n = int(input())
for i in range(n):
	k = int(input())
	x = input()
	a = ''
	b = ''
	one = False
	for c in x:
		if one:
			a += '0'
			b += c
			continue
		if c == '2':
			a += '1'
			b += '1'
		elif c == '0':
			a += '0'
			b += '0'
		else:
			one = True
			a += '1'
			b += '0'
	print(a)
	print(b)


def problem(n, x):
	(a, b) = ('', '')
	for i in x:
		if i == '1':
			(a, b) = (a + '1', b + '0')
			return a + '0' * (n - len(a)) + '\n' + b + x[len(b):]
		t = str(int(i) // 2)
		(a, b) = (a + t, b + t)
	return a + '\n' + b
for _ in range(int(input())):
	print(problem(int(input()), input()))


def main():
	T = int(input())
	for t in range(T):
		n = int(input())
		org = list(map(str, input()))
		a = ['1' for i in range(n)]
		b = ['1' for i in range(n)]
		switch = True
		for i in range(1, n):
			c = org[i]
			if c == '2':
				if switch:
					a[i] = 1
					b[i] = 1
				else:
					a[i] = 2
					b[i] = 0
			elif c == '1':
				if switch:
					a[i] = 0
					b[i] = 1
					switch = False
				else:
					a[i] = 1
					b[i] = 0
			else:
				a[i] = 0
				b[i] = 0
		for j in b:
			print(j, sep='', end='')
		print('')
		for j in a:
			print(j, sep='', end='')
		print('')
main()


t = int(input())
while t:
	n = int(input())
	greater = -1
	a = ''
	b = ''
	number = input()
	for i in number:
		temp = int(i)
		if temp == 2:
			if greater == -1:
				a += '1'
				b += '1'
			elif greater == 0:
				a += '0'
				b += '2'
			else:
				a += '2'
				b += '0'
		elif temp == 1:
			if greater == -1:
				greater = 0
				a += '1'
				b += '0'
			else:
				a += '0'
				b += '1'
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)
	t -= 1


for i in range(int(input())):
	n = int(input())
	s = input()
	a = []
	b = []
	n = 1
	for elem in s:
		elem = int(elem)
		if elem % 2 == 0:
			if n:
				a.append(elem // 2)
				b.append(elem // 2)
			else:
				a.append(0)
				b.append(elem)
		elif n:
			a.append(1)
			b.append(0)
			n = 0
		else:
			b.append(1)
			a.append(0)
	print(*a, sep='')
	print(*b, sep='')


for _ in range(int(input())):
	n = int(input())
	x = input()
	a = ''
	b = ''
	greater = ''
	for digit in x:
		if digit == '2':
			if greater:
				if greater == 'a':
					b += '2'
					a += '0'
				elif greater == 'b':
					a += '2'
					b += '0'
			else:
				a += '1'
				b += '1'
		elif digit == '1':
			if greater == 'a':
				b += '1'
				a += '0'
			elif greater == 'b':
				a += '1'
				b += '0'
			else:
				a += '1'
				b += '0'
				greater = 'a'
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


ans = []
for e in range(int(input())):
	n = int(input())
	x = input()
	a = '1'
	b = '1'
	t = 0
	for j in x[1:]:
		if t == 0:
			if j == '2':
				a += '1'
				b += '1'
			elif j == '1':
				a += '1'
				b += '0'
				t = 1
			else:
				a += '0'
				b += '0'
		elif j == '2':
			a += '0'
			b += '2'
		elif j == '1':
			a += '0'
			b += '1'
			t = 1
		else:
			a += '0'
			b += '0'
	ans.append(a)
	ans.append(b)
print('\n'.join(ans))


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	arr = input()
	s1 = ''
	s2 = ''
	index = 1
	for i in arr:
		index += 1
		if i == '0':
			s1 += '0'
			s2 += '0'
		elif i == '2':
			s1 += '1'
			s2 += '1'
		else:
			s1 += '1' + '0' * (n - index + 1)
			s2 += '0' + arr[index - 1:]
			break
	print(s1)
	print(s2)


from heapq import *
from collections import deque
import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]

def main():
	q = II()
	for _ in range(q):
		n = II()
		s = SI()
		a = [0] * n
		b = [0] * n
		one = False
		for (i, c) in enumerate(s):
			if one:
				a[i] = 0
				b[i] = int(c)
			elif c == '1':
				(a[i], b[i]) = (1, 0)
				one = True
			else:
				a[i] = b[i] = int(c) // 2
		print(*a, sep='')
		print(*b, sep='')
main()


import math
t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	(a, b) = ('', '')
	ma = True
	for (j, i) in enumerate(x):
		if i == '2':
			if ma:
				a = a + '1'
				b = b + '1'
			else:
				ma = False
				a = a + '0'
				b = b + '2'
		elif i == '1':
			if ma:
				a = a + '1'
				b = b + '0'
				ma = False
			else:
				ma = False
				a = a + '0'
				b = b + '1'
		else:
			a = a + '0'
			b = b + '0'
	print(a)
	print(b)


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime
from collections import deque
import collections

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(int(input())):
		n = int(input())
		x = input()
		a = ''
		b = ''
		for i in x:
			if i == '2':
				a += '1'
				b += '1'
			if i == '1':
				a += '0'
				b += '1'
			if i == '0':
				a += '0'
				b += '0'
		(a, b) = (max(a, b), min(a, b))
		l = n
		for i in range(n):
			if a[i] != b[i]:
				l = i
				break
		c = ''
		d = ''
		for i in range(l + 1, n):
			k = str(ord(a[i]) + ord(b[i]) - 96)
			c += '0'
			d += k
		print(a[:l + 1] + c)
		print(b[:l + 1] + d)

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


import sys
import sys

def input():
	return sys.stdin.readline()[:-1]

def main():
	t = int(input())
	for _ in range(t):
		n = input()
		l = [int(x) for x in input()]
		f = 0
		a = []
		b = []
		for e in l:
			if e == 2:
				if f == 0:
					a.append('1')
					b.append('1')
				else:
					a.append('0')
					b.append('2')
			elif e == 1:
				if f == 0:
					a.append('1')
					b.append('0')
					f = 1
				else:
					a.append('0')
					b.append('1')
			else:
				a.append('0')
				b.append('0')
		print(''.join(a))
		print(''.join(b))
main()


t = int(input())
for i in range(t):
	n = int(input())
	ch = input()
	test = False
	s1 = ''
	s2 = ''
	for i in range(n):
		if ch[i] == '2':
			if test == False:
				s1 += '1'
				s2 += '1'
			else:
				s1 += '0'
				s2 += '2'
		elif ch[i] == '0':
			s1 += '0'
			s2 += '0'
		elif test:
			s1 += '0'
			s2 += '1'
		else:
			s1 += '1'
			s2 += '0'
			test = True
	print(s1)
	print(s2)


t = int(input())
for _ in range(t):
	n = int(input())
	x = list(map(int, list(input())))
	a = [0] * n
	b = [0] * n
	if x[0] == 1:
		b[0] = 2
		a[0] = 2
	else:
		b[0] = 1
		a[0] = 1
		flag = True
	for i in range(1, len(x)):
		if not flag:
			b[i] = 0
			a[i] = x[i]
		elif flag and x[i] == 2:
			b[i] = 1
			a[i] = 1
		elif flag and x[i] == 0:
			b[i] = 0
			a[i] = 0
		elif flag and x[i] == 1:
			b[i] = 1
			a[i] = 0
			flag = False
	print(*b, sep='')
	print(*a, sep='')


def possible(n, a1):
	condition = True
	a = ''
	b = ''
	for e in str(a1):
		if e == '2':
			if condition:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
		elif e == '1':
			if condition:
				a += '1'
				b += '0'
				condition = False
			else:
				a += '0'
				b += '1'
		else:
			a += '0'
			b += '0'
	return (a, b)
for _ in range(int(input())):
	n = int(input())
	a = int(input())
	(a1, b) = possible(n, a)
	print(a1)
	print(b)


n = int(input())
for i in range(n):
	a = input()
	s = input()
	a = ''
	b = ''
	f = True
	for i in s:
		if i == '0':
			a += i
			b += i
			continue
		if f:
			if i == '1':
				f = False
				a += '1'
				b += '0'
			if i == '2':
				a += '1'
				b += '1'
		else:
			a += '0'
			b += i
	print(a)
	print(b)


t = int(input())
for i in range(t):
	n = int(input())
	m = int(input())
	m = str(m)
	s1 = ''
	s2 = ''
	c = 0
	for j in range(len(m)):
		if m[j] == '2':
			if c == 0:
				s1 += '1'
				s2 += '1'
			else:
				s1 += '0'
				s2 += '2'
		elif m[j] == '0':
			s1 += '0'
			s2 += '0'
		elif m[j] == '1':
			if c == 0:
				s1 += '1'
				s2 += '0'
				c += 1
			else:
				s1 += '0'
				s2 += '1'
	print(int(s1))
	print(int(s2))


for _ in range(int(input())):
	n = int(input())
	a = []
	b = []
	f = 0
	for x in input():
		a += (0,)
		b += (0,)
		if f:
			b[-1] += int(x)
		elif '1' == x:
			a[-1] += 1
			f = 1
		elif '2' == x:
			a[-1] += 1
			b[-1] += 1
	print(''.join(map(str, a)))
	print(''.join(map(str, b)))


for i in range(int(input())):
	n = int(input())
	s = input()
	(o, se) = ('', '')
	count = 0
	for j in range(n):
		if s[j] == '2':
			if count == 1:
				o += '0'
				se += '2'
			else:
				o += '1'
				se += '1'
		if s[j] == '0':
			o += '0'
			se += '0'
		if s[j] == '1':
			if count == 1:
				o += '0'
				se += '1'
			else:
				o += '1'
				se += '0'
				count = 1
	print(o)
	print(se)


n = int(input())
for i in range(n):
	t = int(input())
	l = input()
	a = ''
	b = ''
	f = 0
	for i in range(len(l)):
		if l[i] == '0':
			a = a + '0'
			b = b + '0'
		elif l[i] == '1':
			if f == 0:
				a = a + '1'
				b = b + '0'
				f = 1
			else:
				a = a + '0'
				b = b + '1'
		elif l[i] == '2':
			if f == 1:
				a = a + '0'
				b = b + '2'
			else:
				a = a + '1'
				b = b + '1'
	print(a)
	print(b)


t = int(input())
javab = []
for i in range(0, t):
	n = int(input())
	x = input()
	a = ['', '']
	q = 0
	for j in x:
		if j == '2':
			if q == 0:
				a[0] += '1'
				a[1] += '1'
			else:
				a[0] += '0'
				a[1] += '2'
		elif j == '0':
			a[0] += '0'
			a[1] += '0'
		elif q == 0:
			a[0] += '1'
			a[1] += '0'
			q += 1
		else:
			a[0] += '0'
			a[1] += '1'
	javab.append(a[0])
	javab.append(a[1])
for i in javab:
	print(i)


from sys import stdin, stdout
rr = lambda : input().strip()
rri = lambda : int(rr())
rrm = lambda : [int(x) for x in rr().split()]

def sol():
	n = rri()
	x = rr()
	res1 = '1'
	res2 = '1'
	q = False
	for i in range(1, n):
		if x[i] == '0':
			res1 += '0'
			res2 += '0'
		elif x[i] == '1':
			if q:
				res1 += '0'
				res2 += '1'
			else:
				q = True
				res1 += '1'
				res2 += '0'
		elif q:
			res1 += '0'
			res2 += '2'
		else:
			res1 += '1'
			res2 += '1'
	print(res1)
	print(res2)
	return
T = rri()
for t in range(T):
	sol()


import sys
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda : sys.stdin.readline().rstrip()

def eprint(s):
	sys.stderr.write('DEBUG: {}'.format(s))
	return

def solve(n, x):
	a = list()
	b = list()
	sx = str(x)
	ad = None
	for i in range(n):
		si = sx[i]
		if si == '0':
			a.append(0)
			b.append(0)
		if si == '1':
			if ad is None:
				ad = True
				a.append(0)
				b.append(1)
			else:
				a.append(1)
				b.append(0)
		if si == '2':
			if ad is None:
				a.append(1)
				b.append(1)
			else:
				a.append(2)
				b.append(0)
	print(''.join(map(str, a)))
	print(''.join(map(str, b)))
	return

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		x = int(input())
		solve(n, x)
	return
main()


t = int(input())
for i in range(t):
	(a, b) = ([], [])
	n = int(input())
	s = [int(i) for i in input()]
	ok = False
	ok1 = False
	for i in range(n):
		if s[i] == 0:
			a.append(0)
			b.append(0)
		elif s[i] == 2:
			if ok:
				a.append(0)
				b.append(2)
			else:
				a.append(1)
				b.append(1)
		elif not ok:
			a.append(1)
			b.append(0)
			ok = True
		else:
			a.append(0)
			b.append(1)
	print(''.join(map(str, a)))
	print(''.join(map(str, b)))


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	(a, b) = ('', '')
	is_one_found = False
	for x in s:
		if is_one_found:
			a += '0'
			b += x
		else:
			num = int(x)
			if num == 1:
				is_one_found = True
				a += x
				b += '0'
			else:
				a += str(num // 2)
				b += str(num // 2)
	print(a, b, sep='\n')


for _ in range(int(input())):
	n = int(input())
	v = []
	p = []
	flag = 0
	s = list(input())
	for i in s:
		if flag == 0:
			if i == '2':
				v.append(str(1))
				p.append(str(1))
			elif i == '0':
				v.append(str(0))
				p.append(str(0))
			else:
				v.append(str(1))
				p.append(str(0))
				flag = 1
		elif i == '2':
			v.append(str(0))
			p.append(str(2))
		elif i == '0':
			v.append(str(0))
			p.append(str(0))
		else:
			v.append(str(0))
			p.append(str(1))
	print(''.join(v))
	print(''.join(p))


R = {'2': ['1', '1'], '1': ['1', '0'], '0': ['0', '0']}
S = {'2': ['0', '2'], '1': ['0', '1'], '0': ['0', '0']}
for _ in range(int(input())):
	n = int(input())
	x = input()
	(a, b) = ([], [])
	reg = True
	for c in x:
		if reg:
			(ca, cb) = R[c]
		else:
			(ca, cb) = S[c]
		a.append(ca)
		b.append(cb)
		if c == '1':
			reg = False
	print(''.join(a))
	print(''.join(b))


a = int(input())
for _ in range(a):
	n = int(input())
	k = list(map(int, list(input())))
	m1 = []
	m2 = []
	l1 = 0
	l2 = 0
	for i in range(n):
		if k[i] == 0:
			m1.append(0)
			m2.append(0)
		elif k[i] == 1:
			if l2 == 1 and l1 == 0:
				m1.append(1)
				m2.append(0)
			else:
				m1.append(0)
				m2.append(1)
				l1 = 0
				l2 = 1
		elif k[i] == 2:
			if l2 == 1 and l1 == 0:
				m2.append(0)
				m1.append(2)
			else:
				m1.append(1)
				m2.append(1)
	print(''.join(map(str, m1)))
	print(''.join(map(str, m2)))


def solve():
	d = {0: (0, 0), 1: (1, 0), 2: (1, 1)}
	for _ in range(ii()):
		n = ii()
		s = si()
		a = ''
		b = ''
		found = False
		for i in s:
			if i == '1' and (not found):
				(o, p) = d[int(i)]
				a += str(o)
				b += str(p)
				found = True
				continue
			if found:
				a += '0'
				b += i
			else:
				(o, p) = d[int(i)]
				a += str(o)
				b += str(p)
		print(int(a))
		print(int(b))
ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(mi())
si = lambda : input()
solve()


for _ in range(int(input())):
	n = int(input())
	li = list(input())
	a = []
	b = []
	f = 0
	for i in li:
		if f == 1:
			a.append('0')
			b.append(i)
		else:
			if i == '0':
				a.append('0')
				b.append('0')
			if i == '2':
				a.append('1')
				b.append('1')
			if i == '1':
				f = 1
				a.append('1')
				b.append('0')
	for i in a:
		print(i, end='')
	print()
	for i in b:
		print(i, end='')
	print()


for _ in range(int(input())):
	n = int(input())
	l = list(input())
	l = list(map(int, l))
	a = ''
	b = ''
	t = 0
	for i in l:
		if i == 2:
			if t == 0:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
		elif i == 0:
			b += '0'
			a += '0'
		elif t == 0:
			t = 1
			a += '1'
			b += '0'
		else:
			a += '0'
			b += '1'
	print(a)
	print(b)


from collections import defaultdict as dd, deque as dq
import sys
input = sys.stdin.readline
t = int(input())
while t:
	n = int(input())
	s = input()
	a = '1'
	b = '1'
	lol = 0
	for i in range(1, n):
		if s[i] == '1':
			if lol == 1:
				a += '1'
				b += '0'
			else:
				b += '1'
				a += '0'
			lol = 1
		elif s[i] == '2':
			if lol == 1:
				a += '2'
				b += '0'
			else:
				b += '1'
				a += '1'
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)
	t -= 1


for t in range(int(input())):
	n = int(input())
	a = input()
	(a1, a2) = ([], [])
	f = 0
	for i in a:
		if i == '2':
			if f == 0:
				a1.append(1)
				a2.append(1)
			elif f == 1:
				a1.append(0)
				a2.append(2)
		elif i == '1':
			if f == 0:
				a1.append(1)
				a2.append(0)
				f = 1
			elif f == 1:
				a1.append(0)
				a2.append(1)
		else:
			a1.append(0)
			a2.append(0)
	for j in range(n):
		print(a1[j], end='')
	print()
	for j in range(n):
		print(a2[j], end='')
	print()


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
import math

def gift():
	for _ in range(t):
		n = int(input())
		num = input()
		ans1 = ['1']
		ans2 = ['1']
		for i in range(1, n):
			if num[i] == '0':
				ans1.append('0')
				ans2.append('0')
			elif num[i] == '2':
				ans1.append('1')
				ans2.append('1')
			else:
				ans1.append('1')
				ans1 += [0] * (n - i - 1)
				ans2.append('0')
				ans2 += list(num[i + 1:n + 1])
				break
		yield ''.join((str(x) for x in ans1))
		yield ''.join((str(x) for x in ans2))
t = int(input())
ans = gift()
print(*ans, sep='\n')


for _ in range(int(input())):
	(n, c) = (int(input()), input())
	(a, b) = ('', '')
	first_greater = False
	for i in range(len(c)):
		if first_greater:
			a += '0'
			b += c[i]
		elif c[i] == '0':
			a += '0'
			b += '0'
		elif c[i] == '2':
			a += '1'
			b += '1'
		else:
			a += '1'
			b += '0'
			first_greater = True
	print(a, b, sep='\n')


import sys
from operator import xor

def alele():
	return list(map(int, sys.stdin.readline().strip().split()))

def ilele():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
import bisect
for _ in range(int(input())):
	N = int(input())
	m = 0
	x = input()
	a = '1'
	b = '1'
	for i in range(1, len(x)):
		if x[i] == '0':
			a += '0'
			b += '0'
		elif x[i] == '2':
			if m == 0:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
		elif x[i] == '1':
			if m == 0:
				a += '1'
				b += '0'
				m = 1
			else:
				a += '0'
				b += '1'
	print(a)
	print(b)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	count = 0
	st1 = str(1)
	st2 = str(1)
	for i in range(1, n):
		if s[i] == '2':
			if count == 0:
				st1 += str(1)
				st2 += str(1)
			else:
				st1 += str(0)
				st2 += str(2)
		elif s[i] == '0':
			st1 += str(0)
			st2 += str(0)
		elif count == 0:
			st1 += str(1)
			st2 += str(0)
			count = 1
		else:
			st1 += str(0)
			st2 += str(1)
	print(st1)
	print(st2)


from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def LS():
	return [list(x) for x in sys.stdin.readline().split()]

def S():
	res = list(sys.stdin.readline())
	if res[-1] == '\n':
		return res[:-1]
	return res

def IR(n):
	return [I() for i in range(n)]

def LIR(n):
	return [LI() for i in range(n)]

def SR(n):
	return [S() for i in range(n)]

def LSR(n):
	return [LS() for i in range(n)]
sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
	t = I()
	for _ in range(t):
		n = I()
		x = list(map(int, input()))
		a = []
		b = []
		f = 0
		for i in x:
			if not i:
				a.append(0)
				b.append(0)
			elif i == 2:
				if f:
					a.append(0)
					b.append(2)
				else:
					a.append(1)
					b.append(1)
			elif f:
				a.append(0)
				b.append(1)
			else:
				a.append(1)
				b.append(0)
				f = 1
		print(*a, sep='')
		print(*b, sep='')
	return
solve()


for _ in range(int(input())):
	n = int(input())
	L = input()
	a = '1'
	b = '1'
	T = 1
	for i in range(1, n):
		if L[i] == '0':
			a += '0'
			b += '0'
		elif L[i] == '2' and T:
			a += '1'
			b += '1'
		elif L[i] == '2':
			a += '0'
			b += '2'
		elif T:
			a += '1'
			b += '0'
			T = 0
		else:
			a += '0'
			b += '1'
	print(a + '\n' + b)


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left

def L():
	return list(map(int, stdin.readline().split()))

def In():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())
P = 1000000007
for t in range(I()):
	n = I()
	s = input()
	flag = 0
	(s1, s2) = ('', '')
	for i in range(n):
		if s[i] == '0':
			s1 = s1 + '0'
			s2 = s2 + '0'
		elif s[i] == '1':
			if flag:
				s1 = s1 + '0'
				s2 = s2 + '1'
			else:
				s1 = s1 + '1'
				s2 = s2 + '0'
				flag = 1
		elif flag:
			s1 = s1 + '0'
			s2 = s2 + '2'
		else:
			s1 = s1 + '1'
			s2 = s2 + '1'
	print(s1)
	print(s2)


T = int(input())
for _ in range(T):
	n = int(input())
	s = input()
	flag = False
	a = ''
	b = ''
	for i in range(n):
		if s[i] == '2':
			if flag:
				a += '2'
				b += '0'
			else:
				a += '1'
				b += '1'
		elif s[i] == '1':
			if flag:
				a += '1'
				b += '0'
			else:
				a += '0'
				b += '1'
				flag = True
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


entrada = int(input())
for k in range(entrada):
	n = int(input())
	string = input()
	a = ''
	b = ''
	flag = False
	for k in range(len(string)):
		if string[k] == '2':
			if flag:
				a += '2'
				b += '0'
			else:
				a += '1'
				b += '1'
		elif string[k] == '1':
			a += '1'
			b += '0'
			if not flag:
				flag = True
				(a, b) = (b, a)
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


for t in range(int(input())):
	n = int(input())
	x = list(str(input()))
	a = []
	b = []
	for i in range(n):
		if x[i] == '1':
			a.append('1')
			b.append('0')
			for j in range(i + 1, n):
				a.append('0')
				b.append(str(x[j]))
			break
		elif x[i] == '0':
			a.append('0')
			b.append('0')
		else:
			a.append('1')
			b.append('1')
	a = ''.join(a)
	b = ''.join(b)
	print(a)
	print(b)


import heapq
t = input()
t = int(t)
for case in range(t):
	a = input()
	n = input()
	a = ''
	b = ''
	diff = False
	for i in n:
		if not diff:
			if i != '1':
				if i == '2':
					a += '1'
					b += '1'
				else:
					a += '0'
					b += '0'
			else:
				diff = True
				a += '1'
				b += '0'
		elif i == '2':
			a += '0'
			b += '2'
		elif i == '0':
			a += '0'
			b += '0'
		else:
			a += '0'
			b += '1'
	print(a)
	print(b)


t = int(input())
for _ in range(t):
	n = int(input())
	S = input()
	flag = False
	ans1 = []
	ans2 = []
	for i in range(n):
		if S[i] == '0':
			ans1.append('0')
			ans2.append('0')
		elif S[i] == '1':
			if not flag:
				ans1.append('1')
				ans2.append('0')
				flag = True
			else:
				ans1.append('0')
				ans2.append('1')
		elif not flag:
			ans1.append('1')
			ans2.append('1')
		else:
			ans1.append('0')
			ans2.append('2')
	print(''.join(ans1))
	print(''.join(ans2))


for _ in range(int(input())):
	(n, x) = (int(input()), input())
	(a, b) = (['0'] * n, ['0'] * n)
	f = True
	for i in range(n):
		if f:
			if x[i] != '1':
				a[i] = b[i] = str(int(x[i]) // 2)
			else:
				a[i] = '1'
				f = False
		else:
			b[i] = x[i]
	print(''.join(a))
	print(''.join(b))


for _ in range(int(input())):
	n = int(input())
	l = list(input())
	f = [0] * n
	s = [0] * n
	f1 = 0
	check = 0
	for i in range(n):
		if l[i] == '1':
			check = 1
			if f1 == 0:
				f[i] = '1'
				f1 = 1
				s[i] = '0'
			else:
				f[i] = '0'
				s[i] = '1'
		if l[i] == '0':
			f[i] = '0'
			s[i] = '0'
		if l[i] == '2':
			if check == 0:
				f[i] = '1'
				s[i] = '1'
			else:
				f[i] = '0'
				s[i] = '2'
	print(''.join(f))
	print(''.join(s))


t = int(input())
for _ in range(t):
	inp = int(input())
	c = input()
	a = ''
	b = ''
	more = -1
	for i in range(inp):
		if c[i] == '2':
			if i > 0 and more == 0:
				a += '0'
				b += '2'
			else:
				a += '1'
				b += '1'
		elif c[i] == '1':
			if i > 0 and more == 0:
				a += '0'
				b += '1'
			else:
				a += '1'
				b += '0'
				more = 0
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


t = int(input())
for i2 in range(t):
	n = int(input())
	s = str(input())
	(ans1, ans2) = ([], [])
	mode = 0
	for i in range(n):
		x = ord(s[i]) - 48
		if mode == 1:
			ans2.append(x)
			ans1.append(0)
		elif x % 2 == 0:
			ans1.append(x // 2)
			ans2.append(x // 2)
		else:
			ans1.append(1)
			ans2.append(0)
			mode = 1
	for i in ans1:
		print(i, end='')
	print('')
	for i in ans2:
		print(i, end='')
	print('')


t = int(input())
for i in range(t):
	n = int(input())
	x = list(input())
	a = '1'
	b = '1'
	b1 = '0'
	a1 = '1'
	a2 = '1'
	b2 = '1'
	for i in range(1, n):
		if x[i] == '0':
			a += '0'
			b += '0'
		elif x[i] == '1':
			a += a1
			b += b1
			a1 = '0'
			b1 = '1'
			a2 = '0'
			b2 = '2'
		elif x[i] == '2':
			a += a2
			b += b2
	print(a)
	print(b)


for ekbaar in range(1):
	for tin in range(int(input())):
		n = int(input())
		x = str(input())
		a = []
		b = []
		k = 0
		for _ in range(len(x)):
			if x[_] == '2':
				if k == 0:
					a.append(1)
					b.append(1)
				else:
					a.append(0)
					b.append(2)
			elif x[_] == '0':
				a.append(0)
				b.append(0)
			elif x[_] == '1':
				if k == 0:
					a.append(1)
					b.append(0)
					k = 1
				else:
					a.append(0)
					b.append(1)
		for _ in range(len(a) - 1):
			print(a[_], end='')
		print(a[len(a) - 1])
		for _ in range(len(b) - 1):
			print(b[_], end='')
		print(b[len(b) - 1])


from functools import lru_cache
import bisect
from collections import Counter
import itertools

def solve():
	n = int(input())
	x = input()
	n1 = n2 = ''
	for i in range(len(x)):
		if x[i] == '1':
			if i != 0:
				n1 += '0'
				n2 += '1'
				for j in range(i + 1, len(x)):
					n1 += x[j]
					n2 += '0'
				break
			else:
				n1 += '2'
				n2 += '2'
		elif x[i] == '2':
			n1 += '1'
			n2 += '1'
		else:
			n1 += '0'
			n2 += '0'
	print(n1)
	print(n2)
t = int(input())
for _ in range(t):
	solve()


from sys import stdin, stdout
t = int(stdin.readline())
while t:
	n = int(stdin.readline())
	x = stdin.readline()
	a = ['1']
	b = ['1']
	fin = False
	for i in range(1, n):
		num = x[i]
		if fin:
			a.append('0' * (n - len(a)))
			b.append(x[len(b):])
			break
		elif num == '2':
			a.append('1')
			b.append('1')
		elif num == '1':
			a.append('1')
			b.append('0')
			fin = True
		else:
			a.append('0')
			b.append('0')
	stdout.write(''.join(a))
	stdout.write('\n')
	stdout.write(''.join(b))
	stdout.write('\n')
	t -= 1


for _ in [0] * int(input()):
	d = {'1': '1', '2': '1', '0': '0'}
	db = {'1': '0', '2': '1', '0': '0'}
	n = int(input())
	s = input()
	a = ''
	b = ''
	c = 0
	for x in s:
		if c == 0 and x == '1':
			a = a + '1'
			b = b + '0'
			d['2'] = '0'
			d['1'] = '0'
			db['2'] = '2'
			db['1'] = '1'
			c = 1
		else:
			a = a + d[x]
			b = b + db[x]
	print(a)
	print(b)


for _ in range(int(input())):
	n = int(input())
	s = input()
	a = ''
	b = ''
	same = True
	for i in range(n):
		if s[i] == '2':
			if not same:
				a += '0'
				b += '2'
			else:
				a += '1'
				b += '1'
		elif s[i] == '1':
			if same:
				a += '1'
				b += '0'
				same = False
			else:
				a += '0'
				b += '1'
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


for _ in range(int(input())):
	n = int(input())
	x = input()
	a = ''
	b = ''
	for y in range(n):
		if x[y] == '2':
			a += '1'
			b += '1'
		elif x[y] == '0':
			a += '0'
			b += '0'
		else:
			a += '1' + '0' * (n - y - 1)
			b += '0' + x[y + 1:n]
			break
	print(int(a), end='\n')
	print(int(b), end='\n')


cases = int(input())

def split(word):
	return list(word)
while cases:
	res = []
	a = []
	b = []
	n = int(input())
	m = input()
	arr = split(m)
	for k in arr:
		res.append(int(k))
	flip = 1
	i = 0
	while i < n:
		if res[i] == 2 and flip == 1:
			a.append('1')
			b.append('1')
		elif res[i] == 2 and flip != 1:
			a.append('0')
			b.append('2')
		elif res[i] == 1:
			if flip == 1:
				a.append('1')
				b.append('0')
				flip = 0
			else:
				a.append('0')
				b.append('1')
		else:
			a.append('0')
			b.append('0')
		i = i + 1
	cases = cases - 1
	af = ''.join(a)
	bf = ''.join(b)
	print(af)
	print(bf)
	del res
	del a
	del b


t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	aBuilder = '1'
	bBuilder = '1'
	if n == 1:
		print(aBuilder)
		print(bBuilder)
	else:
		inequal = False
		for c in x[1:]:
			if c == '0':
				aBuilder += '0'
				bBuilder += '0'
			elif c == '1':
				if not inequal:
					aBuilder += '1'
					inequal = True
					bBuilder += '0'
				else:
					aBuilder += '0'
					bBuilder += '1'
			elif c == '2':
				if inequal:
					aBuilder += '0'
					bBuilder += '2'
				else:
					aBuilder += '1'
					bBuilder += '1'
		print(aBuilder)
		print(bBuilder)


t = int(input())
for _ in range(t):
	n = int(input())
	a = ''
	b = ''
	o1 = False
	for d in input():
		if not o1:
			if d == '2':
				a += '1'
				b += '1'
			elif d == '1':
				a += '1'
				b += '0'
				o1 = True
			elif d == '0':
				a += '0'
				b += '0'
		else:
			a += '0'
			b += d
	print(a)
	print(b)


for t in range(int(input())):
	n = int(input())
	x = list(input())
	mini = ['1']
	maxi = ['1']
	diff = 0
	for i in range(1, n):
		if diff == 0:
			if x[i] == '0':
				mini.append('0')
				maxi.append('0')
			elif x[i] == '1':
				mini.append('0')
				maxi.append('1')
				diff = 1
			elif x[i] == '2':
				mini.append('1')
				maxi.append('1')
		elif x[i] == '0':
			mini.append('0')
			maxi.append('0')
		elif x[i] == '1':
			mini.append('1')
			maxi.append('0')
		elif x[i] == '2':
			mini.append('2')
			maxi.append('0')
	print(''.join(mini))
	print(''.join(maxi))


z = int(input())
for i in range(z):
	n = int(input())
	x = list(input())
	r = 1
	a = [1]
	b = [1]
	ind = 1
	k = -1
	while ind < n:
		x[ind] = int(x[ind])
		if x[ind] % 2 == 0:
			c = x[ind] // 2
			a.append(c)
			b.append(c)
		else:
			k = ind
			ind = n + 9
		ind += 1
	if k != -1:
		x[k] = int(x[k])
		c = x[k] // 2
		a.append(c + 1)
		b.append(c)
		for i in range(k + 1, n):
			x[i] = int(x[i])
			b.append(x[i])
			a.append(0)
	f = ''
	g = ''
	for i in range(n):
		f += str(a[i])
		g += str(b[i])
	print(f)
	print(g)


for i in range(int(input())):
	answer1 = []
	answer2 = []
	long = int(input())
	n = list(map(int, list(input())))
	signal = 0
	for j in range(long):
		if signal == 0:
			if n[j] == 0:
				answer1.append('0')
				answer2.append('0')
			elif n[j] == 2:
				answer1.append('1')
				answer2.append('1')
			else:
				answer1.append('0')
				answer2.append('1')
				signal = 1
		elif signal == 1:
			answer1.append(str(n[j]))
			answer2.append('0')
	print(int(''.join(answer1)))
	print(int(''.join(answer2)))


def main():
	test = int(input())
	for t in range(test):
		n = int(input())
		x = input()
		a = ''
		b = ''
		flag = False
		for i in x:
			if not flag:
				if i == '2':
					a += '1'
					b += '1'
				elif i == '1':
					a += '1'
					b += '0'
					flag = True
				else:
					a += '0'
					b += '0'
			elif i == '2':
				a += '0'
				b += '2'
			elif i == '1':
				a += '0'
				b += '1'
				flag = True
			else:
				a += '0'
				b += '0'
		print(a)
		print(b)
main()


d = {}
d['0', '1'] = '1'
d['1', '1'] = '2'
d['1', '0'] = '1'
d['0', '0'] = '0'
d['0', '2'] = '2'
d['2', '0'] = '2'
for _ in range(int(input())):
	n = int(input())
	x = input()
	a = '1'
	b = '1'
	for i in range(1, n):
		if x[i] == '0':
			a = a + '0'
			b = b + '0'
		elif x[i] == '1':
			a += '0'
			b += '1'
		else:
			a += '1'
			b += '1'
	flag = 2
	pos = -1
	for i in range(n):
		if a[i] > b[i]:
			pos = i + 1
			flag = 1
			break
		elif a[i] < b[i]:
			pos = i + 1
			flag = 0
			break
	if flag != 2:
		if flag == 1:
			c = ''
			for j in range(pos, n):
				c += d[b[j], a[j]]
			b = b[:pos] + c
			a = a[:pos] + '0' * (n - pos)
		else:
			c = ''
			for j in range(pos, n):
				c += d[b[j], a[j]]
			a = a[:pos] + c
			b = b[:pos] + '0' * (n - pos)
	print(a)
	print(b)


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from collections import Counter
from bisect import bisect_left
import sys
from queue import PriorityQueue
import operator as op
from functools import reduce
mod = 1000000007

def L():
	return list(map(int, stdin.readline().split()))

def In():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())

def printIn(ob):
	return stdout.write(str(ob) + '\n')

def powerLL(n, p):
	result = 1
	while p:
		if p & 1:
			result = result * n % mod
		p = int(p / 2)
		n = n * n % mod
	return result

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def myCode():
	n = I()
	s = input()
	a = ['0'] * n
	b = ['0'] * n
	for i in range(len(s)):
		if s[i] == '1':
			a[i] = '1'
			b[i] = '0'
			for j in range(i + 1, len(s)):
				b[j] = s[j]
			break
		elif s[i] == '2':
			a[i] = '1'
			b[i] = '1'
	print(''.join(a))
	print(''.join(b))

def main():
	for t in range(I()):
		myCode()
main()


def solve(s):
	a = ['1']
	b = ['1']
	diffed = False
	for i in range(1, len(s)):
		if s[i] == '2':
			if diffed:
				a.append('0')
				b.append('2')
			else:
				a.append('1')
				b.append('1')
		elif s[i] == '1':
			if diffed:
				a.append('0')
				b.append('1')
			else:
				a.append('1')
				b.append('0')
				diffed = True
		else:
			a.append('0')
			b.append('0')
	return (''.join(a), ''.join(b))
t = int(input())
for _ in range(t):
	n = int(input())
	c = input()
	(a, b) = solve(c)
	print(a)
	print(b)


for t in range(int(input())):
	n = int(input())
	s = input()
	ans = ''
	temp = ''
	i = 0
	while i < n:
		if s[i] == '0':
			ans += '0'
			temp += '0'
		elif s[i] == '2':
			ans += '1'
			temp += '1'
		else:
			ans += '1'
			temp += '0'
			break
		i += 1
	ans += ''.join(['0' for j in range(n - i - 1)])
	temp += s[i + 1:]
	print(ans)
	print(temp)


tc = int(input())
while tc > 0:
	n = int(input())
	s = input()
	a = ['1'] * n
	b = ['1'] * n
	one = False
	for (i, c) in enumerate(s):
		if c == '1':
			a[i] = '0' if one else c
			b[i] = c if one else '0'
			one = True
		elif c == '0':
			a[i] = c
			b[i] = c
		elif c == '2' and one:
			a[i] = '0' if one else c
			b[i] = c if one else '0'
	print(''.join(a))
	print(''.join(b))
	tc -= 1


def solve():
	n = int(input())
	x = input()
	a = [0] * n
	b = [0] * n
	(a[0], b[0]) = (1, 1)
	j = -1
	for i in range(1, n - 1):
		if x[i] == '1':
			j = i
			break
	if j != -1:
		for i in range(1, j):
			a[i] = b[i] = (ord(x[i]) - ord('0')) // 2
		(a[j], b[j]) = (1, 0)
		for i in range(j + 1, n):
			(a[i], b[i]) = (0, ord(x[i]) - ord('0'))
	else:
		for i in range(1, n):
			if x[i] == '0' or x[i] == '2':
				a[i] = b[i] = (ord(x[i]) - ord('0')) // 2
			else:
				(a[i], b[i]) = (1, 0)
	print(''.join((str(x) for x in a)))
	print(''.join((str(x) for x in b)))
for _ in range(int(input())):
	solve()


t = int(input())
while t > 0:
	n = int(input())
	x = input()
	a = '1'
	b = '1'
	i = 1
	while i < n and x[i] != '1':
		if x[i] == '2':
			a = a + '1'
			b = b + '1'
		if x[i] == '0':
			a = a + '0'
			b = b + '0'
		i += 1
	if i < n:
		a = a + '0'
		b = b + '1'
		i += 1
	while i < n:
		if x[i] == '0':
			a = a + '0'
			b = b + '0'
		elif x[i] == '2':
			b = b + '0'
			a = a + '2'
		elif x[i] == '1':
			a = a + '1'
			b = b + '0'
		i += 1
	print(a)
	print(b)
	t -= 1


T = int(input())
for _ in range(T):
	n = int(input())
	s = input()
	(a, b) = ([], [])
	firstOne = True
	for c in s:
		if c == '0':
			a.append('0')
			b.append('0')
		elif c == '1':
			if firstOne:
				a.append('1')
				b.append('0')
				firstOne = False
			else:
				a.append('0')
				b.append('1')
		elif c == '2':
			if firstOne:
				a.append('1')
				b.append('1')
			else:
				a.append('0')
				b.append('2')
	print(''.join(a))
	print(''.join(b))


for _ in range(int(input())):
	n = int(input())
	k = str(input())
	a = ''
	b = ''
	p = 0
	for i in range(n):
		if i == 0:
			if k[i] == '1':
				a += '2'
				b += '2'
			elif k[i] == '2':
				a += '1'
				b += '1'
			else:
				a += '2'
				b += '1'
				p += 1
		elif p == 0:
			if k[i] == '1':
				a += '1'
				b += '0'
				p += 1
			elif k[i] == '2':
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '0'
		elif p > 0:
			p += 1
			if k[i] == '1':
				a += '0'
				b += '1'
			elif k[i] == '2':
				a += '0'
				b += '2'
			else:
				a += '0'
				b += '0'
	print(a)
	print(b)


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	num = list(stdin.readline())
	counter2 = 0
	counter1 = 0
	a = []
	b = []
	for i in range(n):
		if num[i] == '2' and counter2 == 0:
			a.append('1')
			b.append('1')
		elif num[i] == '1' and counter1 == 0:
			counter1 = 1
			counter2 = 1
			a.append('1')
			b.append('0')
		elif num[i] == '0':
			a.append('0')
			b.append('0')
		elif num[i] == '2' and counter2 == 1:
			a.append('0')
			b.append('2')
		else:
			a.append('0')
			b.append('1')
	stdout.write(''.join(a) + '\n')
	stdout.write(''.join(b) + '\n')


t = int(input())
for _ in range(t):
	n = int(input())
	x = input().strip()
	flag = False
	ans1 = ''
	ans2 = ''
	for c in x:
		if c == '0':
			ans1 += '0'
			ans2 += '0'
		elif flag:
			ans1 += '0'
			ans2 += c
		elif c == '1':
			ans1 += '1'
			ans2 += '0'
			flag = True
		else:
			ans1 += '1'
			ans2 += '1'
	print(ans1)
	print(ans2)


import math

def bst(x, swap):
	if not swap:
		if x == '2':
			return (1, 1, False)
		if x == '1':
			return (0, 1, True)
		return (0, 0, False)
	else:
		if x == '2':
			return (0, 2, False)
		if x == '1':
			return (0, 1, False)
		return (0, 0, False)
t = int(input())
for _ in range(t):
	n = int(input())
	st = input()
	a = []
	b = []
	swap = False
	for i in range(n):
		(aa, bb, tt) = bst(st[i], swap)
		if swap:
			a.append(str(aa))
			b.append(str(bb))
		else:
			a.append(str(bb))
			b.append(str(aa))
		swap = swap or tt
	print(''.join(a))
	print(''.join(b))


tests = int(input())
for t in range(tests):
	N = int(input())
	original_num = input()
	soln = ['1', '1']
	flag = 1
	start = 1
	for i in range(1, N):
		if original_num[i] == '2':
			soln[0] += '1'
			soln[1] += '1'
		elif original_num[i] == '0':
			soln[0] += '0'
			soln[1] += '0'
		else:
			soln[flag % 2] += '1'
			soln[(flag + 1) % 2] += '0'
			flag += 1
			start = i + 1
			break
		start = i + 1
	for i in range(start, N):
		if original_num[i] == '2':
			soln[flag % 2] += '2'
			soln[(flag + 1) % 2] += '0'
		elif original_num[i] == '0':
			soln[0] += '0'
			soln[1] += '0'
		else:
			soln[flag % 2] += '1'
			soln[(flag + 1) % 2] += '0'
	print(soln[0])
	print(soln[1])


t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	s1 = ''
	s2 = ''
	k = 0
	for i in x:
		if i == '2':
			if k == 0:
				s1 += '1'
				s2 += '1'
			elif k == 1:
				s1 += '0'
				s2 += i
		elif i == '0':
			s1 += '0'
			s2 += '0'
		elif i == '1':
			if k == 0:
				k = 1
				s1 += '1'
				s2 += '0'
			elif k == 1:
				s1 += '0'
				s2 += '1'
	print(s1)
	print(s2)


t = int(input())
for _ in range(t):
	l = int(input())
	x = input()[1:]
	ans1 = '1'
	ans2 = '1'
	for i in x:
		if i == '1':
			if ans1 >= ans2:
				ans2 += '1'
				ans1 += '0'
			else:
				ans2 += '0'
				ans1 += '1'
		elif i == '2':
			if ans1 > ans2:
				ans2 += '2'
				ans1 += '0'
			elif ans1 < ans2:
				ans2 += '0'
				ans1 += '2'
			else:
				ans2 += '1'
				ans1 += '1'
		else:
			ans1 += '0'
			ans2 += '0'
	print(ans1, ans2, sep='\n')


t = int(input())
for you in range(t):
	n = int(input())
	x = input()
	l1 = [1]
	l2 = [1]
	g = 2
	for i in range(1, n):
		if x[i] == '0':
			l1.append(0)
			l2.append(0)
		elif x[i] == '1':
			if g == 2:
				l1.append(1)
				l2.append(0)
				g = 1
			else:
				l1.append(0)
				l2.append(1)
		elif x[i] == '2':
			if g == 2:
				l1.append(1)
				l2.append(1)
			else:
				l1.append(0)
				l2.append(2)
	for i in range(n):
		print(l1[i], end='')
	print()
	for i in range(n):
		print(l2[i], end='')
	print()


for _ in range(int(input())):
	n = int(input())
	x = input()
	a = ''
	b = ''
	flog = 0
	i = 0
	while flog != 1 and i < n:
		if x[i] == '0':
			a += '0'
			b += '0'
		elif x[i] == '1':
			a += '1'
			b += '0'
			flog = 1
		elif x[i] == '2':
			a += '1'
			b += '1'
		i += 1
	a += '0' * (n - i)
	b += x[i:]
	print(a)
	print(b)


for _ in range(int(input())):
	n = int(input())
	S = input()
	flag = False
	Max = str()
	Min = str()
	for i in range(n):
		if S[i] == '2' and flag == False:
			Max += '1'
			Min += '1'
		elif S[i] == '2' and flag == True:
			Max += '0'
			Min += '2'
		elif S[i] == '1' and flag == False:
			flag = True
			Max += '1'
			Min += '0'
		elif S[i] == '1' and flag == True:
			Max += '0'
			Min += '1'
		elif S[i] == '0':
			Max += '0'
			Min += '0'
	print(Max)
	print(Min)


t = int(input())
while t:
	n = int(input())
	x = input()
	x = list(x)
	x = [int(y) for y in x]
	a = []
	b = []
	flag = False
	for dig in x:
		if dig == 0:
			a.append('0')
			b.append('0')
		elif dig == 1:
			if not flag:
				a.append('1')
				b.append('0')
				flag = True
			else:
				a.append('0')
				b.append('1')
		elif not flag:
			a.append('1')
			b.append('1')
		else:
			a.append('0')
			b.append('2')
	print(''.join(a))
	print(''.join(b))
	t -= 1


import sys
input = sys.stdin.readline
from collections import *
from math import *
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = input()
	flag = 0
	s = '1'
	s1 = '1'
	for i in range(1, n):
		if a[i] == '0':
			s += '0'
			s1 += '0'
		elif a[i] == '1':
			if flag == 0:
				flag = 1
				s += '1'
				s1 += '0'
			else:
				s += '0'
				s1 += '1'
		elif flag == 0:
			s += '1'
			s1 += '1'
		else:
			s += '0'
			s1 += '2'
	print(s)
	print(s1)


t = int(input())
for i in range(t):
	n = int(input())
	m = input()
	a = ''
	b = ''
	flag = 0
	for j in range(n):
		if m[j] == '1':
			a += m[j] + '0' * (n - len(m[:j + 1]))
			b += '0' + m[j + 1:]
			break
		elif m[j] == '2':
			a += '1'
			b += '1'
		elif m[j] == '0':
			a += '0'
			b += '0'
	print(a)
	print(b)


import os
import sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		n = int(input())
		s = input()
		fl = False
		a = ''
		b = ''
		for x in s:
			if x == '0':
				a += '0'
				b += '0'
			if x == '2':
				if fl:
					a += '2'
					b += '0'
				else:
					a += '1'
					b += '1'
			if x == '1':
				if fl:
					a += '1'
					b += '0'
				else:
					a += '0'
					b += '1'
					fl = True
		print(a)
		print(b)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def main():
	t = int(input())
	for __ in range(t):
		n = input()
		x = input()
		a = ['1']
		b = ['1']
		c = {'0': ('0', '0'), '1': ('1', '0'), '2': ('1', '1')}
		max_found = False
		for i in x[1:]:
			if max_found:
				a.append(c[i][1])
				b.append(c[i][0])
			elif a[-1] == b[-1] and i == '1':
				max_found = True
				c['2'] = ('0', '2')
				a.append(c[i][1])
				b.append(c[i][0])
				c['1'] = ('0', '1')
			else:
				a.append(c[i][0])
				b.append(c[i][1])
		print(''.join(a))
		print(''.join(b))
main()


def li():
	return list(map(int, input().split()))

def ii():
	return int(input())
from math import ceil
tes = int(input())
for t in range(tes):
	l = int(input())
	n = input()
	ans1 = ''
	ans2 = ''
	for (i, x) in enumerate(n):
		ans1 += str(ceil(int(x) / 2))
		if x == '1':
			ans1 += '0' * (l - i - 1)
			break
	ans2 = ''
	for i in range(l):
		ans2 += str(int(n[i]) - int(ans1[i]))
	print(ans1)
	print(ans2)


t = int(input())
ans = []
for _ in range(t):
	n = int(input())
	a = input()
	f = []
	s = []
	first = True
	for i in a:
		if i == '0':
			f.append(0)
			s.append(0)
		if i == '1':
			if first:
				f.append(1)
				s.append(0)
				first = False
			else:
				f.append(0)
				s.append(1)
		if i == '2':
			if first:
				f.append(1)
				s.append(1)
			else:
				f.append(0)
				s.append(2)
	f = ''.join(map(str, f))
	s = ''.join(map(str, s))
	ans.append((f, s))
for i in ans:
	print(*i, sep='\n')


t = int(input())
for i in range(t):
	n = int(input())
	x = list(input())
	ans1 = [0] * n
	ans2 = [0] * n
	flg = True
	for j in range(n):
		if x[j] == '0':
			(ans1[j], ans2[j]) = (0, 0)
		elif x[j] == '1':
			if flg:
				(ans1[j], ans2[j]) = (1, 0)
			else:
				(ans1[j], ans2[j]) = (0, 1)
			flg = False
		elif flg:
			(ans1[j], ans2[j]) = (1, 1)
		else:
			(ans1[j], ans2[j]) = (0, 2)
	for j in range(n):
		print(ans1[j], end='')
	print()
	for j in range(n):
		print(ans2[j], end='')
	print()


n = int(input())
for _ in range(n):
	input()
	s = input()
	s1 = list()
	s2 = list()
	maxed_first = False
	for c in s:
		if c == '0':
			s1.append('0')
			s2.append('0')
		elif c == '1':
			if maxed_first:
				s1.append('0')
				s2.append('1')
			else:
				s1.append('1')
				s2.append('0')
				maxed_first = True
		elif maxed_first:
			s1.append('0')
			s2.append('2')
		else:
			s1.append('1')
			s2.append('1')
	print(''.join(s1))
	print(''.join(s2))


def run(n, x):
	r = 0
	(a, b) = (['x'] * n, ['x'] * n)
	s = list(x)
	for i in range(n):
		c = s[i]
		if c == '0':
			a[i] = '0'
			b[i] = '0'
		if r == 1:
			if c == '1':
				a[i] = '0'
				b[i] = '1'
			if c == '2':
				a[i] = '0'
				b[i] = '2'
		if r == 0:
			if c == '1':
				a[i] = '1'
				b[i] = '0'
				r = 1
			if c == '2':
				a[i] = '1'
				b[i] = '1'
	return [''.join(a), ''.join(b)]
i = int(input())
for j in range(i):
	(a, b) = run(int(input()), input())
	print(a)
	print(b)


kl = int(input())
for l in range(kl):
	n = int(input())
	s = str(input())
	x = '1'
	y = '1'
	k = 0
	pr = 0
	for i in range(1, n):
		k += 1
		if s[i] == '2':
			x = x + '1'
			y = y + '1'
		if s[i] == '0':
			x = x + '0'
			y = y + '0'
		if s[i] == '1':
			pr = 1
			break
	if pr:
		x = x + '1' + '0' * (n - k - 1)
		y = y + '0' + s[k + 1:]
	print(x)
	print(y)


for _ in range(int(input())):
	n = int(input())
	x = input()
	a = ''
	b = ''
	a += '1'
	b += '1'
	comes1 = 0
	for i in range(1, n):
		if comes1 == 0:
			if x[i] == '1':
				a += '1'
				b += '0'
				comes1 = 1
			elif x[i] == '2':
				a += '1'
				b += '1'
			elif x[i] == '0':
				a += '0'
				b += '0'
		elif comes1 == 1:
			if x[i] == '1':
				a += '0'
				b += '1'
			elif x[i] == '2':
				a += '0'
				b += '2'
			elif x[i] == '0':
				a += '0'
				b += '0'
	print(a)
	print(b)


for _ in range(int(input())):
	num = int(input())
	ls1 = []
	ls2 = []
	t = input()
	a = 1
	for i in range(num):
		if t[i] == '2' and a != 1:
			ls1.append('0')
			ls2.append('2')
		if t[i] == '2' and a == 1:
			ls1.append('1')
			ls2.append('1')
		elif t[i] == '1' and a == 1:
			ls1.append('1')
			ls2.append('0')
			a = 2
		elif t[i] == '1' and a != 1:
			ls1.append('0')
			ls2.append('1')
		elif t[i] == '0':
			ls1.append('0')
			ls2.append('0')
	print(''.join(ls1))
	print(''.join(ls2))


t = int(input())
for i in range(1, t + 1):
	n = int(input())
	num = input()
	A = ['0' for x in range(len(num))]
	for idx in range(len(num)):
		n = num[idx]
		if n == '2':
			A[idx] = '1'
		if n == '0':
			A[idx] = '0'
		if n == '1':
			A[idx] = '1'
			break
	A = int(''.join(A))
	print(A)
	print(int(num) - A)


import sys
input = sys.stdin.readline
for j in range(int(input())):
	n = int(input())
	x = input()
	a = []
	b = []
	bSmaller = False
	for go in range(n):
		if x[go] == '2':
			if bSmaller == True:
				a.append('0')
				b.append('2')
			else:
				a.append('1')
				b.append('1')
		elif x[go] == '1':
			if bSmaller == False:
				a.append('1')
				b.append('0')
				bSmaller = True
			else:
				a.append('0')
				b.append('1')
		else:
			a.append('0')
			b.append('0')
	print(''.join(a))
	print(''.join(b))


for _ in range(int(input())):
	max = False
	(x, string) = (int(input()), input())
	a = ''
	b = ''
	for i in string:
		if i == '0':
			a += '0'
			b += '0'
		elif i == '2':
			if max == False:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
		elif max == False:
			a += '1'
			b += '0'
			max = True
		else:
			a += '0'
			b += '1'
	print(a)
	print(b)


from math import ceil

class Solution:

	def __init__(self):
		self.n = int(input())
		self.x = int(input())

	def solve_and_print(self):
		c = str(self.x)
		(a, b) = ([], [])
		i = 0
		while i < len(c) and (c[i] == '2' or c[i] == '0'):
			if c[i] == '0':
				a.append(0)
				b.append(0)
			else:
				a.append('1')
				b.append('1')
			i += 1
		if i < len(c):
			a.append('1')
			b.append('0')
			i += 1
		while i < len(c):
			if c[i] == '0':
				a.append('0')
				b.append('0')
			elif c[i] == '1':
				a.append('0')
				b.append('1')
			else:
				a.append('0')
				b.append('2')
			i += 1
		a = int(''.join((str(i) for i in a)))
		b = int(''.join((str(i) for i in b)))
		print(f'{a}\n{b}')
for _ in range(int(input())):
	Solution().solve_and_print()


def solve(n, x):
	a = ['1']
	b = ['1']
	zero_one = False
	i = 1
	while i < n:
		xi = x[i]
		if zero_one:
			a.append('0')
			b.append(xi)
		elif xi == '0' or xi == '2':
			xi = int(xi) // 2
			a.append(str(xi))
			b.append(str(xi))
		else:
			a.append('1')
			b.append('0')
			zero_one = True
		i += 1
	return (a, b)
t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	(a, b) = solve(n, x)
	print(''.join(a))
	print(''.join(b))


q = int(input())
for z in range(q):
	n = int(input())
	a = ''
	b = ''
	s = input()
	f = s.find('1')
	if f == -1:
		for i in s:
			if i == '2':
				a += '1'
				b += '1'
			elif i == '0':
				a += '0'
				b += '0'
	else:
		for i in range(0, len(s)):
			if i <= f:
				if s[i] == '2':
					a += '1'
					b += '1'
				elif s[i] == '1':
					a += '1'
					b += '0'
				elif s[i] == '0':
					a += '0'
					b += '0'
			elif s[i] == '2':
				a += '0'
				b += '2'
			elif s[i] == '1':
				a += '0'
				b += '1'
			elif s[i] == '0':
				a += '0'
				b += '0'
	print(a)
	print(b)


for _ in range(int(input())):
	n = int(input())
	s = input()
	a = ''
	b = ''
	con = 1
	for x in range(n):
		if s[x] != '1' and con:
			if s[x] == '2':
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '0'
		elif con == 0:
			a += s[x]
			b += '0'
		else:
			con = 0
			a += '0'
			b += '1'
	print(a)
	print(b)


import os
import sys
if os.path.exists('/mnt/c/Users/Square/square/codeforces'):
	f = iter(open('C.txt').readlines())

	def input():
		return next(f).strip()
else:
	input = lambda : sys.stdin.readline().strip()
fprint = lambda *args: print(*args, flush=True)
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	has_one = False
	(res1, res2) = ([], [])
	for i in s:
		if i == '2':
			if has_one:
				res1.append('0')
				res2.append('2')
			else:
				res1.append('1')
				res2.append('1')
		elif i == '1':
			if has_one:
				res1.append('0')
				res2.append('1')
			else:
				res1.append('1')
				res2.append('0')
				has_one = True
		else:
			res1.append('0')
			res2.append('0')
	print(''.join(res1))
	print(''.join(res2))


def if_none(boolean):
	global a_smaller
	if a_smaller is None:
		a_smaller = boolean
for _ in range(int(input())):
	input()
	(a, b) = ('', '')
	a_smaller = None
	for num in input():
		if num == '2':
			if a_smaller is None:
				a += '1'
				b += '1'
			elif a_smaller is True:
				a += '2'
				b += '0'
				if_none(False)
			else:
				a += '0'
				b += '2'
				if_none(True)
		elif num == '0':
			a += '0'
			b += '0'
		elif a_smaller is None:
			a += '1'
			b += '0'
			if_none(False)
		elif a_smaller is True:
			a += '1'
			b += '0'
			if_none(False)
		else:
			a += '0'
			b += '1'
			if_none(True)
	print(a)
	print(b)


for t in range(int(input())):
	n = int(input())
	x = input()
	s = 0
	a = ['1']
	b = ['1']
	for i in range(1, n):
		if x[i] == '0':
			a.append('0')
			b.append('0')
		elif x[i] == '1':
			if s == 0:
				a.append('1')
				b.append('0')
				s = 1
			else:
				a.append('0')
				b.append('1')
		elif s == 0:
			a.append('1')
			b.append('1')
		else:
			a.append('0')
			b.append('2')
	print(''.join(a))
	print(''.join(b))


import sys
t = int(input())
g = sys.stdin.readlines()
y = 0
for _ in range(t):
	n = int(g[y])
	y += 1
	a = list(g[y])[:n]
	y += 1
	first = [0] * n
	second = [0] * n
	answer = [[0] * n for i in range(2)]
	f = False
	for i in range(n):
		if a[i] == '2':
			if not f:
				answer[0][i] = '1'
				answer[1][i] = '1'
			else:
				answer[0][i] = '0'
				answer[1][i] = '2'
		elif a[i] == '1':
			if not f:
				answer[0][i] = '1'
				answer[1][i] = '0'
				f = True
			else:
				answer[0][i] = '0'
				answer[1][i] = '1'
		else:
			first[i] = '0'
			second[i] = '0'
	print(*answer[0], sep='')
	print(*answer[1], sep='')


n = int(input())
l = [[0, 1], [1, 0]]
q = [[1, 1], [2, 0], [0, 2]]
for i in range(0, n):
	p = int(input())
	L = []
	Q = []
	I = 0
	s = input().rstrip()
	x = list(s)
	for j in range(0, len(x)):
		if j == 0 or (int(x[j]) == 2 and I == 0):
			L.append('1')
			Q.append('1')
		elif int(x[j]) == 0:
			L.append('0')
			Q.append('0')
		elif int(x[j]) == 2:
			L.append('0')
			Q.append('2')
		elif I == 0:
			I = 1
			L.append('1')
			Q.append('0')
		else:
			L.append('0')
			Q.append('1')
	print(''.join(L))
	print(''.join(Q))


import sys
for _ in range(int(input())):
	n = int(input())
	s = sys.stdin.readline()
	p = '1'
	q = '1'
	c = 0
	for i in range(1, n):
		if s[i] == '0':
			p = p + '0'
			q = q + '0'
		elif s[i] == '1':
			if c:
				p = p + '1'
				q = q + '0'
			else:
				p = p + '0'
				q = q + '1'
			c = 1
		elif c == 0:
			p = p + '1'
			q = q + '1'
		else:
			p = p + '2'
			q = q + '0'
	print(p)
	print(q)


for _ in range(int(input())):
	n = int(input())
	s = input()
	(a, b, f) = ('1', '1', 0)
	for i in range(1, n):
		if s[i] == '2' and f == 0:
			a += '1'
			b += '1'
		elif s[i] == '2' and f == 1:
			a += '0'
			b += '2'
		elif s[i] == '1' and f == 0:
			f = 1
			a += '1'
			b += '0'
		elif s[i] == '1' and f == 1:
			a += '0'
			b += '1'
		elif s[i] == '0':
			a += '0'
			b += '0'
	print(a)
	print(b)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	a = ''
	b = ''
	if '1' in s:
		h = s.index('1')
		for i in range(h):
			if s[i] == '2':
				a += '1'
				b += '1'
			if s[i] == '0':
				a += '0'
				b += '0'
		a += '1'
		b += '0'
		for i in range(h + 1, n):
			a += '0'
			b += s[i]
	else:
		for i in s:
			if i == '2':
				a += '1'
				b += '1'
			if i == '0':
				a += '0'
				b += '0'
			if i == '1':
				a += '1'
				b += '0'
	print(a)
	print(b)


import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
from functools import lru_cache
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

def input():
	return sys.stdin.readline()

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
for _ in range(int(input())):
	n = int(input())
	x = input().strip()
	s1 = ['1']
	s2 = ['1']
	for i in range(1, n):
		if x[i] == '0':
			s1.append('0')
			s2.append('0')
		elif x[i] == '2':
			s1.append('1')
			s2.append('1')
		elif x[i] == '1':
			s1.append('1')
			s2.append('0')
			j = i + 1
			while j < n:
				s1.append('0')
				s2.append(x[j])
				j += 1
			break
	print(''.join(s1))
	print(''.join(s2))


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def get_str():
	return input().decode().strip()

def rint():
	return map(int, input().split())

def oint():
	return int(input())
t = oint()
for _ in range(t):
	n = oint()
	x = get_str()
	a = []
	b = []
	g = 's'
	for i in range(len(x)):
		cur = x[i]
		if cur == '2':
			if g == 's':
				a.append('1')
				b.append('1')
			elif g == 'a':
				a.append('0')
				b.append('2')
			else:
				a.append('2')
				b.append('0')
		elif cur == '1':
			if g == 's':
				a.append('1')
				b.append('0')
				g = 'a'
			elif g == 'a':
				a.append('0')
				b.append('1')
		else:
			a.append('0')
			b.append('0')
	print(''.join(a))
	print(''.join(b))


import sys
for t in range(int(sys.stdin.readline().strip())):
	n = int(sys.stdin.readline().strip())
	s = sys.stdin.readline().strip()
	flag = False
	a1 = ''
	a2 = ''
	for i in range(n):
		if not flag:
			if s[i] == '2':
				a1 = a1 + '1'
				a2 = a2 + '1'
			elif s[i] == '0':
				a1 = a1 + '0'
				a2 = a2 + '0'
			elif s[i] == '1':
				a1 = a1 + '1'
				a2 = a2 + '0'
				flag = True
		elif s[i] == '2':
			a1 = a1 + '0'
			a2 = a2 + '2'
		elif s[i] == '0':
			a1 = a1 + '0'
			a2 = a2 + '0'
		elif s[i] == '1':
			a1 = a1 + '0'
			a2 = a2 + '1'
	sys.stdout.write(a1)
	sys.stdout.write('\n')
	sys.stdout.write(a2)
	sys.stdout.write('\n')


from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def main():
	for _ in range(ii()):
		n = ii()
		s = si()
		s1 = ''
		s2 = ''
		f = 0
		f1 = 0
		for i in range(n):
			if s[i] == '2':
				if f1 == 1:
					s1 += '0'
					s2 += '2'
				else:
					s1 += '1'
					s2 += '1'
			elif s[i] == '0':
				s1 += '0'
				s2 += '0'
			else:
				if f == 0:
					s1 += '1'
					s2 += '0'
					f = 1
				else:
					s1 += '0'
					s2 += '1'
				f1 = 1
		print(s1)
		print(s2)
main()


def func(n, x):
	a = ''
	b = ''
	for i in range(n):
		if x[i] == '0':
			a += '0'
			b += '0'
		elif x[i] == '2':
			a += '1'
			b += '1'
		else:
			a += '0' + x[i + 1:]
			b += '1' + (n - i - 1) * '0'
			break
	return (a, b)
t = int(input())
l = []
for i in range(t):
	n = int(input())
	x = input()
	l.append(func(n, x))
for i in l:
	print(i[0])
	print(i[1])


k = int(input())
for w in range(k):
	n = input()
	n = input()
	num1 = ''
	num2 = ''
	flag = True
	for i in n:
		if flag:
			if i == '2':
				num1 += '1'
				num2 += '1'
			elif i == '0':
				num1 += '0'
				num2 += '0'
			else:
				num1 += '1'
				num2 += '0'
				flag = False
		else:
			num1 += '0'
			num2 += i
	print(num1)
	print(num2)


import math
for i in range(int(input())):
	(n, a) = (int(input()), input())
	(s1, s2) = ('', '')
	for i in a:
		if i == '2':
			if s1 == s2:
				s1 += '1'
				s2 += '1'
			else:
				s1 += '0'
				s2 += '2'
		elif i == '1':
			if s1 == s2:
				s1 += '1'
				s2 += '0'
			else:
				s1 += '0'
				s2 += '1'
		else:
			s1 += '0'
			s2 += '0'
	print(s1)
	print(s2)


def ter(n, x):
	s = str(x)
	a = '1'
	b = '1'
	maxi = False
	for i in range(1, n):
		if s[i] == '2':
			if maxi:
				a += '0'
				b += '2'
			else:
				a += '1'
				b += '1'
		elif s[i] == '0':
			a += '0'
			b += '0'
		elif maxi:
			a += '0'
			b += '1'
		else:
			maxi = True
			a += '1'
			b += '0'
	print(int(a))
	print(int(b))
t = int(input())
for i in range(t):
	n = int(input())
	x = int(input())
	ter(n, x)


t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	a = list()
	b = list()
	used = False
	for i in range(n):
		if x[i] == '0':
			a.append('0')
			b.append('0')
		elif x[i] == '1':
			if used:
				a.append('0')
				b.append('1')
			else:
				a.append('1')
				b.append('0')
				used = True
		elif used:
			a.append('0')
			b.append('2')
		else:
			a.append('1')
			b.append('1')
	print(''.join(a))
	print(''.join(b))


for _ in range(int(input())):
	n = int(input())
	a = list(input())
	a = [int(p) for p in a]
	flag = False
	r1 = ''
	r2 = ''
	for i in range(n):
		if a[i] == 2 and (not flag):
			r1 += '1'
			r2 += '1'
		elif a[i] == 2 and flag:
			r1 += '0'
			r2 += '2'
		elif a[i] == 1 and (not flag):
			r1 += '1'
			r2 += '0'
			flag = True
		elif a[i] == 1 and flag:
			r1 += '0'
			r2 += '1'
		else:
			r1 += '0'
			r2 += '0'
	print(r1)
	print(r2)


t = int(input())
for _ in range(t):
	n = int(input())
	x = list(input())
	arr = [[] for i in range(2)]
	nerf = -1
	buff = -1
	for i in range(n):
		if x[i] == '2':
			if nerf == -1 or i == 0:
				arr[0].append('1')
				arr[1].append('1')
			else:
				arr[nerf].append('0')
				arr[buff].append('2')
		if x[i] == '1':
			if nerf == -1:
				arr[0].append('0')
				arr[1].append('1')
				nerf = 1
				buff = 0
			else:
				arr[nerf].append('0')
				arr[buff].append('1')
		if x[i] == '0':
			arr[0].append('0')
			arr[1].append('0')
	print(''.join(arr[0]))
	print(''.join(arr[1]))


import sys
input = sys.stdin.readline
Q = int(input())
Query = []
for _ in range(Q):
	N = int(input())
	S = input().rstrip()
	Query.append((N, S))
for (N, S) in Query:
	la = []
	sm = []
	dif = False
	for s in S:
		if not dif:
			if s == '0':
				la.append(str(0))
				sm.append(str(0))
			elif s == '1':
				la.append(str(1))
				sm.append(str(0))
				dif = True
			else:
				la.append(str(1))
				sm.append(str(1))
		elif s == '0':
			la.append(str(0))
			sm.append(str(0))
		elif s == '1':
			la.append(str(0))
			sm.append(str(1))
		else:
			la.append(str(0))
			sm.append(str(2))
	print(''.join(la))
	print(''.join(sm))


for _ in range(int(input())):
	a = int(input())
	b = input()
	(x, y) = ('', '')
	(f, f1) = (0, 0)
	for i in range(len(b)):
		if b[i] == '2' and f == 0:
			x += '1'
			y += '1'
		elif b[i] == '2' and f != 0:
			x += '0'
			y += '2'
		elif b[i] == '0':
			x += '0'
			y += '0'
		elif b[i] == '1' and f == 0:
			x += '1'
			y += '0'
			f += 1
		elif b[i] == '1' and f != 0:
			x += '0'
			y += '1'
	print(x)
	print(y)


for _ in range(int(input())):
	n = int(input())
	x = list(input())
	a = list(range(n))
	b = list(range(n))
	diff = False
	for i in range(n):
		if x[i] == '0':
			a[i] = b[i] = '0'
		elif x[i] == '1':
			if diff:
				a[i] = '0'
				b[i] = '1'
			else:
				diff = True
				a[i] = '1'
				b[i] = '0'
		elif diff:
			a[i] = '0'
			b[i] = '2'
		else:
			a[i] = b[i] = '1'
	print(''.join(a))
	print(''.join(b))


t = int(input())
for j in range(t):
	n = int(input())
	s = input()
	al = [1] * n
	bs = [1] * n
	p = 0
	for i in range(1, n):
		if s[i] == '2':
			al[i] = 1
			bs[i] = 1
		elif s[i] == '0':
			al[i] = 0
			bs[i] = 0
		else:
			al[i] = 1
			bs[i] = 0
			p = i + 1
			break
	if p != 0 and n != 1:
		for i in range(p, n):
			if s[i] == '1':
				al[i] = 0
				bs[i] = 1
			elif s[i] == '2':
				al[i] = 0
				bs[i] = 2
			else:
				al[i] = 0
				bs[i] = 0
	for i in range(n):
		print(al[i], end='')
	print()
	for i in range(n):
		print(bs[i], end='')
	print()


for _ in range(int(input())):
	n = int(input())
	num = input()
	a = ''
	b = ''
	idx = n
	for (i, x) in enumerate(num):
		if int(x) == 0:
			a += '0'
			b += '0'
		elif int(x) == 2:
			a += '1'
			b += '1'
		else:
			a += '1'
			b += '0'
			idx = i + 1
			break
	while idx < n:
		a += '0'
		b += num[idx]
		idx += 1
	print(a)
	print(b)


test = int(input())
sol = []
while test:
	test -= 1
	n = int(input())
	s = input()
	d = [0 for i in range(n)]
	t = [0 for i in range(n)]
	t[0] = 1
	d[0] = 1
	i = 0
	while i < n:
		if s[i] == '1':
			t[i] = 1
			i += 1
			break
		elif s[i] == '2':
			(t[i], d[i]) = (1, 1)
		i += 1
	while i < n:
		d[i] = int(s[i])
		i += 1
	sol.append([t, d])
for i in sol:
	print(*i[0], sep='')
	print(*i[1], sep='')


t = int(input())
for _ in range(t):
	n = int(input())
	s = str(input())
	a = [0 for i in range(n)]
	b = [0 for i in range(n)]
	ok = False
	for i in range(len(s)):
		if ok:
			a[i] = 0
			b[i] = int(s[i])
			continue
		if s[i] == '1':
			a[i] = 1
			ok = True
		elif s[i] == '2':
			a[i] = b[i] = 1
	for i in range(len(a)):
		print(a[i], end='')
	print()
	for i in range(len(b)):
		print(b[i], end='')
	print()


t = int(input())
l = []
for i in range(t):
	n = int(input())
	a = input()
	c = '1'
	d = '1'
	h = 0
	for i in range(1, n):
		if a[i] == '2':
			c += '1'
			d += '1'
		elif a[i] == '0':
			c += '0'
			d += '0'
		elif a[i] == '1':
			c += '1'
			d += '0'
			h = i
			break
	if h != 0:
		c += (n - (h + 1)) * '0'
		d += a[h + 1:]
	l.append(c)
	l.append(d)
for i in l:
	print(i)


T = int(input())
for case in range(T):
	l = int(input())
	s = input()
	o1 = '1'
	o2 = '1'
	bal = True
	for b in s[1:]:
		if b == '2':
			if bal:
				o1 += '1'
				o2 += '1'
			else:
				o1 += '0'
				o2 += '2'
		if b == '1':
			if bal:
				o1 += '1'
				o2 += '0'
				bal = False
			else:
				o1 += '0'
				o2 += '1'
		if b == '0':
			o1 += '0'
			o2 += '0'
	print(o1)
	print(o2)


for _ in range(int(input())):
	n = int(input())
	a = input()
	(ans, ans1, q1) = ([], [], 0)
	while q1 < n and a[q1] != '1':
		ans.append('1' if a[q1] == '2' else '0')
		ans1.append('1' if a[q1] == '2' else '0')
		q1 += 1
	if q1 < n:
		ans.append('1')
		ans1.append('0')
	q1 += 1
	while q1 < n:
		ans.append('0')
		ans1.append(a[q1])
		q1 += 1
	print(''.join(ans))
	print(''.join(ans1))


for i in range(int(input())):
	n = int(input())
	x = input()
	l1 = list(x)
	l1[0] = '1'
	l2 = ['1'] + ['0' for k in range(n - 1)]
	for j in range(1, n):
		if l1[j] == '1':
			l2[j] = '1'
			l1[j] = '0'
			break
		elif l1[j] == '2':
			l2[j] = '1'
			l1[j] = '1'
	print(int(''.join(l1)), int(''.join(l2)), sep='\n')


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	a = [1]
	b = [1]
	cor = -1
	for i in range(1, n):
		if x[i] == '0':
			a.append(0)
			b.append(0)
		elif x[i] == '2':
			if cor == 2:
				a.append(0)
				b.append(2)
			elif cor == 1:
				a.append(2)
				b.append(0)
			else:
				a.append(1)
				b.append(1)
		elif a[-1] > b[-1] and cor == -1 or cor == 2:
			a.append(0)
			b.append(1)
			cor = 2
		elif a[-1] < b[-1] and cor == -1 or cor == 1:
			a.append(1)
			b.append(0)
			cor = 1
		else:
			a.append(1)
			b.append(0)
			cor = 2
	print(*a, sep='')
	print(*b, sep='')


k = list(map(int, input().split()))
n = k[0]
s = ''
for i in range(n):
	k = list(map(int, input().split()))
	k = k[0]
	ch = list(map(str, input().split()))
	ch = list(ch[0])
	ok = 1
	a = ''
	b = ''
	for j in range(k):
		if ok == 1:
			if ch[j] == '1':
				a = a + '1'
				b = b + '0'
				ok = 0
			elif ch[j] == '0':
				a = a + '0'
				b = b + '0'
			else:
				a = a + '1'
				b = b + '1'
		else:
			a = a + '0'
			b = b + ch[j]
	print(a)
	print(b)


t = int(input())
while t > 0:
	n = int(input())
	s = input()
	a = []
	b = []
	flag = 0
	for i in range(n):
		if flag == 0:
			if s[i] == '2':
				a.append('1')
				b.append('1')
			elif s[i] == '0':
				a.append('0')
				b.append('0')
			elif s[i] == '1':
				a.append('1')
				b.append('0')
				flag = 1
		else:
			a.append('0')
			b.append(s[i])
	f1 = ''
	for i in a:
		f1 += i
	f2 = ''
	for i in b:
		f2 += i
	print(f1)
	print(f2)
	t -= 1


T = int(input())
for _ in range(T):
	(n, t) = (int(input()), input())
	(a, b) = ([], [])
	bigger = 0
	for u in t:
		u = int(u)
		if u == 0:
			a.append(0)
			b.append(0)
		elif u == 1:
			if bigger:
				a.append(0)
				b.append(1)
			else:
				a.append(1)
				b.append(0)
				bigger = 1
		elif bigger:
			a.append(0)
			b.append(2)
		else:
			a.append(1)
			b.append(1)
	print(''.join(map(str, a)))
	print(''.join(map(str, b)))


from itertools import permutations
from math import sqrt
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def prog_name():
	n = int(input())
	ss = input()
	x = []
	cnt = 0
	for i in ss:
		x.append(i)
	s1 = ['1'] * n
	s2 = ['1'] * n
	for a in range(1, len(x)):
		if cnt:
			s1[a] = '0'
			s2[a] = x[a]
		elif x[a] == '2':
			s1[a] = '1'
			s2[a] = '1'
		elif x[a] == '0':
			s1[a] = '0'
			s2[a] = '0'
		else:
			s1[a] = '1'
			s2[a] = '0'
			cnt = 1
	print(''.join(s1))
	print(''.join(s2))

def main():
	t = int(input())
	for unique in range(t):
		prog_name()
main()


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	x = list(map(int, list(input())[:-1]))
	a = [0] * n
	b = [0] * n
	t = n
	for i in range(n):
		if x[i] == 1:
			a[i] = x[i]
			t = i + 1
			break
		elif x[i] == 2:
			a[i] = 1
			b[i] = 1
	for i in range(t, n):
		b[i] = x[i]
	print(''.join(list(map(str, a))))
	print(''.join(list(map(str, b))))


t = int(input())
while t:
	l = int(input())
	x = str(input())
	(a, b) = (['0'] * l, ['0'] * l)
	for i in range(l):
		if x[i] == '1':
			a[i] = '1'
			b[i] = '0'
			for j in range(i + 1, l):
				b[j] = x[j]
			break
		else:
			a[i] = b[i] = str(int(x[i]) // 2)
	print(''.join(a))
	print(''.join(b))
	t -= 1


for i in range(int(input())):
	n = int(input())
	s = input()
	a = '1'
	b = '1'
	j = 0
	for i in range(1, n):
		if s[i] == '1':
			a += '1'
			b += '0'
			j = i
			break
		a += str(int(s[i]) // 2)
		b += str(int(s[i]) // 2)
	if j:
		a += '0' * (n - j - 1)
		b += s[j + 1:]
	print(a)
	print(b)


from math import *
from copy import *
from string import *
from random import *
from bisect import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
from collections import defaultdict

def solve(s):
	n = len(s)
	(a, b) = ('', '')
	f = 1
	for i in range(n):
		if i == 0:
			if s[i] == '0':
				a += '1'
				b += '2'
				f = 1
			elif s[i] == '1':
				a += '0'
				b += '1'
				f = 1
			elif s[i] == '2':
				a += '1'
				b += '1'
				f = 0
		elif s[i] == '0':
			a += '0'
			b += '0'
		elif s[i] == '1':
			if f <= 0:
				a += '0'
				b += '1'
				if f == 0:
					f = 1
			else:
				a += '1'
				b += '0'
				if f == 0:
					f = -1
		elif s[i] == '2':
			if f != 1:
				a += '1'
				b += '1'
			else:
				a += '2'
				b += '0'
				if f == 0:
					f = -1
	print(a)
	print(b)
T = int(input())
for _ in range(T):
	N = int(stdin.readline())
	l = input()
	solve(l)


t = int(input())
for each_t in range(t):
	n = int(input())
	x = input()
	a = ''
	b = ''
	flag = 0
	for i in range(n):
		if i == 0:
			a += '1'
			b += '1'
			continue
		if x[i] == '0':
			if flag == 1:
				a += '0'
				b += '0'
			else:
				a += '0'
				b += '0'
		elif x[i] == '1':
			if flag == 1:
				a += '0'
				b += '1'
			else:
				a += '1'
				b += '0'
				flag = 1
		elif x[i] == '2':
			if flag == 1:
				a += '0'
				b += '2'
			else:
				a += '1'
				b += '1'
	print(a)
	print(b)


for _ in range(int(input())):
	n = int(input())
	x = input()
	a = ['0'] * n
	b = ['0'] * n
	equal = True
	for k in range(n):
		if x[k] == '2':
			if equal:
				a[k] = '1'
				b[k] = '1'
			else:
				a[k] = '0'
				b[k] = '2'
		elif x[k] == '1':
			if equal:
				a[k] = '1'
				b[k] = '0'
				equal = False
			else:
				a[k] = '0'
				b[k] = '1'
	print(''.join(b))
	print(''.join(a))


for qq in range(int(input())):
	l = int(input())
	n = input()
	m = str(int(n) // 2)
	try:
		i = n.index('1')
	except:
		i = l + 1
	if i == 0:
		print('2' + '0' * (l - 1))
		print('2' + n[1:])
	elif i > l:
		print(m)
		print(m)
	else:
		print(m[:i] + '1' + '0' * (l - i - 1))
		print(m[:i] + '0' + n[i + 1:])


n = int(input())
for testcase in range(n):
	l = int(input())
	num1 = ''
	num2 = ''
	num = input()
	check = False
	for digit in num:
		nd = int(digit)
		if nd == 2:
			if not check:
				num1 = num1 + '1'
				num2 = num2 + '1'
			else:
				num1 = num1 + '0'
				num2 = num2 + '2'
		if nd == 1:
			if not check:
				num1 = num1 + '1'
				num2 = num2 + '0'
				check = True
			else:
				num1 = num1 + '0'
				num2 = num2 + '1'
		if nd == 0:
			num1 = num1 + '0'
			num2 = num2 + '0'
	print(num1)
	print(num2)


t = int(input())
for case_num in range(t):
	n = int(input())
	x = input()
	a = []
	b = []
	split = False
	for i in x:
		if not split:
			if i == '2':
				a.append('1')
				b.append('1')
			if i == '0':
				a.append('0')
				b.append('0')
			if i == '1':
				a.append('1')
				b.append('0')
				split = True
		else:
			a.append('0')
			b.append(i)
	print(''.join(a))
	print(''.join(b))


t = int(input())
while t:
	n = int(input())
	c = input()
	a = []
	b = []
	flag = 0
	for i in range(n):
		if c[i] == '2' and flag == 1:
			a.append('0')
			b.append('2')
		if c[i] == '2' and flag == 0:
			a.append('1')
			b.append('1')
		if c[i] == '0':
			a.append('0')
			b.append('0')
		if c[i] == '1' and flag == 1:
			a.append('0')
			b.append('1')
		if c[i] == '1' and flag == 0:
			a.append('1')
			b.append('0')
			flag = 1
	a1 = ''.join(a)
	b1 = ''.join(b)
	print(a1)
	print(b1)
	a.clear()
	b.clear()
	t -= 1


def solve():
	n = int(input())
	x = list(map(int, list(input())))
	dif_determined = False
	a = [-1] * n
	b = [-1] * n
	for i in range(n):
		v = x[i]
		if dif_determined == False:
			if v == 0:
				a[i] = 0
				b[i] = 0
				continue
			elif v == 1:
				a[i] = 1
				b[i] = 0
				dif_determined = True
				continue
			elif v == 2:
				a[i] = 1
				b[i] = 1
				continue
		else:
			a[i] = 0
			b[i] = v
			continue
	print(''.join(map(str, a)))
	print(''.join(map(str, b)))
	return

def main():
	t = int(input())
	for i in range(t):
		solve()
	return
main()


from sys import stdin, stdout

def INI():
	return int(stdin.readline())

def INL():
	return [int(_) for _ in stdin.readline().split()]

def INS():
	return stdin.readline()

def MOD():
	return pow(10, 9) + 7

def OPS(ans):
	stdout.write(str(ans) + '\n')

def OPL(ans):
	[stdout.write(str(_) + ' ') for _ in ans]
	stdout.write('\n')
import math
for _ in range(INI()):
	n = INI()
	S = INS()
	A = ''
	B = ''
	c = 0
	for _ in range(n):
		if c == 0:
			A += str(math.ceil(int(S[_]) / 2))
			B += str(int(S[_]) // 2)
		else:
			B += S[_]
			A += '0'
		if A[-1] != B[-1]:
			c = 1
	OPS(A)
	OPS(B)


t = int(input())
for i in range(0, t):
	l = int(input())
	str = input()
	a = []
	b = []
	flag = '1'
	for j in range(0, l):
		if str[j] == '2':
			if flag == '1':
				a.append(1)
				b.append(1)
			else:
				a.append(0)
				b.append(2)
		elif str[j] == '0':
			a.append(0)
			b.append(0)
		elif flag == '1':
			a.append(1)
			b.append(0)
			flag = '0'
		else:
			a.append(0)
			b.append(1)
	for m in a:
		print(m, end='')
	print()
	for n in b:
		print(n, end='')
	print()


for i in range(int(input())):
	p = int(input())
	n = input()
	now = 1
	ans = ['1', '1']
	for i in range(1, p):
		i = int(n[i])
		if i == 2 or i == 0:
			if now:
				ans[0] += str(i // 2)
				ans[1] += str(i // 2)
			else:
				ans[0] += '0'
				ans[1] += str(i)
		elif i == 1:
			if now:
				ans[0] += '1'
				ans[1] += '0'
				now = 0
			else:
				ans[0] += '0'
				ans[1] += '1'
	print(*ans, sep='\n')


import sys
input = sys.stdin.readline
T = int(input())
for test in range(T):
	n = int(input())
	a = [0] * n
	b = [0] * n
	c = list(input())
	check = False
	for i in range(n):
		if c[i] == '2':
			if check is True:
				a[i] = '0'
				b[i] = '2'
			else:
				a[i] = '1'
				b[i] = '1'
		elif c[i] == '1':
			if check is False:
				a[i] = '1'
				b[i] = '0'
				check = True
			else:
				a[i] = '0'
				b[i] = '1'
		elif c[i] == '0':
			(a[i], b[i]) = ('0', '0')
	print(''.join(a))
	print(''.join(b))


num_of_test = int(input())
lst = []
for i in range(0, num_of_test):
	length = int(input())
	lst.append(input())
for i in range(0, num_of_test):
	a = ''
	b = ''
	found_1 = False
	for j in range(0, len(lst[i])):
		if not found_1:
			if lst[i][j] == '2':
				a += '1'
				b += '1'
			elif lst[i][j] == '0':
				a += '0'
				b += '0'
			else:
				found_1 = True
				a += '1'
				b += '0'
		else:
			a += '0'
			b += lst[i][j]
	print(a)
	print(b)


def out1(x, q, w):
	for j in range(0, n):
		if x[j] == '2':
			q.append('1')
			w.append('1')
		elif x[j] == '1':
			q.append('1')
			w.append('0')
			break
		elif x[j] == '0':
			q.append('0')
			w.append('0')
	if j < n - 1:
		for a in range(j + 1, n):
			q.append('0')
			w.append(x[a])
t = int(input())
for i in range(t):
	n = int(input())
	x = list(input())
	q = []
	w = []
	out1(x, q, w)
	print(''.join(q))
	print(''.join(w))


try:
	for _ in range(int(input())):
		n = int(input())
		x = input()
		a = ''
		b = ''
		maxi = False
		for i in range(n):
			if x[i] == '0':
				if maxi == False:
					a += '0'
					b += '0'
				elif maxi == 1:
					a += '0'
					b += '0'
				else:
					a += '0'
					b += '0'
			elif x[i] == '1':
				if maxi == False:
					a += '1'
					b += '0'
					maxi = 1
				elif maxi == 1:
					a += '0'
					b += '1'
				else:
					a += '1'
					b += '0'
			elif maxi == False:
				a += '1'
				b += '1'
			elif maxi == 1:
				a += '0'
				b += '2'
			else:
				a += '2'
				b += '0'
		print(int(a))
		print(int(b))
except:
	pass


for _ in range(0, int(input())):
	n = int(input())
	x = input()
	(a, b) = ('1', '1')
	f = 0
	for i in range(1, n):
		t = x[i]
		if t == '0' or t == '2':
			if f == 0:
				a += str(int(t) // 2)
				b += str(int(t) // 2)
			else:
				a += '0'
				b += t
		elif f == 0:
			a += t
			b += '0'
			f = 1
		else:
			a += '0'
			b += t
	print(a)
	print(b)


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	(x1, x2) = ('', '')
	c = 0
	for i in x:
		if i == '2':
			if c >= 1:
				x1 += '0'
				x2 += '2'
			else:
				x1 += '1'
				x2 += '1'
		elif i == '1':
			if c >= 1:
				x1 += '0'
				x2 += '1'
			else:
				x1 += '1'
				x2 += '0'
				c += 1
		else:
			x1 += '0'
			x2 += '0'
	print(x1)
	print(x2)


t = int(input())
for i in range(t):
	n = int(input())
	s = input().strip()
	output1 = ''
	output2 = ''
	m = 0
	for j in s:
		if j == '0':
			output1 = output1 + '0'
			output2 = output2 + '0'
		if j == '1':
			if m == 0:
				output1 = output1 + '1'
				output2 = output2 + '0'
				m = 1
			else:
				output1 = output1 + '0'
				output2 = output2 + '1'
		if j == '2':
			if m == 0:
				output1 = output1 + '1'
				output2 = output2 + '1'
			else:
				output1 = output1 + '0'
				output2 = output2 + '2'
	print(output1)
	print(output2)


import math
test_cases = int(input())
for t in range(test_cases):
	n = int(input())
	x = input()
	num1 = ''
	num2 = ''
	for i in range(n):
		if x[i] != '1':
			num = '0'
			if x[i] == '2':
				num = '1'
			num1 += num
			num2 += num
		else:
			num1 += '1' + '0' * (n - (i + 1))
			num2 += '0' + x[i + 1:]
			break
	print(num1)
	print(num2)


for _ in range(int(input())):
	n = int(input())
	eq = True
	a = []
	b = []
	for x in input():
		if eq:
			if x == '0':
				a.append('0')
				b.append('0')
			elif x == '1':
				eq = False
				a.append('1')
				b.append('0')
			else:
				a.append('1')
				b.append('1')
		elif x == '0':
			a.append('0')
			b.append('0')
		elif x == '1':
			a.append('0')
			b.append('1')
		else:
			a.append('0')
			b.append('2')
	print(''.join(a))
	print(''.join(b))


for t in range(int(input())):
	n = int(input())
	s = input()
	if '1' not in s:
		a = s.replace('2', '1')
		print(a)
		print(a)
		continue
	else:
		i = s.index('1') + 1
		a = s[:i] + '0' * (n - i)
		a = a.replace('2', '1')
		print(a)
		b = ''
		for j in range(i):
			if a[j] == s[j]:
				b += '0'
			else:
				b += '1'
		b += s[i:]
		print(b)


import math
t = int(input())
for x in range(t):
	n = int(input())
	arr = input()
	flag = True
	a = []
	b = []
	for i in arr:
		if i == '2' or i == '0':
			if i == '2':
				if flag:
					a.append('1')
					b.append('1')
				else:
					a.append('0')
					b.append('2')
			else:
				a.append('0')
				b.append('0')
		elif flag:
			a.append('1')
			b.append('0')
			flag = False
		else:
			a.append('0')
			b.append('1')
	for i in a:
		print(i, end='')
	print()
	for i in b:
		print(i, end='')
	print()


t = eval(input())
while t != 0:
	n = eval(input())
	x = input()
	a = [0 for i in range(n)]
	b = [0 for i in range(n)]
	flag = 0
	for i in range(0, n):
		if x[i] == '0':
			a[i] = 0
			b[i] = 0
		if flag == 0:
			if x[i] == '2':
				a[i] = 1
				b[i] = 1
			if x[i] == '1':
				a[i] = 1
				b[i] = 0
				flag = 1
		else:
			if x[i] == '2':
				a[i] = 0
				b[i] = 2
			if x[i] == '1':
				a[i] = 0
				b[i] = 1
	for j in range(0, n):
		print(a[j], end='')
	print()
	for i in range(0, n):
		print(b[i], end='')
	print()
	t -= 1


def solve(type, val, flag):
	if type == 'first':
		if val == 2:
			return (1, 1)
		elif val == 1:
			return (2, 2)
		else:
			return (2, 1)
	elif val == 2:
		if flag == 1:
			return (0, 2)
		else:
			return (1, 1)
	elif val == 1:
		if flag == 1:
			return (0, 1)
		else:
			return (1, 0)
	else:
		return (0, 0)
t = int(input())
while t != 0:
	n = int(input())
	s = list(map(int, input()))
	a = ''
	b = ''
	flag = 0
	temp = solve('first', s[0], flag)
	a = a + str(temp[0])
	b = b + str(temp[1])
	for i in range(1, n):
		temp = solve('s', s[i], flag)
		a = a + str(temp[0])
		b = b + str(temp[1])
		if flag == 0:
			if s[i] == 1:
				flag = 1
	print(a)
	print(b)
	t = t - 1


MOD = 1000000007
MOD2 = 998244353
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
let = 'abcdefghijklmnopqrstuvwxyz'
for _ in range(ii()):
	n = ii()
	s = si()
	(l1, l2) = (['1'], ['1'])
	fg = 0
	for i in range(1, n):
		if s[i] == '2':
			if not fg:
				l2.append('1')
				l1.append('1')
			else:
				l2.append('2')
				l1.append('0')
		if s[i] == '0':
			l1.append('0')
			l2.append('0')
		if s[i] == '1':
			if not fg:
				l1.append('1')
				l2.append('0')
				fg = 1
			else:
				l1.append('0')
				l2.append('1')
	print(''.join(l1))
	print(''.join(l2))


from math import ceil
for _ in range(int(input())):
	n = int(input())
	s = input()
	q = ''
	p = ''
	one = True
	for x in s:
		if x == '1':
			q += '1'
			p += '0'
			if one:
				one = False
				(q, p) = (p, q)
		elif x == '2':
			if not one:
				p += '0'
				q += '2'
			else:
				q += '1'
				p += '1'
		else:
			q += '0'
			p += '0'
	print(p)
	print(q)


t = int(input())
for counter in range(t):
	n = int(input())
	s = input()
	a = ''
	b = ''
	k = n
	for i in range(n):
		if s[i] == '0':
			a += '0'
			b += '0'
		elif s[i] == '2':
			a += '1'
			b += '1'
		else:
			a += '1'
			b += '0'
			k = i + 1
			break
	for i in range(k, n):
		if s[i] == '0':
			a += '0'
			b += '0'
		elif s[i] == '2':
			a += '0'
			b += '2'
		else:
			a += '0'
			b += '1'
	print(a)
	print(b)


for z in range(int(input())):
	n = int(input())
	end = input()
	a = '1'
	b = '1'
	big = 0
	for i in end[1:]:
		if big == 0:
			if i == '0':
				a += '0'
				b += '0'
			elif i == '2':
				a += '1'
				b += '1'
			elif i == '1':
				a += '1'
				b += '0'
				big = 1
				continue
		if big == 1:
			if i == '0':
				a += '0'
				b += '0'
			elif i == '2':
				a += '0'
				b += '2'
			elif i == '1':
				a += '0'
				b += '1'
	print(int(a))
	print(int(b))


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	a = []
	b = []
	if '1' in x:
		ind = x.index('1')
		for i in range(n):
			if i < ind:
				if x[i] == '2':
					a.append('1')
					b.append('1')
				else:
					a.append('0')
					b.append('0')
			elif i == ind:
				a.append('1')
				b.append('0')
			elif x[i] == '2':
				a.append('0')
				b.append('2')
			elif x[i] == '1':
				a.append('0')
				b.append('1')
			else:
				a.append('0')
				b.append('0')
	else:
		for i in range(n):
			if x[i] == '2':
				a.append('1')
				b.append('1')
			else:
				a.append('0')
				b.append('0')
	print(''.join(a))
	print(''.join(b))


def read():
	n = int(input())
	x = input()
	return (n, x)

def solve(n, x):
	has_one = False
	a = b = ''
	for xi in x:
		if xi == '2':
			if has_one:
				a += '0'
				b += '2'
			else:
				a += '1'
				b += '1'
		elif xi == '1':
			if has_one:
				a += '0'
				b += '1'
			else:
				a += '1'
				b += '0'
				has_one = True
		else:
			a += '0'
			b += '0'
	return (a, b)
for i in range(int(input())):
	result = solve(*read())
	print(*result, sep='\n')


from math import *
from sys import *
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	s = input()
	a = []
	b = []
	i = n
	for i in range(n):
		if s[i] == '1':
			break
	k = i
	for i in range(k + 1):
		if s[i] == '2':
			a.append(1)
			b.append(1)
		if s[i] == '0':
			a.append(0)
			b.append(0)
		if s[i] == '1':
			a.append(1)
			b.append(0)
	for i in range(k + 1, n):
		if s[i] == '0':
			a.append(0)
			b.append(0)
		if s[i] == '2':
			a.append(0)
			b.append(2)
		if s[i] == '1':
			a.append(0)
			b.append(1)
	print(*a, sep='')
	print(*b, sep='')


n = int(input())
for _ in range(n):
	a = int(input())
	s = str(input())
	a1 = '1'
	a2 = '1'
	for j in s[1:]:
		if j == '0':
			a1 = a1 + '0'
			a2 = a2 + '0'
		elif j == '2':
			a1 = a1 + '1'
			a2 = a2 + '1'
		else:
			a1 = a1 + '1'
			a2 = a2 + '0'
			a1 = a1 + '0' * (len(s) - len(a1))
			if len(a2) != a:
				a2 = a2 + s[len(a2) - a:]
			break
	print(a1, a2, sep='\n')


dic = {'1': ('0', '1'), '2': ('1', '1'), '0': ('0', '0')}
t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	(a, b) = ('', '')
	flag = False
	for i in x:
		if flag is False:
			(aa, bb) = dic[i]
			a += aa
			b += bb
			if aa != bb:
				flag = True
		else:
			a += i
			b += '0'
	print(a + '\n' + b)


def solve(n, x):
	(a, b) = (['0'] * n, ['0'] * n)
	d = {'0': '0', '2': '1'}
	for i in range(n):
		if x[i] != '1':
			a[i] = b[i] = d[x[i]]
		else:
			a[i] = '1'
			b[i] = '0'
			for j in range(i + 1, n):
				b[j] = x[j]
			break
	res = [''.join(a), ''.join(b)]
	return '\n'.join(res)
t = int(input())
for _ in range(t):
	n = int(input())
	x = list(input())
	print(solve(n, x))


for t in range(int(input())):
	n = int(input())
	x = input()
	a = [0 for i in range(n)]
	b = [0 for i in range(n)]
	flag = 0
	for i in range(n):
		d = int(x[i])
		if d == 2:
			if flag == 0:
				a[i] = 1
				b[i] = 1
			else:
				a[i] = 0
				b[i] = 2
		elif d == 1:
			if flag == 0:
				a[i] = 1
				flag = 1
			else:
				b[i] = 1
	for i in range(n):
		print(a[i], end='')
	print()
	for i in range(n):
		print(b[i], end='')
	print()


t = int(input())
for i in range(t):
	length = int(input())
	target = input()
	a = []
	b = []
	is_larger = 0
	for j in range(len(target)):
		cur = int(target[j])
		if cur == 2:
			if is_larger == 1:
				b.append(0)
				a.append(2)
			else:
				a.append(1)
				b.append(1)
		elif cur == 1:
			if is_larger == 0:
				a.append(0)
				b.append(1)
				is_larger = 1
			elif is_larger == 1:
				a.append(1)
				b.append(0)
				is_larger = 1
		else:
			a.append(0)
			b.append(0)
	print(*a, sep='')
	print(*b, sep='')


def solve():
	n = int(input())
	x = str(input())
	a = '1' * n
	a = list(a)
	b = '1' * n
	b = list(b)
	x = list(x)
	for i in range(1, n):
		if x[i] == '1':
			a[i] = '1'
			a[i + 1:] = '0' * (n - 1 - i)
			b[i] = '0'
			b[i + 1:] = x[i + 1:]
			break
		elif x[i] == '2':
			a[i] = '1'
			b[i] = '1'
		else:
			a[i] = '0'
			b[i] = '0'
	print(''.join(a))
	print(''.join(b))
t = int(input())
for i in range(t):
	solve()


a = int(input())
for _ in range(a):
	x = int(input())
	y = input()
	(o1, o2) = ('', '')
	for i in range(x):
		if y[i] == '2':
			o1 += '1'
			o2 += '1'
		elif y[i] == '0':
			o1 += '0'
			o2 += '0'
		elif y[i] == '1':
			o1 += '1'
			o2 += '0'
			break
	o2 += y[i + 1:x]
	o1 += '0' * (x - i - 1)
	print(o1)
	print(o2)


t = int(input())
for t1 in range(0, t):
	n = int(input())
	x = input()
	f = 0
	s = '1'
	s1 = '1'
	for i in range(1, n):
		if x[i] == '0':
			s = s + '0'
			s1 = s1 + '0'
		elif x[i] == '1':
			if f == 0:
				s = s + '1'
				s1 = s1 + '0'
				f = 1
			else:
				s = s + '0'
				s1 = s1 + '1'
		elif f == 0:
			s = s + '1'
			s1 = s1 + '1'
		else:
			s = s + '0'
			s1 = s1 + '2'
	print(s)
	print(s1)


t = int(input())
for _ in range(t):
	n = int(input())
	s = [int(i) for i in input()]
	a = '1'
	b = '1'
	sw = 0
	for i in range(1, n):
		if s[i] == 0:
			a += '0'
			b += '0'
			continue
		if sw:
			if s[i] == 1:
				a += '0'
				b += '1'
			elif s[i] == 2:
				a += '0'
				b += '2'
		elif s[i] == 1:
			a += '1'
			b += '0'
			sw = 1
		elif s[i] == 2:
			a += '1'
			b += '1'
	print(a)
	print(b)


for i in range(int(input())):
	input()
	a = str(input())
	x = ''
	y = ''
	bool = 0
	for j in a:
		if j == '0':
			x += '0'
			y += '0'
		elif j == '1' and bool == 0:
			x += '1'
			y += '0'
			bool = 1
		elif j == '1' and bool == 1:
			x += '0'
			y += '1'
		elif j == '2' and bool == 0:
			x += '1'
			y += '1'
		elif j == '2' and bool == 1:
			x += '0'
			y += '2'
	print(x)
	print(y)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
testcases = int(input())
for j in range(testcases):
	x = int(input())
	ternary = [int(a) for a in str(input())]
	a = []
	b = []
	maxexists = False
	max1 = -1
	for s in range(x):
		if ternary[s] == 2:
			if maxexists == False:
				a.append(1)
				b.append(1)
			elif maxexists == True:
				b.append(2)
				a.append(0)
		elif ternary[s] == 1:
			if maxexists == False:
				maxexists = True
				max1 = 0
				a.append(1)
				b.append(0)
			elif maxexists == True:
				if max1 == 0:
					b.append(1)
					a.append(0)
		elif ternary[s] == 0:
			a.append(0)
			b.append(0)
	print(''.join([str(k) for k in a]))
	print(''.join([str(i) for i in b]))


import sys
input = lambda : sys.stdin.readline()
int_arr = lambda : list(map(int, input().split()))
str_arr = lambda : list(map(str, input().split()))
get_str = lambda : map(str, input().split())
get_int = lambda : map(int, input().split())
get_flo = lambda : map(float, input().split())
mod = 1000000007

def solve(n, s):
	a = ''
	b = ''
	ff = 0
	for i in range(n):
		if ff:
			a += '0'
			b += s[i]
		elif s[i] == '0':
			a += '0'
			b += '0'
		elif s[i] == '2':
			a += '1'
			b += '1'
		else:
			a += '1'
			b += '0'
			ff = 1
	print(a)
	print(b)
for _ in range(int(input())):
	n = int(input())
	s = str(input())
	solve(n, s)


T = int(input())
while T > 0:
	n = int(input())
	val = input()
	a = '1'
	b = '1'
	count = 1
	for x in range(1, n):
		if val[x] == '2':
			a = a + '1'
			b = b + '1'
		elif val[x] == '0':
			a = a + '0'
			b = b + '0'
		else:
			break
		count += 1
	if count < n:
		if val[count] == '1':
			a = a + '1'
			b = b + '0'
			count = count + 1
	for x in range(count, n):
		if val[x] == '2':
			a = a + '0'
			b = b + '2'
		elif val[x] == '1':
			a = a + '0'
			b = b + '1'
		else:
			a = a + '0'
			b = b + '0'
	print(a)
	print(b)
	T -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	gt = False
	ret = ['', '']
	for d in x:
		if gt:
			ret[0] += '0'
			ret[1] += d
		else:
			if d == '2':
				ret[0] += '1'
				ret[1] += '1'
			if d == '1':
				ret[0] += '1'
				ret[1] += '0'
				gt = True
			if d == '0':
				ret[0] += '0'
				ret[1] += '0'
	print(*ret, sep='\n')


x = int(input())
for j in range(x):
	y = int(input())
	s = input()
	s1 = ''
	s2 = ''
	flag = 0
	for i in range(y):
		if flag == 0:
			if s[i] == '2':
				s1 += '1'
				s2 += '1'
			elif s[i] == '0':
				s1 += '0'
				s2 += '0'
			else:
				s1 += '0'
				s2 += '1'
				flag = 1
		else:
			s1 += s[i]
			s2 += '0'
	print(s2)
	print(s1)


t = int(input())
while t:
	n = int(input())
	x = input()
	listt = list(x)
	a = list('0' * n)
	b = list('0' * n)
	contain_one = False
	index = n - 1
	if '1' in listt:
		index = listt.index('1')
		contain_one = True
	contain_two = False
	if '2' in listt[1:]:
		index2 = listt[1:].index('2')
		contain_two = True
	flag = 0
	for i in range(index + 1):
		if listt[i] == '2':
			a[i] = '1'
			b[i] = '1'
		if contain_one and i == index:
			if listt[i] == '1':
				a[i] = '1'
				b[i] = '0'
		elif listt[i] == '1':
			a[i] = '0'
			b[i] = '1'
	for i in range(index + 1, len(listt)):
		b[i] = listt[i]
	print(int(''.join(a)))
	print(int(''.join(b)))
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	a = ['0'] * n
	b = ['0'] * n
	for i in range(n):
		if x[i] == '0':
			continue
		elif x[i] == '2':
			a[i] = '1'
			b[i] = '1'
		else:
			a[i] = '1'
			for j in range(i + 1, n):
				b[j] = x[j]
			break
	print(''.join(a))
	print(''.join(b))


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	x = list(map(int, input().rstrip()))
	a = ''
	A = 0
	b = ''
	for i in range(n):
		if x[i] == 2:
			if A == 0:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
		elif x[i] == 1:
			if A == 0:
				a += '1'
				b += '0'
				A = 1
			else:
				b += '1'
				a += '0'
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


from sys import stdin
inp = stdin.readline
t = int(inp())
for i in range(t):
	n = int(inp())
	number = [int(d) for d in str(inp()[:-1])]
	number1 = [0] * n
	number2 = [0] * n
	appeared = False
	for j in range(n):
		if number[j] == 1 and appeared:
			number2[j] = 1
			number1[j] = 0
		if number[j] == 1 and (not appeared):
			number2[j] = 0
			number1[j] = 1
			appeared = True
		elif number[j] == 2 and appeared:
			number2[j] = 2
			number1[j] = 0
		elif number[j] == 2 and (not appeared):
			number2[j] = 1
			number1[j] = 1
		elif number[j] == 0:
			number2[j] = 0
			number1[j] = 0
	print(''.join(map(str, number1)))
	print(''.join(map(str, number2)))


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	num1 = num2 = ''
	bigger = False
	for i in range(n):
		if x[i] == '0':
			num1 = num1 + '0'
			num2 = num2 + '0'
		elif x[i] == '1':
			if bigger:
				num2 = num2 + '1'
				num1 = num1 + '0'
			else:
				num1 = num1 + '1'
				num2 = num2 + '0'
				bigger = True
		elif bigger:
			num1 = num1 + '0'
			num2 = num2 + '2'
		else:
			num1 = num1 + '1'
			num2 = num2 + '1'
	print(num1)
	print(num2)


t = int(input())
for i in range(t):
	n = int(input())
	no = input()
	(a, b) = ([], [])
	for i in range(n):
		if no[i] == '2':
			a.append('1')
			b.append('1')
		elif no[i] == '0':
			a.append('0')
			b.append('0')
		else:
			a.append('1')
			b.append('0')
			for j in range(i + 1, n):
				a.append('0')
				b.append(no[j])
			break
	print(''.join(a))
	print(''.join(b))


from math import *
t = int(input())
for y in range(t):
	n = int(input())
	s = input()
	f = 0
	a = ''
	b = ''
	for i in s:
		if f == 0:
			if i == '2':
				a += '1'
				b += '1'
			elif i == '1':
				a += '1'
				b += '0'
				f = 1
			else:
				a += '0'
				b += '0'
		elif i == '2':
			a += '0'
			b += '2'
		elif i == '1':
			a += '0'
			b += '1'
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


t = int(input())
while t > 0:
	l = int(input())
	s = input()
	s1 = ''
	s2 = ''
	s1 = s1 + '1'
	s2 = s2 + '1'
	for i in range(1, l, 1):
		if s[i] == '2':
			if s1 < s2:
				s1 = s1 + '2'
				s2 = s2 + '0'
			elif s2 < s1:
				s2 = s2 + '2'
				s1 = s1 + '0'
			elif s1 == s2:
				s1 = s1 + '1'
				s2 = s2 + '1'
		elif s[i] == '1':
			if s1 <= s2:
				s1 = s1 + '1'
				s2 = s2 + '0'
			elif s1 > s2:
				s2 = s2 + '1'
				s1 = s1 + '0'
		elif s[i] == '0':
			s1 = s1 + '0'
			s2 = s2 + '0'
	print(s1)
	print(s2)
	t = t - 1


for _ in range(int(input())):
	n = int(input())
	string = input()
	s = ''
	t = ''
	flag = ''
	for i in range(n):
		if flag == '':
			if string[i] == '2':
				s += '1'
				t += '1'
			elif string[i] == '0':
				s += '0'
				t += '0'
			elif flag == '':
				s += '1'
				t += '0'
				flag = 'done'
		else:
			s += '0'
			t += string[i]
	print(s)
	print(t)


t = int(input())
for y in range(t):
	n = int(input())
	l = input()
	a = ''
	b = ''
	j = 0
	for i in range(n):
		if l[i] == '2':
			a = a + '1'
			b = b + '1'
		elif l[i] == '1':
			a = a + '1'
			b = b + '0'
			j = i
			break
		else:
			a = a + '0'
			b = b + '0'
	if j:
		a = a + (n - 1 - j) * '0'
		b = b + l[j + 1:]
	print(a)
	print(b)


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	a = ''
	b = ''
	eq = True
	for j in range(0, n):
		if eq:
			if x[j] == '0':
				a += '0'
				b += '0'
			elif x[j] == '2':
				a += '1'
				b += '1'
			else:
				a += '1'
				b += '0'
				eq = False
		elif x[j] == '0':
			a += '0'
			b += '0'
		elif x[j] == '2':
			a += '0'
			b += '2'
		else:
			a += '0'
			b += '1'
	print(a)
	print(b)


q = int(input())
for _ in range(q):
	n = int(input())
	x = input()
	a = '1'
	b = '1'
	fi = 0
	for i in range(1, n):
		xi = int(x[i])
		if xi == 2:
			if fi == 0:
				a += '1'
				b += '1'
			else:
				b += '2'
				a += '0'
		elif xi == 0:
			a += '0'
			b += '0'
		elif fi == 0:
			a += '1'
			b += '0'
			fi = 1
		else:
			a += '0'
			b += '1'
	print(a)
	print(b)


n = int(input())
for i in range(n):
	a = '1'
	b = '1'
	x = int(input())
	y = input()
	f = 0
	for j in range(1, x):
		if y[j] == '2' and f == 0:
			a += '1'
			b += '1'
		elif y[j] == '1' and f == 0:
			a += '1'
			b += '0'
			f = 1
		elif y[j] == '1' and f == 1:
			a += '0'
			b += '1'
		elif y[j] == '2' and f == 1:
			a += '0'
			b += '2'
		elif y[j] == '0':
			a += '0'
			b += '0'
	print(a)
	print(b)


t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	(n1, n2) = ('', '')
	if x.count('1') == 0:
		for j in range(len(x)):
			if x[j] == '2':
				n1 += '1'
				n2 += '1'
			else:
				n1 += '0'
				n2 += '0'
	else:
		for j in range(x.index('1') + 1):
			if x[j] == '2':
				n1 += '1'
				n2 += '1'
			elif x[j] == '1':
				n1 += '1'
				n2 += '0'
			else:
				n1 += '0'
				n2 += '0'
		for j in range(x.index('1') + 1, len(x)):
			if x[j] == '2':
				n1 += '0'
				n2 += '2'
			elif x[j] == '1':
				n1 += '0'
				n2 += '1'
			else:
				n1 += '0'
				n2 += '0'
	print(n1)
	print(n2)


for _ in range(int(input())):
	n = int(input())
	s = input()
	(a, b) = ('', '')
	for (i, c) in enumerate(s):
		if c == '2':
			a += '1'
			b += '1'
		elif c == '0':
			a += '0'
			b += '0'
		else:
			a += '1'
			b += '0'
			a += '0' * (n - i - 1)
			b += s[i + 1:]
			break
	print(a)
	print(b)


def calc(X):
	max_ = False
	a = ['0'] * len(X)
	b = ['0'] * len(X)
	for (i, x) in enumerate(X):
		if not max_ and x == '2':
			(a[i], b[i]) = ('1', '1')
		elif not max_ and x == '0':
			(a[i], b[i]) = ('0', '0')
		elif max_:
			b[i] = x
		elif x == '1':
			a[i] = '1'
			max_ = True
		elif x == '2':
			(a[i], b[i]) = ('1', '1')
	return (''.join(a), ''.join(b))
N = int(input())
cases = []
for _ in range(N):
	_ = input()
	cases.append(input())
for x in cases:
	(a, b) = calc(x)
	print(a)
	print(b)


for i in range(int(input())):
	a = int(input())
	b = input()
	(c, d) = ('', '')
	for i in range(a):
		if b[i] == '2':
			c += '1'
			d += '1'
		elif b[i] == '0':
			c += '0'
			d += '0'
		else:
			c += '1'
			d += '0'
			break
	for j in range(i + 1, a):
		c += '0'
		d += b[j]
	print(c)
	print(d)


t = int(input())
while t > 0:
	n = int(input())
	s = input()
	flag = 0
	a = ''
	b = ''
	i = 0
	while i < n:
		if s[i] != '1':
			a += str(int(s[i]) // 2)
			b += str(int(s[i]) // 2)
		else:
			flag = 1
			break
		i += 1
	if flag == 1:
		a += '1'
		b += '0'
		flag = 2
		i += 1
	if flag == 2 and i < n:
		while i < n:
			a += '0'
			b += s[i]
			i += 1
	print(a)
	print(b)
	t -= 1


def f0(reverse=None):
	return ('0', '0')

def f1(reverse=False):
	if reverse:
		return ('0', '1')
	else:
		return ('1', '0')

def f2(reverse=False):
	if reverse:
		return ('0', '2')
	else:
		return ('1', '1')
f = [f0, f1, f2]
T = int(input())
for t in range(T):
	reverse = False
	n = int(input())
	answer = [[], []]
	for i in input():
		(n1, n2) = f[int(i)](reverse)
		if int(i) == 1:
			reverse = True
		answer[0].append(n1)
		answer[1].append(n2)
	print(''.join(answer[0]), ''.join(answer[1]), sep='\n')


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(input())
	s1 = '1'
	s2 = '1'
	x = 1
	for i in range(1, n):
		if s[i] == '2' and x:
			s1 += '1'
			s2 += '1'
		elif s[i] == '1' and x:
			s1 += '1'
			s2 += '0'
			x = 0
		else:
			s1 += '0'
			s2 += s[i]
	print(s1)
	print(s2)


import math, collections, heapq
testcase = int(input())
for _ in range(testcase):
	input()
	s = input()
	a = b = ''
	f = 1
	for i in s:
		if f:
			if i == '2':
				a += '1'
				b += '1'
			elif i == '0':
				a += '0'
				b += '0'
			else:
				a += '1'
				b += '0'
				f = 0
		else:
			a += '0'
			b += i
	print(a)
	print(b)


def main():
	n = int(input())
	s = input()
	(a, b) = ('', '')
	maximise = False
	for c in s:
		if c == '2':
			if not maximise:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
		elif c == '0':
			a += '0'
			b += '0'
		elif c == '1':
			if not maximise:
				a += '1'
				b += '0'
				maximise = True
			else:
				a += '0'
				b += '1'
	print(a)
	print(b)
for _ in range(int(input())):
	main()


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	(mn, mx) = ('', '')
	has_diff = False
	for i in range(n):
		if x[i] == '0':
			mn += '0'
			mx += '0'
		if x[i] == '2':
			if not has_diff:
				mn += '1'
				mx += '1'
			else:
				mn += '2'
				mx += '0'
		if x[i] == '1':
			if not has_diff:
				mn += '0'
				mx += '1'
				has_diff = True
			else:
				mn += '1'
				mx += '0'
	print(mn, mx, sep='\n')


import math
for i in range(int(input())):
	n = int(input())
	x = input()
	a = ['0'] * n
	b = ['0'] * n
	p = n
	for i in range(n):
		if x[i] == '2':
			a[i] = '1'
			b[i] = '1'
		elif x[i] == '0':
			continue
		else:
			a[i] = 1
			p = i + 1
			break
	for j in range(p, n):
		b[j] = x[j]
	print(*a, sep='')
	print(*b, sep='')


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return [int(i) for i in input().split()]

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
ans = []
for _ in range(ii()):
	n = ii()
	s = input()
	s1 = '1'
	s2 = '1'
	t = ''
	i = 1
	for c in s[1:]:
		if c != '1':
			t += str(int(c) // 2)
			i += 1
		else:
			break
	if i < n:
		s1 += t + s[i] + '0' * (n - i - 1)
		s2 += t + '0' + s[i + 1:]
		ans.append(s1)
		ans.append(s2)
	else:
		ans.append(s1 + t)
		ans.append(s2 + t)
print(*ans, sep='\n')


t = int(input())
for i in range(t):
	n = int(input())
	num = input()
	ans_1 = ''
	ans_2 = ''
	greater = False
	for j in range(n):
		if greater == True:
			ans_1 += '0' * (n - j)
			ans_2 += num[j:]
			break
		if num[j] == '2':
			ans_1 += '1'
			ans_2 += '1'
		elif num[j] == '0':
			ans_1 += '0'
			ans_2 += '0'
		else:
			ans_1 += '1'
			ans_2 += '0'
			greater = True
	print(ans_1)
	print(ans_2)


n = int(input())
for i in range(n):
	l = int(input())
	s = input()
	s1 = '1'
	s2 = '1'
	c = 0
	for i in range(1, l):
		if s[i] == '0':
			s1 += '0'
			s2 += '0'
		if s[i] == '1':
			c += 1
			if c == 1:
				s1 += '1'
				s2 += '0'
			else:
				s1 += '0'
				s2 += '1'
		if s[i] == '2':
			if c == 0:
				s1 += '1'
				s2 += '1'
			else:
				s1 += '0'
				s2 += '2'
	print(s1)
	print(s2)


for _ in range(int(input())):
	a = int(input())
	n = input()
	t = ''
	l = ''
	flag = 0
	for i in range(len(n)):
		if n[i] == '0':
			t += '0'
			l += '0'
		elif n[i] == '1':
			if flag:
				t += '0'
				l += '1'
				continue
			flag = 1
			t += '1'
			l += '0'
		else:
			if flag:
				t += '0'
				l += '2'
				continue
			t += '1'
			l += '1'
	print(t)
	print(l)


t = int(input())

def solve(l):
	(a, b) = ('', '')
	is_one = ''
	for x in l:
		if '1' == is_one:
			if x == '2':
				a += '0'
				b += '2'
			elif x == '1':
				a += '0'
				b += '1'
			else:
				a += '0'
				b += '0'
		elif x == '2':
			a += '1'
			b += '1'
		elif x == '1':
			a += '1'
			b += '0'
			is_one += '1'
		else:
			a += '0'
			b += '0'
	return [a, b]
A = []
for n in range(t):
	x = int(input())
	c = input()
	A.append(solve(c))
for x in A:
	print(x[0])
	print(x[1])


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, X):
	assert X[0] == 2
	A = []
	B = []
	isEq = True
	for d in X:
		if d == 0:
			A.append(0)
			B.append(0)
		elif d == 1:
			if isEq:
				A.append(1)
				B.append(0)
			else:
				A.append(0)
				B.append(1)
			isEq = False
		else:
			assert d == 2
			if isEq:
				A.append(1)
				B.append(1)
			else:
				A.append(0)
				B.append(2)
				isEq = False
	A = ''.join(map(str, A))
	B = ''.join(map(str, B))
	return A + '\n' + B
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
T = int(input())
for t in range(T):
	(N,) = [int(x) for x in input().split()]
	X = [int(x) for x in input().decode().rstrip()]
	ans = solve(N, X)
	print(ans)


t = int(input())
for i in range(t):
	le = int(input())
	num = input()
	first = list()
	second = list()
	equal = True
	for j in num:
		if equal and (j == '2' or j == '0'):
			first.append(int(j) // 2)
			second.append(int(j) // 2)
		elif equal and j == '1':
			equal = 0
			first.append(1)
			second.append(0)
		else:
			second.append(int(j))
			first.append(0)
	print(*first, sep='')
	print(*second, sep='')


import math
T = int(input())
for _ in range(T):
	n = int(input())
	s = input()
	a = ''
	b = ''
	flag = 0
	for i in range(n):
		if s[i] == '2':
			a += '1'
			b += '1'
		elif s[i] == '0':
			a += '0'
			b += '0'
		else:
			flag = 1
			break
	if flag == 1:
		a += '1'
		b += '0'
		a += '0' * (n - i - 1)
		b += s[i + 1:n]
	print(a)
	print(b)


for i in range(int(input())):
	n = int(input())
	x = input()
	a = '1'
	b = '1'
	max = -1
	for j in range(1, n):
		dig = x[j]
		if max == 1:
			a += '0'
			b += dig
		elif dig == '2':
			a += '1'
			b += '1'
		elif dig == '0':
			a += '0'
			b += '0'
		else:
			a += '1'
			b += '0'
			max = 1
	print(a)
	print(b)


import math

def divisiblity(a, b):
	c = a % b
	if c == 0:
		return 0
	return b - c

def beautiful_string(n, k):
	a = int((math.sqrt(8 * k + 1) - 1) / 2) + 1
	b = k - int(a * (a - 1) / 2)
	if b == 0:
		s = 'a' * (n - a) + 'bb' + 'a' * (a - 2)
		return s
	else:
		s = 'a' * (n - a - 1) + 'b' + 'a' * (a - b) + 'b' + 'a' * (b - 1)
		return s

def ternary_xor(x):
	a = ''
	b = ''
	c = True
	for i in x:
		if i == '0':
			a += '0'
			b += '0'
		elif i == '1':
			if c:
				a += '1'
				b += '0'
				c = False
			else:
				a += '0'
				b += '1'
		elif c:
			a += '1'
			b += '1'
		else:
			a += '0'
			b += '2'
	return (a, b)
cases = int(input())
for _ in range(cases):
	l = input()
	x = input()
	(a, b) = ternary_xor(x)
	print(a)
	print(b)


def solve(ternary_number):
	a = '1'
	b = '1'
	greater = False
	for i in range(1, len(ternary_number)):
		if ternary_number[i] == '0':
			a += '0'
			b += '0'
		elif not greater and ternary_number[i] == '2':
			a += '1'
			b += '1'
		elif greater and ternary_number[i] == '2':
			a += '0'
			b += '2'
		elif not greater and ternary_number[i] == '1':
			a += '1'
			b += '0'
			greater = True
		elif greater and ternary_number[i] == '1':
			a += '0'
			b += '1'
	return a + '\n' + b

def main():
	n = int(input())
	for _ in range(n):
		__ = input()
		ternary_number = input()
		print(solve(ternary_number))
main()


t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	b = ''
	c = ''
	d = ''
	if x.count('1') == 0:
		for j in x:
			if j == '0':
				b = b + '0'
			else:
				b = b + '1'
		print(b)
		print(b)
	else:
		a = x.index('1')
		for k in range(a):
			if x[k] == '0':
				c = c + '0'
				d = d + '0'
			else:
				c = c + '1'
				d = d + '1'
		c = c + '1'
		d = d + '0'
		for l in range(a + 1, n):
			c = c + '0'
			d = d + x[l]
		print(c)
		print(d)


T = int(input())
for t in range(T):
	n = int(input())
	s = input()
	found_one = False
	first = ''
	second = ''
	for i in s:
		if found_one:
			break
		elif i == '1':
			first += '1'
			second += '0'
			found_one = True
			break
		elif i == '2':
			first += '1'
			second += '1'
		else:
			first += '0'
			second += '0'
	cur_len = len(first)
	if cur_len < n:
		first += '0' * (n - cur_len)
		second += s[-(n - cur_len):]
	print(first)
	print(second)


def solve():
	n = int(input())
	first = 0
	s = input()
	ans1 = []
	ans2 = []
	one_append = ans1.append
	two_append = ans2.append
	for i in s:
		if i == '2':
			if first == 0:
				one_append('1')
				two_append('1')
			else:
				one_append('0')
				two_append('2')
		elif i == '0':
			one_append('0')
			two_append('0')
		elif first == 0:
			one_append('1')
			two_append('0')
			first = 1
		elif first == 1:
			one_append('0')
			two_append('1')
	print(''.join(ans1))
	print(''.join(ans2))
t = int(input())
for i in range(t):
	solve()


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	f = 0
	a = ''
	b = ''
	for c in s:
		if c == '2':
			if f:
				a += '0'
				b += '2'
			else:
				a += '1'
				b += '1'
		elif c == '1':
			if f:
				a += '0'
				b += '1'
			else:
				a += '1'
				b += '0'
				f = 1
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


for i in range(int(input())):
	x = int(input())
	n = list(input())
	FLAG = 0
	index = x
	Badha = ''
	Chota = ''
	for i in range(x):
		if n[i] == '1':
			index = i + 1
			Badha += '1'
			Chota += '0'
			break
		elif n[i] == '2':
			Badha += '1'
			Chota += '1'
		else:
			Badha += '0'
			Chota += '0'
	for i in range(index, x):
		if n[i] == '1':
			Badha += '0'
			Chota += '1'
		elif n[i] == '2':
			Badha += '0'
			Chota += '2'
		else:
			Badha += '0'
			Chota += '0'
	print(Badha)
	print(Chota)


for i in range(int(input())):
	n = int(input())
	num = [int(i) for i in input()]
	a = ''
	b = ''
	n = 0
	for i in num:
		if i == 0:
			a += '0'
			b += '0'
		elif i == 2:
			if n == 0:
				a += '1'
				b += '1'
			if n == 1:
				a += '0'
				b += '2'
		elif i == 1:
			if n == 0:
				a += '1'
				b += '0'
				n = 1
			elif n == 1:
				a += '0'
				b += '1'
	print(a)
	print(b)


for i in range(int(input())):
	(n, s) = (int(input()), input())
	(ans1, ans2) = ([], [])
	flag = 0
	for j in s:
		if j == '1':
			if flag:
				ans2.append('1')
				ans1.append('0')
			else:
				ans1.append('1')
				ans2.append('0')
				flag = 1
		elif j == '2':
			if flag:
				ans2.append('2')
				ans1.append('0')
			else:
				ans2.append('1')
				ans1.append('1')
		else:
			ans1.append('0')
			ans2.append('0')
	print(''.join(ans1))
	print(''.join(ans2))


for k in range(int(input())):
	n = int(input())
	t = input()
	a = ''
	b = ''
	u = 0
	for k in t:
		if k == '2':
			if u == 0:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
		elif k == '1':
			if u == 0:
				a += '1'
				b += '0'
				u += 1
			else:
				a += '0'
				b += '1'
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


n = int(input())
for _ in range(n):
	q = int(input())
	res = input()
	res = list(map(int, res))
	res1 = [0] * q
	res2 = [0] * q
	res1[0] = 1
	res2[0] = 1
	flag = True
	for i in range(1, q):
		if res[i] == 0:
			res1[i] = 0
			res2[i] = 0
		elif res[i] == 1:
			if flag:
				res1[i] = 1
				res2[i] = 0
				flag = False
			else:
				res1[i] = 0
				res2[i] = 1
		elif flag:
			res1[i] = 1
			res2[i] = 1
		else:
			res1[i] = 0
			res2[i] = 2
	for j in res1:
		print(j, end='')
	print()
	for k in res2:
		print(k, end='')
	print()


for _ in range(int(input())):
	num = int(input())
	l = input()
	n = []
	for i in l:
		n.append(i)
	l1 = []
	l2 = []
	for i in range(num):
		l1.append('')
		l2.append('')
	for i in range(num):
		if n[i] == '1':
			l1[i] = '1'
			l2[i] = '0'
			for j in range(i + 1, num):
				l2[j] = n[j]
				l1[j] = '0'
			break
		else:
			l1[i] = str(int(n[i]) // 2)
			l2[i] = str(int(n[i]) // 2)
	print(''.join(l1))
	print(''.join(l2))


t = int(input())
for i in range(t):
	m = int(input())
	s = input()
	(a, b) = ('', '')
	f = 1
	for j in range(m):
		if s[j] == '2':
			if f == 1:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
		elif s[j] == '1':
			if f == 1:
				a += '1'
				b += '0'
				f = 0
			else:
				a += '0'
				b += '1'
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


import sys
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	a = int(input())
	s = input()[1:]
	ans1 = '1'
	ans2 = '1'
	f = False
	for i in s:
		if i == '0':
			ans1 += '0'
			ans2 += '0'
		elif i == '2':
			if f == False:
				ans1 += '1'
				ans2 += '1'
			else:
				ans1 += '0'
				ans2 += '2'
		elif f == False:
			ans1 += '1'
			ans2 += '0'
			f = True
		else:
			ans1 += '0'
			ans2 += '1'
	print(ans1)
	print(ans2)


def getNumbers(line):
	n = len(line)
	a = ['0'] * n
	b = ['0'] * n
	a[0] = b[0] = '1'
	pasted = False
	for i in range(1, n):
		if line[i] == '1':
			if pasted:
				b[i] = '1'
			else:
				a[i] = '1'
				pasted = True
		if line[i] == '2':
			if pasted:
				b[i] = '2'
			else:
				a[i] = '1'
				b[i] = '1'
	return (a, b)
kt = int(input())
for t in range(kt):
	n = int(input())
	line = input()
	(a, b) = getNumbers(line)
	print(''.join(a))
	print(''.join(b))


import sys
t = int(sys.stdin.readline())
ans_arr = []
for x in range(t):
	n = int(sys.stdin.readline())
	x = sys.stdin.readline().strip()
	n1 = ''
	n2 = ''
	flag = 1
	for e in range(n):
		if e == 0:
			n1 += '1'
			n2 += '1'
		elif flag == 1:
			if x[e] == '1':
				n1 += '1'
				n2 += '0'
				flag = 0
			elif x[e] == '2':
				n1 += '1'
				n2 += '1'
			elif x[e] == '0':
				n1 += '0'
				n2 += '0'
		elif x[e] == '0':
			n1 += '0'
			n2 += '0'
		elif x[e] == '1':
			n1 += '0'
			n2 += '1'
		elif x[e] == '2':
			n1 += '0'
			n2 += '2'
	ans_arr.append(n1 + '\n' + n2)
print('\n'.join(ans_arr))


def solve(n):
	(a, b) = ('', '')
	sama = True
	abesar = False
	for kar in n:
		if kar == '2':
			if sama:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
		elif kar == '1':
			if sama:
				a += '1'
				b += '0'
				sama = False
			else:
				a += '0'
				b += '1'
		elif kar == '0':
			a += '0'
			b += '0'
	return (a, b)
tt = int(input())
for i in range(tt):
	input()
	(a, b) = solve(input())
	print(a)
	print(b)


for t in range(int(input())):
	n = int(input())
	x = input()
	s = ''
	f = False
	for y in x:
		if y == '0':
			print('0', end='')
			s += '0'
		elif y == '1':
			if f:
				print('0', end='')
				s += '1'
			else:
				print('1', end='')
				s += '0'
			f = True
		elif f:
			print('0', end='')
			s += '2'
		else:
			print('1', end='')
			s += '1'
	print()
	print(s)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	test = n
	a = '1'
	b = '1'
	for i in range(1, n):
		if s[i] == '1':
			test = i
			break
	for j in range(1, n):
		if j == test:
			a = a + '1'
			b = b + '0'
		elif j > test:
			a += '0'
			b += s[j]
		elif s[j] == '2':
			a += '1'
			b += '1'
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


te = int(input())
while te > 0:
	te -= 1
	n = int(input())
	x = input()
	y = -1
	a = '1'
	b = '1'
	for i in range(1, n):
		if x[i] == '2' and y == -1:
			a += '1'
			b += '1'
		elif x[i] == '2' and y > -1:
			a += '0'
			b += '2'
		if x[i] == '1' and y == -1:
			y = 4
			a += '1'
			b += '0'
		elif x[i] == '1' and y > -1:
			a += '0'
			b += '1'
		if x[i] == '0':
			a += '0'
			b += '0'
	print(a)
	print(b)


t = int(input())
while t:
	t -= 1
	n = int(input())
	x = input()
	a = ''
	b = ''
	flag = False
	for (ind, i) in enumerate(x):
		if i == '2':
			b += '1'
			a += '1'
		elif i == '1':
			flag = True
			b += '1'
			a += '0'
			for jnd in range(ind + 1, n):
				a += x[jnd]
				b += '0'
			break
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


import math
t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	a = ['0'] * n
	b = ['0'] * n
	a[0] = b[0] = '1'
	first_1 = False
	for (i, c) in enumerate(x):
		first_1 = c == '1'
		if i == 0:
			a[i] = b[i] = '1'
		elif not first_1:
			if c == '0':
				a[i] = b[i] = '0'
			else:
				a[i] = b[i] = '1'
		else:
			a[i] = '1'
			a[i + 1:] = '0' * (n - i - 1)
			b[i] = '0'
			b[i + 1:] = x[i + 1:]
			break
	print(''.join(a))
	print(''.join(b))


from math import ceil
t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	a = ''
	b = ''
	has_unit = False
	for i in range(n):
		if x[i] == '2':
			if has_unit:
				a += '0'
				b += '2'
			else:
				a += '1'
				b += '1'
		elif x[i] == '1':
			if not has_unit:
				a += '1'
				b += '0'
				has_unit = True
			else:
				a += '0'
				b += '1'
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	ans1 = ''
	ans2 = ''
	k = 0
	kr = 0
	for i in x:
		i = int(i)
		if i == 0:
			ans1 += '0'
			ans2 += '0'
		elif i == 1:
			if k == 0:
				ans1 += '0'
				ans2 += '1'
			else:
				ans1 += '1'
				ans2 += '0'
			k = 1
		elif k == 0:
			ans1 += '1'
			ans2 += '1'
		else:
			ans1 += '2'
			ans2 += '0'
	print(ans2)
	print(ans1)


def a():
	n = int(input())
	num = input()
	a = ''
	b = ''
	count1 = 0
	for i in range(n):
		if i == 0:
			a += '1'
			b += '1'
			continue
		if num[i] == '0':
			a += '0'
			b += '0'
			continue
		if num[i] == '1':
			count1 += 1
			if count1 == 1:
				a += '1'
				b += '0'
			else:
				a += '0'
				b += '1'
		if num[i] == '2' and i != 0:
			if count1 == 0:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
	print(a)
	print(b)
t = int(input())
for i in range(t):
	a()


from sys import stdin, stdout

def solve():
	n = int(input())
	s = str(input())
	(t, d) = ('1', '1')
	one = False
	for i in s[1:]:
		if i == '2':
			if one:
				t += '0'
				d += '2'
			else:
				t += '1'
				d += '1'
		elif i == '1':
			if one:
				t += '0'
				d += '1'
			else:
				t += '1'
				d += '0'
			one = True
		else:
			t += '0'
			d += '0'
	print(t)
	print(d)
	return 0
t = int(input())
for i in range(t):
	solve()


t = int(input())
for w in range(t):
	n = int(input())
	x = input()
	x = [s for s in list(x)]
	ans = [['0' for i in range(n)], ['0' for i in range(n)]]
	big = False
	ans[0][0] = '1'
	ans[1][0] = '1'
	for i in range(1, len(x)):
		if big == False:
			if x[i] == '2':
				ans[0][i] = '1'
				ans[1][i] = '1'
			elif x[i] == '0':
				ans[0][i] = '0'
				ans[1][i] = '0'
			elif x[i] == '1':
				ans[0][i] = '1'
				ans[1][i] = '0'
				big = True
		else:
			ans[1][i] = x[i]
	print(''.join(ans[0]))
	print(''.join(ans[1]))


from sys import stdin, stdout
ans = ''
for _ in range(int(input())):
	n = int(stdin.readline())
	c = stdin.readline()
	a = '1'
	b = '1'
	i = 1
	f = False
	while i < n:
		if c[i] == '0':
			a += '0'
			b += '0'
		elif c[i] == '1':
			if not f:
				a += '1'
				b += '0'
				f = True
			else:
				a += '0'
				b += '1'
		elif not f:
			a += '1'
			b += '1'
		else:
			a += '0'
			b += '2'
		i += 1
	ans += a + '\n' + b + '\n'
stdout.write(ans)


for _ in range(int(input())):
	n = int(input())
	s = input()
	i = 0
	a = ''
	b = ''
	while i < n:
		if s[i] == '1':
			break
		else:
			if s[i] == '2':
				a += '1'
				b += '1'
			if s[i] == '0':
				a += '0'
				b += '0'
		i = i + 1
	if i < n:
		a = a + '1'
		b = b + '0'
		i = i + 1
	for j in range(i, n):
		if s[j] == '0':
			a += '0'
			b += '0'
		else:
			a += '0'
			b += s[j]
	print(a)
	print(b)


test = int(input())
while test:
	test -= 1
	n = int(input())
	x = list(input())
	ans1 = ''
	ans2 = ''
	flag = True
	for i in x:
		if flag:
			if i == '2':
				ans1 += '1'
				ans2 += '1'
			elif i == '1':
				ans1 += '1'
				ans2 += '0'
				flag = False
			else:
				ans1 += '0'
				ans2 += '0'
		else:
			ans1 += '0'
			ans2 += i
	print(ans1, ans2, sep='\n')


for ii in range(int(input())):
	n = int(input())
	x = input()
	a = ''
	b = ''
	f = 1
	for i in x:
		i = int(i)
		if f:
			if i == 2:
				a += '1'
				b += '1'
			elif i == 1:
				a += '1'
				b += '0'
				f = 0
			else:
				a += '0'
				b += '0'
		elif i == 2:
			a += '0'
			b += '2'
		elif i == 1:
			a += '0'
			b += '1'
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


t = int(input())
for i in range(0, t):
	a = ''
	b = ''
	f = True
	n = int(input())
	x = input()
	if x[0] == '1':
		a += '2'
		b += '2'
	else:
		a += '1'
		b += '1'
	for s in range(1, n):
		if x[s] == '0':
			a += '0'
			b += '0'
		elif x[s] == '1' and f:
			a += '1'
			b += '0'
			f = False
		elif x[s] == '2' and f:
			a += '1'
			b += '1'
		elif x[s] == '1' and (not f):
			a += '0'
			b += '1'
		elif x[s] == '2' and (not f):
			a += '0'
			b += '2'
	print(a)
	print(b)


t = int(input())
for i in range(0, t):
	n = int(input())
	x = str(input())
	x = [int(x[i]) for i in range(1, n)]
	a = [1]
	b = [1]
	first = True
	for i in range(0, n - 1):
		if x[i] == 0:
			a += [0]
			b += [0]
		elif x[i] == 1:
			if first:
				a += [1]
				b += [0]
				first = False
			else:
				a += [0]
				b += [1]
		elif x[i] == 2:
			if first:
				a += [1]
				b += [1]
			else:
				a += [0]
				b += [2]
	print(*a, sep='')
	print(*b, sep='')


for _ in range(int(input())):
	n = int(input())
	s = input()
	k1 = '1'
	k2 = '1'
	for i in range(1, n):
		if s[i] == '1':
			k1 += '1' + '0' * (n - (i + 1))
			k2 += '0' + s[i + 1:]
			break
		elif s[i] == '2':
			k1 += '1'
			k2 += '1'
		else:
			k1 += '0'
			k2 += '0'
	print(k1, end='\n')
	print(k2, end='\n')


import math

class Read:

	@staticmethod
	def string():
		return input()

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(sep=' '):
		return input().split(sep)

	@staticmethod
	def list_int(sep=' '):
		return list(map(int, input().split(sep)))

def solve():
	n = Read.int()
	c = Read.string()
	a = ''
	b = ''
	state = True
	for i in c:
		if i == '2':
			if state:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
		elif i == '0':
			a += '0'
			b += '0'
		elif state:
			a += '1'
			b += '0'
			state = False
		else:
			a += '0'
			b += '1'
	print(a)
	print(b)
query_count = Read.int()
while query_count:
	query_count -= 1
	solve()


import math
for inp in range(int(input())):
	n = int(input())
	a = list(input())
	for i in range(n):
		a[i] = int(a[i])
	c = [0] * n
	d = [0] * n
	for i in range(n):
		(x, y) = (a[i] // 2, a[i] - a[i] // 2)
		(c[i], d[i]) = (max(x, y), min(x, y))
		if x > y or y > x:
			break
	for j in range(i + 1, n):
		d[j] = a[j]
		c[j] = 0
	for i in c:
		print(i, end='')
	print()
	for i in d:
		print(i, end='')
	print()


t = int(input())
for t in range(t):
	n = int(input())
	s = input()
	t1 = '1'
	t2 = '1'
	a = 0
	for i in range(1, len(s)):
		if s[i] == '0':
			t1 += '0'
			t2 += '0'
		elif s[i] == '1':
			if a != 0:
				t1 += '0'
				t2 += '1'
			else:
				t2 += '0'
				t1 += '1'
				a = 1
		elif a == 0:
			t1 += '1'
			t2 += '1'
		else:
			t1 += '0'
			t2 += '2'
	print(t1 + '\n' + t2)


for i in range(int(input())):
	n = int(input())
	s = input()
	a = []
	b = []
	flag = False
	for j in range(n):
		if s[j] == '2':
			if flag:
				a.append('0')
				b.append('2')
			else:
				a.append('1')
				b.append('1')
		elif s[j] == '1':
			if j != 0:
				if flag:
					a.append('0')
					b.append('1')
				else:
					a.append('1')
					b.append('0')
					flag = True
			else:
				a.append('2')
				b.append('2')
		elif j != 0:
			a.append('0')
			b.append('0')
		elif flag:
			a.append('1')
			b.append('2')
		else:
			a.append('2')
			b.append('1')
			flag = True
	print(''.join(a))
	print(''.join(b))


import sys
from math import sqrt
inp = sys.stdin.readline
read = lambda : list(map(int, inp().split()))

def a():
	ans = ''
	for _ in range(int(inp())):
		(a, b) = read()
		if a % b == 0:
			ans += '0\n'
		else:
			ans += str((a // b + 1) * b - a) + '\n'
	print(ans)

def b():
	ans = ''
	for _ in range(int(inp())):
		(n, k) = read()
		(f1, f2) = (n - 2, n - 1)
		l = 1
		while (l + 1) * l // 2 < k:
			l += 1
		f1 -= l - 1
		f2 -= k - l * (l - 1) // 2 - 1
		res = ''
		for i in range(n):
			if i in (f1, f2):
				res += 'b'
			else:
				res += 'a'
		ans += res + '\n'
	print(ans)

def c():
	ans = ''
	for _ in range(int(inp())):
		n = int(inp())
		x = inp().strip()
		res = ['', '']
		flag = 0
		for j in x:
			if j == '1':
				if flag:
					res[1] += '1'
					res[0] += '0'
				else:
					res[1] += '0'
					res[0] += '1'
					flag = 1
			elif j == '2':
				if flag:
					res[1] += '2'
					res[0] += '0'
				else:
					res[1] += '1'
					res[0] += '1'
			else:
				res[1] += '0'
				res[0] += '0'
		ans += res[0] + '\n' + res[1] + '\n'
	print(ans)
c()


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	(a, b) = ([], [])
	(ma, mb, j) = (0, 0, n)
	for i in x:
		c = int(i) % 3
		if c == 0:
			a.append(0)
			b.append(0)
		elif c == 1:
			if ma > mb:
				mb += 2 ** j
				j -= 1
				b.append(1)
				a.append(0)
			else:
				ma += 2 ** j
				j -= 1
				a.append(1)
				b.append(0)
		elif c == 2:
			if ma > mb:
				mb += 2 ** j
				j -= 1
				b.append(2)
				a.append(0)
			elif mb > ma:
				ma += 2 ** j
				j -= 1
				a.append(2)
				b.append(0)
			else:
				ma += 2 ** j
				mb += 2 ** j
				j -= 1
				a.append(1)
				b.append(1)
	print(*a, sep='')
	print(*b, sep='')


test = int(input())
while test > 0:
	test -= 1
	n = int(input())
	s = input()
	a = '1'
	b = '1'
	ok = 0
	for i in range(1, n):
		if s[i] == '2':
			if ok == 1:
				a += '0'
				b += '2'
			else:
				a += '1'
				b += '1'
		if s[i] == '1':
			if ok == 0:
				a += '1'
				b += '0'
				ok = 1
			else:
				a += '0'
				b += '1'
		if s[i] == '0':
			a += '0'
			b += '0'
	print(a)
	print(b)


t = int(input())
for _ in range(t):
	n = int(input())
	c = list(map(int, list(input())))
	a = []
	b = []
	count_one = 0
	for i in c:
		if i == 2 or i == 0:
			if count_one == 0:
				a.append(i // 2)
				b.append(i // 2)
			else:
				a.append(0)
				b.append(i)
		elif i == 1:
			if count_one == 0:
				a.append(1)
				b.append(0)
				count_one = 1
			else:
				a.append(0)
				b.append(1)
	for i in a:
		print(i, end='')
	print('')
	for i in b:
		print(i, end='')
	print('')


for _ in range(int(input())):
	n = int(input())
	s = input()
	a = ''
	b = ''
	flag = 0
	for (i, val) in enumerate(s):
		if flag != 1:
			if val == '2':
				a += '1'
				b += '1'
			elif val == '0':
				a += '0'
				b += '0'
			else:
				a += '0'
				b += '1'
				flag = 1
		elif flag == 1:
			a += val
			b += '0'
	print(a)
	print(b)


for i in range(int(input())):
	n = int(input())
	x = int(input())
	if n == 1:
		print(1)
		print(1)
	else:
		x = str(x)
		a = ''
		b = ''
		co = 0
		for i in range(n):
			if x[i] == '2' and co == 0:
				a += '1'
				b += '1'
			elif x[i] == '2' and co >= 1:
				a += '0'
				b += '2'
			elif x[i] == '0':
				a += '0'
				b += '0'
			elif x[i] == '1' and co == 0:
				a += '1'
				b += '0'
				co += 1
			elif x[i] == '1' and co >= 1:
				a += '0'
				b += '1'
		print(int(a))
		print(int(b))


from sys import stdin, stdout
for t in range(int(input())):
	n = int(input())
	num = stdin.readline()
	ans1 = '1'
	ans2 = '1'
	seen = False
	for i in range(1, n):
		if num[i] == '2' and seen == False:
			ans1 = ans1 + '1'
			ans2 = ans2 + '1'
		elif num[i] == '2' and seen == True:
			ans1 = ans1 + '0'
			ans2 = ans2 + '2'
		elif num[i] == '1' and seen == False:
			ans1 = ans1 + '1'
			ans2 = ans2 + '0'
			seen = True
		elif num[i] == '1' and seen == True:
			ans1 = ans1 + '0'
			ans2 = ans2 + '1'
		else:
			ans1 = ans1 + '0'
			ans2 = ans2 + '0'
	stdout.write(ans1 + '\n' + ans2 + '\n')


def solve(lst):
	min_st = ''
	i = 0
	while i < len(lst):
		ch = lst[i]
		if ch == '1':
			print(1, end='')
			min_st += '0'
			break
		if ch == '2':
			print(1, end='')
			min_st += '1'
		if ch == '0':
			print(0, end='')
			min_st += '0'
		i += 1
	if i != len(lst):
		i += 1
	print('0' * (len(lst) - i))
	print(min_st, end='')
	print(''.join(lst[i:len(lst)]))
t = int(input())
while t:
	n = int(input())
	st = list(input())
	solve(st)
	t -= 1


t = int(input())
while t:
	t = t - 1
	n = int(input())
	x = input()
	a = '1'
	b = '1'
	y = 0
	for i in range(1, n):
		if x[i] == '2' and y == 1:
			a = a + '0'
			b = b + '2'
		if x[i] == '2' and y == 0:
			a = a + '1'
			b = b + '1'
		if x[i] == '1' and y == 1:
			a = a + '0'
			b = b + '1'
		if x[i] == '1' and y == 0:
			a = a + '1'
			b = b + '0'
			y = 1
		if x[i] == '0':
			a = a + '0'
			b = b + '0'
	print(a)
	print(b)


t = int(input())
for i in range(t):
	n = int(input())
	s1 = []
	s2 = []
	x = ''
	y = ''
	a = list(input())
	for j in range(len(a)):
		if a[j] == '2':
			s1.append(1)
			s2.append(1)
		elif a[j] == '0':
			s1.append(0)
			s2.append(0)
		elif a[j] == '1':
			s1.append(1)
			s2.append(0)
			for k in range(j + 1, n, 1):
				s2.append(a[k])
				s1.append(0)
			break
	for j in range(n):
		x += str(s1[j])
		y += str(s2[j])
	print(x)
	print(y)


q = int(input())
for j in range(q):
	n = int(input())
	c = input()
	a = []
	b = []
	flag = 0
	for i in range(n):
		if c[i] == '0':
			a.append(0)
			b.append(0)
		elif c[i] == '1':
			if flag == 0:
				a.append(1)
				b.append(0)
			else:
				a.append(0)
				b.append(1)
			flag = 1
		elif flag == 1:
			a.append(0)
			b.append(2)
		else:
			a.append(1)
			b.append(1)
	for i in a:
		print(i, end='')
	print()
	for i in b:
		print(i, end='')
	print()


t = int(input())
for i in range(t):
	a = int(input())
	b = input()
	a1 = ''
	b1 = ''
	flag = 0
	for j in b:
		if j == '2':
			if flag == 0:
				a1 += '1'
				b1 += '1'
			else:
				a1 += '0'
				b1 += '2'
		elif j == '1':
			if flag == 0:
				a1 += '1'
				b1 += '0'
				flag = 1
			else:
				a1 += '0'
				b1 += '1'
		else:
			a1 += '0'
			b1 += '0'
	print(a1)
	print(b1)


in1 = int(input())
for x in range(in1):
	inX = int(input())
	inY = input()
	str1 = ''
	str2 = ''
	popped = False
	for y in inY:
		if y == '2':
			if not popped:
				str1 += '1'
				str2 += '1'
			else:
				str1 += '0'
				str2 += '2'
		elif y == '1':
			if not popped:
				str1 += '1'
				str2 += '0'
				popped = True
			else:
				str1 += '0'
				str2 += '1'
		else:
			str1 += '0'
			str2 += '0'
	print(str1)
	print(str2)


for _ in range(int(input())):
	n = int(input())
	s = input()
	if s.find('1') != -1:
		a = str(int(s[:s.find('1')]) // 2) + '1' + '0' * (len(s[s.find('1'):]) - 1)
		b = str(int(s[:s.find('1')]) // 2) + '0' + s[s.find('1') + 1:]
	else:
		a = b = str(int(s) // 2)
	print(a)
	print(b)


num = int(input())
for i in range(num):
	x = int(input())
	n = input()
	n1_l = '1'
	n2_l = '1'
	f_o = False
	for char in n:
		if f_o:
			if char == '0':
				n1_l += '0'
				n2_l += '0'
			elif char == '1':
				if n1_l < n2_l:
					n1_l += '1'
					n2_l += '0'
				else:
					n2_l += '1'
					n1_l += '0'
			elif n1_l < n2_l:
				n1_l += '2'
				n2_l += '0'
			elif n1_l > n2_l:
				n1_l += '0'
				n2_l += '2'
			else:
				n1_l += '1'
				n2_l += '1'
		f_o = True
	print(n1_l)
	print(n2_l)


(t, n, x) = (int(input()), [], [])
Ans = [['', ''] for i in range(t)]
for i in range(t):
	n.append(int(input()))
	x.append(input())
for i in range(t):
	p = True
	d = x[i]
	for j in range(n[i]):
		if d[j] == '2' and p:
			Ans[i][0] += '1'
			Ans[i][1] += '1'
		elif d[j] == '0' and p:
			Ans[i][0] += '0'
			Ans[i][1] += '0'
		elif d[j] == '1' and p:
			Ans[i][0] += '1'
			Ans[i][1] += '0'
			p = False
		elif not p:
			Ans[i][0] += '0'
			Ans[i][1] += d[j]
	print('\n'.join(Ans[i]))


def xor(a, b):
	return (a + b) % 3

def solve(n, arr):
	ans1 = [None] * n
	ans2 = [None] * n
	bal = True
	for i in range(n):
		if not arr[i]:
			ans1[i] = ans2[i] = 0
		elif arr[i] == 2:
			if bal:
				ans1[i] = ans2[i] = 1
			else:
				ans1[i] = 2
				ans2[i] = 0
		elif bal:
			ans2[i] = 1
			ans1[i] = 0
			bal = False
		else:
			ans2[i] = 0
			ans1[i] = 1
	print(*ans1, sep='')
	print(*ans2, sep='')
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input()))
	solve(n, arr)


n = int(input())
l = []
for i in range(n):
	digit = int(input())
	str = input()
	a = ''
	b = ''
	count = 0
	for x in str:
		if count == 0:
			if x == '0':
				a = a + '0'
				b = b + '0'
			elif x == '2':
				a = a + '1'
				b = b + '1'
			else:
				a = a + '1'
				b = b + '0'
				count = 1
		else:
			a = a + '0'
			b = b + x
	l.append(a)
	l.append(b)
for x in l:
	print(x)


t = int(input())
for _ in range(t):
	number = int(input())
	input_string = str(input())
	str1 = '1'
	str2 = '1'
	temp = 0
	for i in range(1, number):
		if input_string[i] == '2':
			str1 += '1'
			str2 += '1'
		elif input_string[i] == '1':
			str1 += '1'
			str2 += '0'
			temp = i
			break
		else:
			str1 += '0'
			str2 += '0'
	if temp != 0:
		for i in range(temp + 1, number):
			str1 += '0'
			str2 += input_string[i]
	print(str1)
	print(str2)


t = int(input())
while t > 0:
	n = int(input())
	x = list(input())
	a = '1'
	b = '1'
	i = 1
	while i < n and x[i] != '1':
		if x[i] == '0':
			a += '0'
			b += '0'
		else:
			a += '1'
			b += '1'
		i += 1
	if i < n:
		a += '1'
		b += '0'
		i += 1
		while i < n:
			a += '0'
			b += x[i]
			i += 1
	print(a)
	print(b)
	t -= 1


for T in range(int(input())):
	n = int(input())
	s = input()
	dec = False
	a = []
	b = []
	for i in s:
		if dec:
			a.append('0')
			b.append(i)
		elif i == '2':
			a.append('1')
			b.append('1')
		elif i == '1':
			a.append('1')
			b.append('0')
			dec = True
		else:
			a.append('0')
			b.append('0')
	print(''.join(a))
	print(''.join(b))


def r(t=int):
	return list(map(t, input().split()))

def ri(t=int):
	return t(input())

def cd(it):
	ret_val = dict()
	for v in it:
		ret_val[v] = ret_val.get(v, 0) + 1
	return ret_val
for _ in range(ri()):
	c = ri()
	s = input()
	(ans1, ans2) = ('', '')
	max_detected = False
	m_s = {'0': [0, 0], '1': [2, 2], '2': [1, 1]}
	m_d = {'0': [0, 0], '1': [0, 1], '2': [0, 2]}
	m_nd = {'0': [0, 0], '1': [0, 1], '2': [1, 1]}
	for i in s:
		if not ans1:
			k = m_s[i]
			ans1 += str(k[0])
			ans2 += str(k[1])
		elif not max_detected:
			k = m_nd[i]
			ans1 += str(k[0])
			ans2 += str(k[1])
		else:
			k = m_d[i]
			ans1 += str(k[1])
			ans2 += str(k[0])
		if k[0] != k[1]:
			max_detected = True
	print(ans1)
	print(ans2)


def solution():
	from sys import stdout, stdin
	(_input, _print) = (stdin.readline, stdout.write)
	(_range, _int, _enumerate) = (range, int, enumerate)
	for _ in _range(_int(_input())):
		n = _int(_input())
		a = _input().rstrip('\n')
		(b, c) = ('', '')
		i = 0
		f = True
		while i < n:
			if f:
				if a[i] == '2':
					b += '1'
					c += '1'
				elif a[i] == '1':
					b += '0'
					c += '1'
					f = False
				else:
					b += '0'
					c += '0'
			elif a[i] == '2':
				b += '2'
				c += '0'
			elif a[i] == '1':
				b += '1'
				c += '0'
			else:
				b += '0'
				c += '0'
			i += 1
		print(c)
		print(b)
solution()


t = int(input())
for case in range(t):
	length = int(input())
	s = input()
	a_bigger = False
	a = ['1']
	b = ['1']
	for i in range(1, length):
		if s[i] == '2':
			if a_bigger:
				a.append('0')
				b.append('2')
			else:
				a.append('1')
				b.append('1')
		if s[i] == '1':
			if a_bigger:
				a.append('0')
				b.append('1')
			else:
				a.append('1')
				b.append('0')
				a_bigger = True
		if s[i] == '0':
			a.append('0')
			b.append('0')
	print(''.join(a))
	print(''.join(b))


t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	a = ''
	b = ''
	diff = False
	for c in x:
		if diff:
			if c == '2':
				a += '0'
				b += '2'
			elif c == '1':
				a += '0'
				b += '1'
			elif c == '0':
				a += '0'
				b += '0'
		elif c == '2':
			a += '1'
			b += '1'
		elif c == '1':
			a += '1'
			b += '0'
			diff = True
		elif c == '0':
			a += '0'
			b += '0'
	print(a)
	print(b)


import sys
input = sys.stdin.readline
t = int(input())
while t:
	t -= 1
	n = int(input())
	x = list(input())
	if n == 1:
		print(1)
		print(1)
	else:
		a = ''
		b = ''
		c = 0
		for i in range(n):
			if x[i] != '2':
				break
		a += '1' * i
		b += '1' * i
		c = 0
		for j in range(i, n):
			if x[j] == '0':
				a += '0'
				b += '0'
			elif x[j] == '1':
				if c:
					a += '0'
					b += '1'
				else:
					a += '1'
					b += '0'
					c = 1
			elif c == 0:
				a += '1'
				b += '1'
			elif c:
				a += '0'
				b += '2'
		print(a)
		print(b)


def tx(c, n):
	s = [int(i) for i in str(c)]
	sep = False
	a = [0] * n
	b = [0] * n
	for i in range(n):
		if s[i] == 2:
			if sep:
				a[i] = 0
				b[i] = 2
			else:
				a[i] = 1
				b[i] = 1
		if s[i] == 1:
			if sep == False:
				a[i] = 1
				b[i] = 0
				sep = True
			else:
				a[i] = 0
				b[i] = 1
		if s[i] == 0:
			continue
	a = [str(i) for i in a]
	b = [str(i) for i in b]
	a = ''.join(a)
	b = ''.join(b)
	return (int(a), int(b))
ts = int(input())
for t in range(ts):
	n = int(input())
	c = int(input())
	(a, b) = tx(c, n)
	print(a)
	print(b)


t = int(input())
while t:
	t -= 1
	n = int(input())
	x = input()
	en = 1
	a = [[], []]
	for i in range(n):
		if x[i] == '1':
			a[en].append('1')
			a[1 - en].append('0')
			if en:
				en = 0
		elif x[i] == '0':
			a[0].append('0')
			a[1].append('0')
		elif en:
			a[0].append('1')
			a[1].append('1')
		else:
			a[0].append('2')
			a[1].append('0')
	print(''.join(a[0]))
	print(''.join(a[1]))


t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	res1 = ['0' for j in range(n)]
	res2 = ['0' for j in range(n)]
	check = False
	for j in range(n):
		if x[j] == '0':
			res1[j] = '0'
			res2[j] = '0'
		elif x[j] == '2':
			if check:
				res2[j] = '2'
			else:
				res1[j] = '1'
				res2[j] = '1'
		elif check:
			res2[j] = '1'
		else:
			res1[j] = '1'
			check = True
	print(''.join(res1))
	print(''.join(res2))


t = int(input())
while t != 0:
	n = int(input())
	A = str(input())
	res1 = ['1']
	res2 = ['1']
	i = 1
	while i < n:
		if A[i] == '2':
			res1.append('1')
			res2.append('1')
		elif A[i] == '1':
			res1.append('1')
			res2.append('0')
			break
		else:
			res1.append('0')
			res2.append('0')
		i += 1
	g = i + 1
	while g < n:
		if A[g] == '2':
			res1.append('0')
			res2.append('2')
		elif A[g] == '1':
			res1.append('0')
			res2.append('1')
		else:
			res1.append('0')
			res2.append('0')
		g += 1
	print(int(''.join(res1)))
	print(int(''.join(res2)))
	t -= 1


for _ in range(int(input())):
	n = int(input())
	s = input()
	if len(set(s)) == 1:
		print('1' * n)
		print('1' * n)
		continue
	else:
		a = ''
		b = ''
		flag = True
		for i in range(0, n):
			if s[i] == '2' and flag:
				a += '1'
			elif s[i] == '1' and flag:
				a += '1'
				flag = False
			else:
				a += '0'
		flag = True
		for i in range(0, n):
			if s[i] == '2' and flag:
				b += '1'
			elif s[i] == '1' and flag:
				b += '0'
				flag = False
			else:
				b = b + s[i]
	print(a)
	print(b)


for _ in range(int(input())):
	am = int(input())
	n = list(map(int, list(input())))
	n1 = list('0' * am)
	n2 = list('0' * am)
	flag = False
	was = True
	for i in range(am):
		if n[i] == 1:
			if flag:
				n2[i] = '1'
			else:
				flag = True
				n1[i] = '1'
		elif n[i] == 2:
			if flag:
				n2[i] = '2'
			else:
				n1[i] = '1'
				n2[i] = '1'
	print(''.join(n1))
	print(''.join(n2))


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	(q1, q2) = ('', '')
	cnt = 0
	for i in s:
		if i == '2':
			if cnt == 0:
				q1 += '1'
				q2 += '1'
			else:
				q1 += '2'
				q2 += '0'
		elif i == '0':
			q1 += '0'
			q2 += '0'
		else:
			if cnt == 0:
				q1 += '0'
				q2 += '1'
			else:
				q1 += '1'
				q2 += '0'
			cnt += 1
	print(q1, q2)


for _ in range(int(input())):
	n = int(input())
	x = input()
	(a, b, g) = ('', '', False)
	for el in x:
		if el == '2':
			if g:
				a += '0'
				b += '2'
			else:
				a += '1'
				b += '1'
		elif el == '1':
			if g:
				a += '0'
				b += '1'
			else:
				a += '1'
				b += '0'
				g = True
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


t = int(input())
for _ in range(t):
	x = int(input())
	a = int(input())
	fuck = []
	zuck = []
	z = str(a)
	ans = list(z.strip(''))
	for i in range(len(ans)):
		if ans[i] == '2':
			fuck.append('1')
			zuck.append('1')
		elif ans[i] == '0':
			fuck.append('0')
			zuck.append('0')
		elif ans[i] == '1':
			fuck.append('1')
			zuck.append('0')
			for j in range(i + 1, len(ans)):
				zuck.append(ans[j])
				fuck.append(0)
			break
	f = ''
	z = ''
	for i in fuck:
		f += str(i)
	print(int(f))
	for i in zuck:
		z += str(i)
	print(int(z))


import sys
input = sys.stdin.readline
(t,) = map(int, input().split())
for _ in range(t):
	n = int(input())
	s = input().strip()
	f = 0
	xs = []
	ys = []
	for c in s:
		if c == '0':
			xs.append(0)
			ys.append(0)
		elif c == '1':
			if f:
				xs.append(0)
				ys.append(1)
			else:
				xs.append(1)
				ys.append(0)
				f = 1
		elif f:
			xs.append(0)
			ys.append(2)
		else:
			xs.append(1)
			ys.append(1)
	xs = map(str, xs)
	ys = map(str, ys)
	print(''.join(xs))
	print(''.join(ys))


R = lambda : map(int, input().split())
t = int(input())
for _ in range(t):
	z = int(input())
	x = input()
	a = ''
	b = ''
	flag = False
	for ch in x:
		if ch == '0':
			a += '0'
			b += '0'
		elif not flag:
			if ch == '2':
				a += '1'
				b += '1'
			if ch == '1':
				a += '1'
				b += '0'
				flag = True
		elif flag:
			a += '0'
			b += ch
	print(a)
	print(b)


for _ in range(int(input())):
	n = int(input())
	a = input()
	m = 0
	ls = ''
	for i in range(n):
		d = a[i]
		if d == '2':
			ls = ls + '1'
		elif d == '0':
			ls = ls + '0'
		else:
			ls = ls + '1'
			m = n - 1 - i
			break
	ls = ls + '0' * m
	print(int(ls))
	print(int(a) - int(ls))


n = int(input())
for i in range(0, n):
	num = int(input())
	line = str(input())
	judge = 0
	a = ''
	b = ''
	for i in range(0, len(line)):
		if judge == 0:
			if line[i] == '2' or line[i] == '0':
				a += str(int(int(line[i]) / 2))
				b += str(int(int(line[i]) / 2))
			else:
				a += '1'
				b += '0'
				judge = 1
		else:
			a += '0'
			b += line[i]
	print(a)
	print(b)


for t in range(int(input())):
	n = int(input())
	s = input()
	a = ''
	b = ''
	if s[0] == '1':
		a += '3'
		b += '1'
	else:
		a += '1'
		b += '1'
	k = True
	for i in range(1, n):
		if s[i] == '2' and k:
			a += '1'
			b += '1'
		elif s[i] == '0':
			a += '0'
			b += '0'
		elif s[i] == '1' and k:
			a += '1'
			b += '0'
			k = False
		else:
			a += '0'
			b += s[i]
	print(a)
	print(b)


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
from math import gcd
from bisect import bisect

def solution():
	for _ in range(int(input())):
		n = int(input())
		x = input()
		a = '1'
		b = '1'
		s = 0
		x = x[1:]
		for i in x:
			if i == '0':
				a += '0'
				b += '0'
			elif i == '1':
				if s == 0:
					s = 1
					a += '1'
					b += '0'
				else:
					a += '0'
					b += '1'
			elif s == 0:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
		print(a)
		print(b)
solution()
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
read = lambda : list(map(int, input().strip().split(' ')))


def main():
	T = int(input())
	for t in range(T):
		n = int(input())
		s = input()
		a = '1'
		b = '1'
		for l in range(1, n):
			if s[l] == '2':
				a += '1'
				b += '1'
			elif s[l] == '0':
				a += '0'
				b += '0'
			else:
				break
		if len(a) != n:
			a += '1'
			b += '0'
			for i in range(l + 1, n):
				if s[i] == '2':
					a += '0'
					b += '2'
				elif s[i] == '1':
					a += '0'
					b += '1'
				else:
					a += '0'
					b += '0'
		print(a)
		print(b)
main()


t = int(input())
while t != 0:
	t -= 1
	n = int(input())
	s = input()
	s = str(s)
	a = ''
	b = ''
	v = 0
	c = 0
	for i in range(n):
		if int(s[i]) == 1:
			if v == 1 or c == 1:
				a = a + '0'
				b = b + s[i]
			elif c == 0:
				a = a + s[i]
				b = b + '0'
			v = 1
		elif int(s[i]) == 2:
			if v == 1:
				a = a + '0'
				b = b + s[i]
				c = 1
			else:
				a = a + '1'
				b = b + '1'
		else:
			a = a + '0'
			b = b + '0'
	print(a)
	print(b)


test_cases = int(input())

def handle():
	input()
	value = input()
	value_one = []
	value_two = []
	equal_still = True
	for val in value:
		if val == '0':
			value_one.append('0')
			value_two.append('0')
		elif val == '1':
			if equal_still:
				value_one.append('1')
				value_two.append('0')
				equal_still = False
			else:
				value_one.append('0')
				value_two.append('1')
		elif equal_still:
			value_one.append('1')
			value_two.append('1')
		else:
			value_one.append('0')
			value_two.append('2')
	print(''.join(value_one))
	print(''.join(value_two))
for _ in range(test_cases):
	handle()


for _ in range(int(input())):
	n = int(input())
	x = input()
	(f, s) = ([], [])
	l2 = 0
	for ch in range(len(x)):
		if x[ch] == '2':
			f.append('1')
			s.append('1')
		elif x[ch] == '1':
			f.append('1')
			s.append('0')
			l2 = ch
			break
		else:
			f.append('0')
			s.append('0')
	if l2 != 0 and l2 != len(x) - 1:
		for i in range(l2 + 1, len(x)):
			s.append(x[i])
			f.append('0')
	print(''.join(f))
	print(''.join(s))


c = int(input())
for i in range(c):
	a = int(input())
	b = input()
	k = 0
	f = str()
	f1 = str()
	for i in range(a):
		if k == 1:
			f += '0'
			f1 += str(b[i])
		elif b[i] == '0':
			f += '0'
			f1 += '0'
		elif b[i] == '2':
			f += '1'
			f1 += '1'
		elif k == 0:
			f += '1'
			f1 += '0'
			k = 1
		else:
			f += '0'
			f1 += '1'
	print(f)
	print(f1)


import sys
RI = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
for i in range(int(ri())):
	n = int(ri())
	st = ri()
	flag = False
	a = []
	b = []
	for i in st:
		if i == '1':
			if not flag:
				a.append(1)
				b.append(0)
				flag = not flag
			else:
				a.append(0)
				b.append(1)
		elif i == '2':
			if not flag:
				a.append(1)
				b.append(1)
			else:
				a.append(0)
				b.append(2)
		elif not flag:
			a.append(0)
			b.append(0)
		else:
			a.append(0)
			b.append(0)
	print(''.join(map(str, a)))
	print(''.join(map(str, b)))


from sys import stdin, stdout
for i in range(int(input())):
	n = int(input())
	s = stdin.readline()
	(a, b) = ('', '')
	f = 0
	for j in range(n):
		if f == 1:
			a += '0'
			b += s[j]
			continue
		if s[j] == '0':
			a += '0'
			b += '0'
		elif s[j] == '1':
			a += '1'
			b += '0'
			f = 1
		else:
			a += '1'
			b += '1'
	stdout.write(a + '\n' + b + '\n')


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	(a, b) = ([], [])
	first = True
	for i in x:
		if i == '0':
			a.append('0')
			b.append('0')
		elif i == '1':
			if first:
				a.append('0')
				b.append('1')
				first = False
			else:
				a.append('1')
				b.append('0')
		elif i == '2':
			if first:
				a.append('1')
				b.append('1')
			else:
				a.append('2')
				b.append('0')
	print(''.join(a))
	print(''.join(b))


t = int(input())
for j in range(t):
	len = int(input())
	str1 = input()
	a = ''
	b = ''
	flag_1 = False
	flag_2 = 0
	for i in str1:
		if i == '0':
			a += '0'
			b += '0'
		elif i == '1':
			if flag_2 > 0 and flag_1 == False:
				a += '1'
				b += '0'
			else:
				a += '0'
				b += '1'
			flag_1 = True
		else:
			flag_2 += 1
			if flag_1 == True:
				a += '0'
				b += '2'
			else:
				a += '1'
				b += '1'
	print(a)
	print(b)


for _ in range(int(input())):
	n = int(input())
	s = input()
	mx = ''
	mi = ''
	f = 0
	for i in range(n):
		f = i
		if s[i] == '2':
			mx += '1'
			mi += '1'
		elif s[i] == '0':
			mx += '0'
			mi += '0'
		elif s[i] == '1':
			mx += '1'
			mi += '0'
			break
	for i in range(f + 1, n):
		mx += '0'
		mi += s[i]
	print(mx)
	print(mi)


for i in range(int(input())):
	n = int(input())
	s = input()
	a = '1'
	b = '1'
	c1 = 0
	t1 = 0
	t2 = 0
	for i in range(1, n):
		if s[i] == '0':
			a += '0'
			b += '0'
		elif s[i] == '1':
			t2 += 1
			if t2 == 1:
				a += '1'
				b += '0'
			else:
				a += '0'
				b += '1'
		elif t2 > 0:
			a += '0'
			b += '2'
		else:
			a += '1'
			b += '1'
	print(a)
	print(b)


t = int(input())
i1 = 0
i2 = 0
for i in range(t):
	n = int(input())
	x = input()
	a = ''
	b = ''
	f = True
	for c in x:
		if c == '2':
			if f:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
		elif c == '1':
			if f:
				a += '1'
				b += '0'
				f = False
			else:
				a += '0'
				b += '1'
		else:
			a += '0'
			b += '0'
	print(int(a))
	print(int(b))


t = int(input())
for i in range(0, t):
	n = int(input())
	st = input()
	st1 = ''
	st2 = ''
	flag = False
	for i in range(0, len(st)):
		if st[i] == '1' and flag == False:
			flag = True
			st1 += '1'
			st2 += '0'
		elif st[i] == '2' and flag == False:
			st1 += '1'
			st2 += '1'
		elif st[i] == '1':
			st1 += '0'
			st2 += '1'
		elif st[i] == '0':
			st1 += '0'
			st2 += '0'
		elif st[i] == '2':
			st1 += '0'
			st2 += '2'
	print(st1)
	print(st2)


t = int(input())
while t:
	t += -1
	n = int(input())
	s = input()
	a1 = ''
	a2 = ''
	ch = 0
	for i in s:
		if ch == 0:
			if i == '2':
				a1 += '1'
				a2 += '1'
			elif i == '0':
				a1 += '0'
				a2 += '0'
			else:
				ch = 1
				a1 += '0'
				a2 += '1'
		elif i == '2':
			a1 += '2'
			a2 += '0'
		elif i == '0':
			a1 += '0'
			a2 += '0'
		else:
			a1 += '1'
			a2 += '0'
	print(a1)
	print(a2)


T = int(input())
for kkkk in range(T):
	n = int(input())
	x = input()
	s = ''
	d = ''
	flag = 1
	r = 1
	for i in x:
		if i == '2':
			if r == 1:
				s = s + '1'
				d = d + '1'
				r = 0
			elif flag == 1:
				s = s + '1'
				d = d + '1'
			else:
				s = s + '0'
				d = d + '2'
		elif i == '1':
			if flag == 1:
				s = s + '1'
				d = d + '0'
				flag = 0
			else:
				s = s + '0'
				d = d + '1'
		else:
			s = s + '0'
			d = d + '0'
	print(s)
	print(d)


for _ in range(int(input())):
	(n, x) = (int(input()), input())
	ind = x.find('1')
	if ind == -1:
		(a, b) = [x.replace('2', '1')] * 2
	else:
		(a, b) = [x[:ind].replace('2', '1')] * 2
		a += '1' + '0' * (n - len(a) - 1)
		b += '0' + x[ind + 1:]
	print(a)
	print(b)


for _ in range(int(input())):
	n = int(input())
	x = input()
	a = ''
	b = ''
	maior = False
	for (ind, i) in enumerate(x):
		if i == '2':
			if ind == 0 or maior == False:
				a += '1'
				b += '1'
			elif maior == 'b':
				a += '2'
				b += '0'
			else:
				a += '0'
				b += '2'
		elif i == '0':
			a += '0'
			b += '0'
		elif i == '1':
			if maior != 'a':
				a += '1'
				b += '0'
				maior = 'a'
			else:
				a += '0'
				b += '1'
				maior = 'a'
	print(a)
	print(b)


for _ in range(int(input())):
	n = int(input())
	k = input()
	(n1, n2) = ('', '')
	c = 0
	for i in k:
		if c == 0:
			if i == '2':
				n1 += '1'
				n2 += '1'
			elif i == '1':
				n1 += '1'
				n2 += '0'
				c = 1
			else:
				n1 += '0'
				n2 += '0'
		else:
			n1 += '0'
			n2 += i
	print(n1)
	print(n2)


def cal(size, xor):
	a = b = ''
	flag = False
	for j in range(size):
		if xor[j] == '0' or xor[j] == '2':
			if flag:
				ch1 = '0'
				ch2 = xor[j]
			else:
				ch1 = ch2 = str(int(xor[j]) // 2)
			a += ch1
			b += ch2
		elif flag:
			b += '1'
			a += '0'
		else:
			a += '1'
			b += '0'
			flag = True
	return '\n'.join([a, b])
t = int(input())
for i in range(t):
	n = int(input())
	c = input().strip()
	print(cal(n, c))


import math

def rMap():
	return map(int, input().split())

def rList():
	return list(map(int, input().split()))
t = int(input())
for i in range(t):
	n = int(input())
	x = list(input())
	a = ['1']
	b = ['1']
	count = 0
	for i in x[1:]:
		if i == '2':
			if count == 0:
				a.append('1')
				b.append('1')
			else:
				a.append('0')
				b.append('2')
		elif i == '1':
			if count == 0:
				a.append('1')
				b.append('0')
			else:
				a.append('0')
				b.append('1')
			count += 1
		else:
			a.append('0')
			b.append('0')
	print(''.join(a))
	print(''.join(b))


t = int(input())
for _ in range(t):
	n = int(input())
	(A, B) = ('', '')
	S = input()
	flg = False
	for i in range(n):
		if S[i] == '0':
			A = A[:] + '0'
			B = B[:] + '0'
		elif S[i] == '1':
			if flg:
				A = A[:] + '0'
				B = B[:] + '1'
			else:
				A = A[:] + '1'
				B = B[:] + '0'
				flg = True
		elif S[i] == '2':
			if flg:
				A = A[:] + '0'
				B = B[:] + '2'
			else:
				A = A[:] + '1'
				B = B[:] + '1'
	print(A)
	print(B)


for nt in range(int(input())):
	n = int(input())
	x = input()
	ans1 = ''
	ans2 = ''
	flag = 0
	for i in range(n):
		if x[i] == '2':
			if not flag:
				ans1 += '1'
				ans2 += '1'
			else:
				ans1 += '0'
				ans2 += '2'
		elif x[i] == '1':
			if not flag:
				ans1 += '1'
				ans2 += '0'
				flag = 1
			else:
				ans1 += '0'
				ans2 += '1'
		else:
			ans1 += '0'
			ans2 += '0'
	print(ans1)
	print(ans2)


s = ''
p = ''
q = ''
c = 0
l = []
t = int(input())
for i in range(t):
	c = 0
	ls = int(input())
	s = input()
	l = list(s)
	for j in l:
		c = c + 1
		if j == '2':
			p = p + '1'
			q = q + '1'
		if j == '0':
			p = p + '0'
			q = q + '0'
		if j == '1':
			p = p + '0'
			q = q + '1'
			break
	for x in range(c, len(s)):
		p = p + s[x]
	new = ls - len(q)
	for x in range(new):
		q += '0'
	print(q)
	q = ''
	print(p)
	p = ''


t = int(input())
for iii in range(t):
	n = int(input())
	x = list(input())
	a = [''] * n
	b = [''] * n
	for i in range(n - 1, -1, -1):
		tmp = x[i]
		if tmp == '0':
			(a[i], b[i]) = ('0', '0')
		elif tmp == '2':
			(a[i], b[i]) = ('1', '1')
		else:
			(a[i], b[i]) = ('0', '1')
	flag = False
	for i in range(n):
		if not flag and b[i] > a[i]:
			flag = True
		elif flag:
			if b[i] == '1':
				if a[i] == '0':
					(a[i], b[i]) = ('1', '0')
				else:
					(a[i], b[i]) = ('2', '0')
	print(''.join(map(str, a)))
	print(''.join(map(str, b)))


for _ in range(int(input())):
	n = int(input())
	arr = input()
	a = [0] * n
	b = [0] * n
	(a[0], b[0]) = (1, 1)
	flag = False
	for i in range(1, n):
		if not flag:
			if arr[i] == '1':
				(a[i], b[i], flag) = (1, 0, True)
			elif arr[i] == '2':
				(a[i], b[i]) = (1, 1)
			elif arr[i] == '0':
				(a[i], b[i]) = (0, 0)
		else:
			(a[i], b[i]) = (0, arr[i])
	print(*a, sep='')
	print(*b, sep='')


def fun(n, x):
	s = ''
	b = ''
	f = True
	for i in x:
		if i == '2':
			if f:
				s += '1'
				b += '1'
			else:
				s += '0'
				b += '2'
		elif i == '0':
			s += '0'
			b += '0'
		elif f:
			s += '1'
			b += '0'
			f = False
		else:
			s += '0'
			b += '1'
	print(s)
	print(b)
for _ in range(int(input())):
	n = int(input())
	x = input()
	fun(n, x)


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	flg = 0
	a = []
	b = []
	for i in range(n):
		if flg == 0:
			if x[i] == '1':
				flg = 1
				a.append(x[i])
				b.append('0')
			else:
				a.append(str(int(x[i]) // 2))
				b.append(str(int(x[i]) // 2))
		else:
			b.append(x[i])
			a.append('0')
	print(''.join(a))
	print(''.join(b))


for _ in range(int(input())):
	mode = False
	n = int(input())
	num = input()
	(a, b) = ('', '')
	for d in num:
		if not mode:
			if d is '0':
				a += '0'
				b += '0'
			elif d is '1':
				a += '1'
				b += '0'
				mode = True
			elif d is '2':
				a += '1'
				b += '1'
		elif d == '0':
			a += '0'
			b += '0'
		elif d == '1':
			a += '0'
			b += '1'
		elif d == '2':
			a += '0'
			b += '2'
	print(a)
	print(b)


for _ in range(int(input())):
	n = int(input())
	x = input()
	(a, b) = ('1', '1')
	bix = False
	for char in x[1:]:
		if char == '0':
			a += '0'
			b += '0'
		elif char == '1':
			if bix:
				a += '0'
				b += '1'
			else:
				bix = True
				a += '1'
				b += '0'
		elif bix:
			a += '0'
			b += '2'
		else:
			a += '1'
			b += '1'
	print(a, b, sep='\n')


import sys, bisect
from math import gcd
input = sys.stdin.readline

def inp():
	return int(input().rstrip())

def inlt():
	return list(map(int, input().rstrip().split()))

def insr():
	s = input().rstrip()
	return s[:len(s) - 1]

def invr():
	return map(int, input().rstrip().split())
t = inp()
for _ in range(t):
	n = inp()
	nums = [int(i) for i in input().strip()]
	a = [0 for i in range(n)]
	b = [0 for i in range(n)]
	a[0] = 1
	b[0] = 1
	has = False
	for i in range(1, n):
		if nums[i] == 0:
			a[i] = 0
			b[i] = 0
		elif nums[i] == 1:
			a[i] = 1
			b[i] = 0
			cnt = i
			has = True
			break
		else:
			a[i] = 1
			b[i] = 1
	if has:
		if cnt + 1 < n:
			for i in range(cnt + 1, n):
				if nums[i] == 0:
					a[i] = 0
					b[i] = 0
				elif nums[i] == 1:
					a[i] = 0
					b[i] = 1
				else:
					a[i] = 0
					b[i] = 2
	print(''.join((str(i) for i in a)))
	print(''.join((str(i) for i in b)))


t = int(input())
while t:
	t -= 1
	n = int(input())
	c = input().strip()
	cur = True
	a = ['1'] * n
	b = ['1'] * n
	for i in range(1, n):
		if c[i] == '1':
			if cur:
				a[i] = '1'
				b[i] = '0'
				cur = not cur
			else:
				a[i] = '0'
				b[i] = '1'
		elif c[i] == '0':
			a[i] = '0'
			b[i] = '0'
		elif c[i] == '2':
			if cur:
				a[i] = '1'
				b[i] = '1'
			else:
				a[i] = '0'
				b[i] = '2'
	print(''.join(a))
	print(''.join(b))


from sys import stdout, stdin
read = stdin.readline
write = stdout.write
t = int(read())
for _ in range(t):
	n = int(read())
	x = read()
	(a, b) = (['1'], ['1'])
	a_gt_b = False
	for d in x[1:-1]:
		if d == '1':
			if not a_gt_b:
				a_gt_b = True
				a.append('1')
				b.append('0')
			else:
				a.append('0')
				b.append('1')
		elif d == '0':
			a.append('0')
			b.append('0')
		elif not a_gt_b:
			a.append('1')
			b.append('1')
		else:
			a.append('0')
			b.append('2')
	write(''.join(a))
	write('\n')
	write(''.join(b))
	write('\n')


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	a = []
	b = []
	one_met = False
	for x_i in x:
		if x_i == '2':
			if one_met:
				a.append('0')
				b.append('2')
			else:
				a.append('1')
				b.append('1')
		elif x_i == '1':
			if one_met:
				a.append('0')
				b.append('1')
			else:
				a.append('1')
				b.append('0')
				one_met = True
		elif x_i == '0':
			a.append('0')
			b.append('0')
		else:
			assert False
	print(''.join(a))
	print(''.join(b))


t = int(input())
for _ in range(t):
	input()
	xs = input()
	a = []
	b = []
	seen1 = False
	a.append('1')
	b.append('1')
	for x in xs[1:]:
		if seen1:
			a.append('0')
			b.append(x)
		else:
			if x == '0':
				a.append('0')
				b.append('0')
			if x == '1':
				a.append('1')
				b.append('0')
				seen1 = True
			if x == '2':
				a.append('1')
				b.append('1')
	print(''.join(a))
	print(''.join(b))


t = int(input())
for test in range(t):
	n = int(input())
	x = input()
	a = [0] * n
	b = [0] * n
	tek = False
	for i in range(n):
		if x[i] == '2':
			if tek == True:
				a[i] = 0
				b[i] = 2
			else:
				a[i] = 1
				b[i] = 1
		elif x[i] == '1':
			if tek == False:
				a[i] = 1
				b[i] = 0
				tek = True
			else:
				a[i] = 0
				b[i] = 1
		else:
			a[i] = 0
			b[i] = 0
	for i in range(n):
		print(a[i], end='')
	print()
	for i in range(n):
		print(b[i], end='')
	print()


for u in range(int(input())):
	n = int(input())
	s = input()
	(x, y) = ('', '')
	for i in range(n):
		if s[i] == '2':
			x = x + '1'
			y = y + '1'
		elif s[i] == '0':
			x = x + '0'
			y = y + '0'
		elif s[i] == '1':
			x = x + '1'
			y = y + '0'
			break
	z = len(x)
	if z < n:
		x = x + (n - z) * '0'
		y = y + s[z:n]
		print(x)
		print(y)
	else:
		print(x)
		print(y)


for i in range(int(input())):
	size = int(input())
	num1 = ['0' for _ in range(size)]
	num2 = ['0' for _ in range(size)]
	edge = False
	for (j, val) in enumerate(list(input())):
		if val == '2':
			if not edge:
				num1[j] = '1'
				num2[j] = '1'
			else:
				num1[j] = '0'
				num2[j] = '2'
		elif val == '1':
			if not edge:
				num1[j] = '1'
				num2[j] = '0'
			else:
				num1[j] = '0'
				num2[j] = '1'
			edge = True
		else:
			num1[j] = '0'
			num2[j] = '0'
	print(''.join(num1))
	print(''.join(num2))


t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	a = ''
	b = ''
	for j in range(n):
		if x[j] == '0':
			a += '0'
			b += '0'
		if x[j] == '1':
			a += '1' + '0' * (n - j - 1)
			b += '0' + x[j + 1:]
			break
		if x[j] == '2':
			a += '1'
			b += '1'
	print(a, b, sep='\n', end='\n')


for _ in range(int(input())):
	n = int(input())
	s = str(input())
	s1 = '1'
	s2 = '1'
	f = 0
	g = 0
	for i in range(n):
		if s[i] == '1':
			x = i
			g = 1
			break
	for i in range(1, n):
		if g == 0:
			if s[i] == '0':
				s1 += '0'
				s2 += '0'
			else:
				s1 += '1'
				s2 += '1'
		elif i < x:
			if s[i] == '0':
				s1 += '0'
				s2 += '0'
			else:
				s1 += '1'
				s2 += '1'
		elif i == x:
			s1 += '1'
			s2 += '0'
		elif s[i] == '0':
			s1 += '0'
			s2 += '0'
		elif s[i] == '1':
			s1 += '0'
			s2 += '1'
		else:
			s1 += '0'
			s2 += '2'
	print(s1)
	print(s2)


t = int(input())
for i in range(t):
	n = int(input())
	x = [int(j) for j in input()]
	a = [1]
	b = [1]
	l = 0
	try:
		p = x.index(1)
	except:
		p = len(x)
	for j in range(1, len(x)):
		if x[j] == 1:
			if not l:
				a.append(0)
				b.append(1)
				l = 1
			else:
				a.append(1)
				b.append(0)
		elif x[j] == 2:
			if not l or j < p:
				a.append(1)
				b.append(1)
			else:
				a.append(2)
				b.append(0)
		elif x[j] == 0:
			a.append(0)
			b.append(0)
	for k in a:
		print(k, end='')
	print('\t')
	for k in b:
		print(k, end='')
	print('\t')


t = int(input())
for i in range(t):
	n = int(input())
	string_1 = ''
	string_2 = ''
	string_list = list(input())
	bigger = 0
	for j in range(n):
		if string_list[j] == '0':
			string_1 = string_1 + '0'
			string_2 = string_2 + '0'
		elif string_list[j] == '1':
			if bigger == 0:
				string_1 = string_1 + '1'
				string_2 = string_2 + '0'
				bigger = 1
			else:
				string_1 = string_1 + '0'
				string_2 = string_2 + '1'
		elif bigger == 0:
			string_1 = string_1 + '1'
			string_2 = string_2 + '1'
		else:
			string_1 = string_1 + '0'
			string_2 = string_2 + '2'
	print(string_1)
	print(string_2)


def ter(j):
	if len(j) == 1:
		return '1\n1'
	else:
		s1 = '1'
		s2 = '1'
		for k in range(1, len(j)):
			if j[k] == '1':
				if s1 >= s2:
					s2 = s2 + '1'
					s1 = s1 + '0'
				elif s1 < s2:
					s1 = s1 + '1'
					s2 = s2 + '0'
			elif j[k] == '0':
				s2 = s2 + '0'
				s1 = s1 + '0'
			elif s1 > s2:
				s2 = s2 + '2'
				s1 = s1 + '0'
			elif s1 < s2:
				s1 = s1 + '2'
				s2 = s2 + '0'
			else:
				s1 = s1 + '1'
				s2 = s2 + '1'
		return s1 + '\n' + s2
t = int(input())
l = []
for i in range(t):
	n = int(input())
	s = input()
	l.append(s)
for j in l:
	print(ter(j))


cases = int(input())
for i in range(cases):
	length = int(input())
	num = input()
	a = '1'
	b = '1'
	first1 = False
	for y in range(1, length):
		if num[y] == '2':
			if first1:
				b += '2'
				a += '0'
			else:
				a += '1'
				b += '1'
		elif num[y] == '0':
			a += '0'
			b += '0'
		elif first1:
			a += '0'
			b += '1'
		else:
			a += '1'
			b += '0'
			first1 = True
	print(a)
	print(b)


t = int(input())
for i in range(t):
	n = int(input())
	arr = [int(i) for i in input()]
	a = []
	b = []
	flg = 0
	for i in arr:
		if flg == 0:
			if i == 2:
				a.append('1')
				b.append('1')
			elif i == 0:
				a.append('0')
				b.append('0')
			else:
				a.append('1')
				b.append('0')
				flg = 1
		else:
			a.append('0')
			b.append(str(i))
	print(''.join(a))
	print(''.join(b))


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	a = ''
	b = ''
	t = False
	for j in s:
		if j == '0':
			a += '0'
			b += '0'
		elif t == False:
			if j == '1':
				a += '1'
				b += '0'
				t = True
			else:
				a += '1'
				b += '1'
		elif j == '1':
			a += '0'
			b += '1'
		else:
			a += '0'
			b += '2'
	print(a, b, sep='\n')


t = int(input())
for test in range(t):
	n = int(input())
	ter = [int(i) for i in list(input())]
	ans1 = [0 for i in range(n)]
	ans2 = [0 for i in range(n)]
	maxgiven = 0
	for i in range(n):
		if maxgiven == 0:
			if ter[i] == 0:
				(ans1[i], ans2[i]) = (0, 0)
			if ter[i] == 2:
				(ans1[i], ans2[i]) = (1, 1)
			if ter[i] == 1:
				(ans1[i], ans2[i]) = (1, 0)
				maxgiven = 1
		else:
			if ter[i] == 0:
				(ans1[i], ans2[i]) = (0, 0)
			if ter[i] == 2:
				(ans1[i], ans2[i]) = (0, 2)
			if ter[i] == 1:
				(ans1[i], ans2[i]) = (0, 1)
	ans1 = [str(i) for i in ans1]
	ans2 = [str(i) for i in ans2]
	print(int(''.join(ans1)))
	print(int(''.join(ans2)))


t = int(input())
for q in range(t):
	l = int(input())
	num = [int(x) for x in input()]
	a = [1 for x in range(l)]
	b = [1 for x in range(l)]
	flag = False
	for x in range(l):
		if num[x] == 2:
			if flag:
				a[x] = 2
				b[x] = 0
			else:
				a[x] = 1
				b[x] = 1
		elif num[x] == 1:
			if flag:
				a[x] = 1
				b[x] = 0
			else:
				a[x] = 0
				b[x] = 1
				flag = True
		elif num[x] == 0:
			a[x] = 0
			b[x] = 0
	for x in a:
		print(x, end='')
	print()
	for x in b:
		print(x, end='')
	print()


for _ in range(int(input())):
	n = int(input())
	s = input()
	x = []
	y = []
	t = 0
	p = 0
	for i in range(n):
		if s[i] == '2' and t != 1:
			x.append('1')
			y.append('1')
		elif s[i] == '2' and t == 1:
			x.append('0')
			y.append('2')
		elif s[i] == '1' and t == 0:
			x.append('1')
			y.append('0')
			t = 1
		elif s[i] == '1' and t == 1:
			x.append('0')
			y.append('1')
		elif s[i] == '0':
			x.append('0')
			y.append('0')
	for i in x:
		print(i, end='')
	print()
	for i in y:
		print(i, end='')
	print()


def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		c = input()
		(a, b) = ([], [])
		are_equal = True
		for i in c:
			if are_equal:
				if i == '2':
					a.append('1')
					b.append('1')
				elif i == '0':
					a.append('0')
					b.append('0')
				else:
					a.append('1')
					b.append('0')
					are_equal = False
			else:
				a.append('0')
				b.append(i)
		print(''.join(a))
		print(''.join(b))
main()


t = int(input())
while t > 0:
	n = int(input())
	x = input()
	a = '1'
	b = '1'
	i = 1
	while i < n and x[i] != '1':
		a += str(int(x[i]) // 2)
		b += str(int(x[i]) // 2)
		i += 1
	if i != n:
		a += '1'
		b += '0'
		i += 1
		a += '0' * (n - i)
		b += x[i:]
	print(a, '\n', b, sep='')
	t -= 1


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	x = input()
	a = []
	b = []
	maxx = -1
	for i in range(n):
		if x[i] == '0':
			a.append('0')
			b.append('0')
		elif maxx == -1:
			if x[i] == '2':
				a.append('1')
				b.append('1')
			else:
				a.append('1')
				b.append('0')
				maxx = 0
		elif x[i] == '2':
			a.append('0')
			b.append('2')
		else:
			a.append('0')
			b.append('1')
	print(''.join(a))
	print(''.join(b))


for tc in range(int(input())):
	n = int(input())
	a = list(input())
	temp = ['0'] * n
	tem = ['0'] * n
	k = 0
	f = 0
	for i in range(n):
		if a[i] == '2':
			temp[i] = '1'
			tem[i] = '1'
		elif a[i] == '0':
			temp[i] == '0'
			tem[i] = '0'
		else:
			tem[i] = '1'
			temp[i] = '0'
			k = i + 1
			f = 1
			break
	if f:
		for i in range(k, n):
			temp[i] = a[i]
	print(''.join(temp))
	print(''.join(tem))


for tc in range(int(input())):
	n = int(input())
	arr = []
	line = input()
	(a, b) = ([], [])
	flag = 0
	for i in range(n):
		arr.append(int(line[i]))
		if arr[i] == 0:
			a.append(0)
			b.append(0)
		elif arr[i] == 1:
			if flag == 0:
				a.append(1)
				b.append(0)
				flag = 1
			else:
				a.append(0)
				b.append(1)
		elif arr[i] == 2:
			if flag == 0:
				a.append(1)
				b.append(1)
				flag == 1
			else:
				a.append(0)
				b.append(2)
	for i in a:
		print(i, end='')
	print('')
	for i in b:
		print(i, end='')
	print('')


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	num = input()
	a = '1'
	f = None
	for i in range(1, n):
		if num[i] == '2':
			if f == None:
				a += '1'
			elif f == 1:
				a += '2'
				f = 0
			else:
				a += '0'
		elif num[i] == '1':
			if f == None:
				a += '1'
				f = 0
			elif f == 1:
				a += '1'
				f = 0
			else:
				a += '0'
		else:
			a += '0'
	b = ''
	for i in range(n):
		b += str(int(num[i]) - int(a[i]))
	print(a)
	print(b)


t = int(input())
for loop in range(t):
	n = int(input())
	s = input()
	ansA = []
	ansB = []
	tf = False
	for i in s:
		if i == '0':
			ansA.append('0')
			ansB.append('0')
		elif tf:
			ansA.append('0')
			ansB.append(i)
		elif i == '2':
			ansA.append('1')
			ansB.append('1')
		else:
			ansA.append('1')
			ansB.append('0')
			tf = True
	print(''.join(ansA))
	print(''.join(ansB))


num_cases = int(input())
for t in range(num_cases):
	length = int(input())
	x = input()
	a = [0 for i in range(length)]
	b = [0 for i in range(length)]
	found_one = -1
	for i in range(length):
		if found_one == 0:
			a[i] = '0'
			b[i] = x[i]
		elif found_one == 1:
			b[i] = '0'
			a[i] = x[i]
		elif x[i] == '1':
			a[i] = '1'
			b[i] = '0'
			found_one = 0
		elif x[i] == '0':
			a[i] = '0'
			b[i] = '0'
		elif x[i] == '2':
			a[i] = '1'
			b[i] = '1'
	a_int = int(''.join(a))
	b_int = int(''.join(b))
	if a_int > b_int:
		print(a_int)
		print(b_int)
	else:
		print(b_int)
		print(a_int)


def solve():
	l = int(input())
	n = list(map(int, input()))
	p = n.index(1) if 1 in n else l
	fp = [i // 2 for i in n[:p]]
	print(*fp + [1] * (p != l) + ([0] * l)[p + 1:], sep='')
	print(*fp + [0] * (p != l) + n[p + 1:], sep='')
t = int(input())
for i in range(t):
	solve()


from sys import stdin
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	s = stdin.readline().rstrip()
	s1 = '1'
	s2 = '1'
	c = 0
	for i in range(1, n):
		if int(s[i]) == 2 and c == 0:
			s1 = s1 + '1'
			s2 = s2 + '1'
		elif int(s[i]) == 1 and c == 0:
			c = 1
			s1 = s1 + '1'
			s2 = s2 + '0'
			continue
		elif int(s[i]) == 0:
			s1 = s1 + '0'
			s2 = s2 + '0'
		elif c == 1:
			s1 = s1 + '0'
			s2 = s2 + s[i]
	print(s1)
	print(s2)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for case in range(int(input())):
	n = int(input())
	x = input()
	equal_flag = True
	a_greater = False
	b_greater = False
	a_array = []
	b_array = []
	for c in x:
		if equal_flag:
			if c == '0':
				(c1, c2) = [0, 0]
			elif c == '1':
				(c1, c2) = [1, 0]
				a_greater = True
				equal_flag = False
			else:
				(c1, c2) = [1, 1]
		elif c == '0':
			(c1, c2) = [0, 0]
		elif c == '1':
			(c1, c2) = [0, 1]
		else:
			(c1, c2) = [0, 2]
		a_array.append(c1)
		b_array.append(c2)
	for i in range(n):
		print(a_array[i], end='')
	print()
	for i in range(n):
		print(b_array[i], end='')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	a = ['1']
	b = ['1']
	m = 0
	for j in x[1:]:
		if j == '0':
			a.append('0')
			b.append('0')
		elif j == '2' and m == 0:
			a.append('1')
			b.append('1')
		elif j == '1' and m == 0:
			a.append('1')
			b.append('0')
			m = 1
		else:
			a.append('0')
			b.append(j)
	s1 = ''.join(a)
	s2 = ''.join(b)
	print(s1)
	print(s2)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
li = [0]
for i in range(int(100000.0 + 10)):
	li.append(li[-1] + i + 1)
for ti in range(t):
	n = int(input())
	s = input()
	a1 = []
	a0 = []
	adv = -1
	for i in s:
		if i == '2':
			if adv == -1:
				a1.append('1')
				a0.append('1')
			elif adv == 0:
				a0.append('0')
				a1.append('2')
			else:
				a0.append('2')
				a1.append('0')
		elif i == '0':
			a1.append('0')
			a0.append('0')
		elif adv == -1:
			adv = 0
			a0.append('1')
			a1.append('0')
		elif adv == 0:
			a0.append('0')
			a1.append('1')
		else:
			a0.append('1')
			a1.append('0')
	print(*a0, sep='')
	print(*a1, sep='')


t = int(input())
for i in range(t):
	n = int(input())
	b = input()
	x = ''
	y = ''
	m = 0
	for j in b:
		if m == 0:
			if j == '0':
				x += '0'
				y += '0'
			elif j == '2':
				x += '1'
				y += '1'
			elif j == '1':
				m = 1
				x += '0'
				y += '1'
		else:
			x += j
			y += '0'
	print(y)
	print(x)


for i in range(int(input())):
	n = int(input())
	st = input()
	fs = list()
	ss = list()
	ts = list(st)
	flag = True
	for i in range(n):
		if not flag:
			fs.append('0')
			ss.append(ts[i])
			continue
		if ts[i] == '2':
			fs.append('1')
			ss.append('1')
		elif ts[i] == '1':
			fs.append('1')
			ss.append('0')
			flag = False
		else:
			fs.append('0')
			ss.append('0')
	print(''.join(fs))
	print(''.join(ss))


for i in range(int(input())):
	l = int(input())
	num = input()
	ra = ''
	rb = ''
	for n in range(l):
		if num[n] == '2':
			ra += '1'
			rb += '1'
		elif num[n] == '0':
			ra += '0'
			rb += '0'
		else:
			ra += '1' + '0' * (l - n - 1)
			rb += '0' + num[n + 1:]
			break
	print(ra)
	print(rb)


from array import array
test = int(input())
for i in range(0, test):
	length = int(input())
	num = int(input())
	big = []
	small = []
	num = str(num)
	foundBigger = False
	for k in range(0, length):
		dig = int(num[k])
		if dig == 0:
			big.append('0')
			small.append('0')
		elif dig == 1:
			big.append('0')
			small.append('1')
		elif k == 0:
			big.append('1')
			small.append('1')
		elif not foundBigger:
			big.append('1')
			small.append('1')
		else:
			big.append('0')
			small.append('2')
		if not foundBigger and big[k] < small[k]:
			foundBigger = True
			(big[k], small[k]) = (small[k], big[k])
	print(str(array('B', map(ord, big)).tobytes(), 'utf-8'))
	print(str(array('B', map(ord, small)).tobytes(), 'utf-8'))


import sys

def pro(c):
	a = '1'
	b = '1'
	n = len(c)
	flg = 1
	I = -1
	for i in range(1, n):
		if c[i] == '2':
			a += '1'
			b += '1'
		if c[i] == '1' and flg:
			a += '1'
			b += '0'
			I = i
			break
		if c[i] == '0':
			a += '0'
			b += '0'
	if I != -1:
		for i in range(I + 1, n):
			if c[i] == '2':
				a += '0'
				b += '2'
			if c[i] == '0':
				a += '0'
				b += '0'
			if c[i] == '1':
				a += '0'
				b += '1'
	print(a)
	print(b)
t = int(input())
for i in range(t):
	n = int(input())
	a = input()
	pro(a)


t = int(input())
res = ''
for _ in range(t):
	n = int(input())
	x = input()
	a_is_larger = False
	a = ''
	b = ''
	for s in x:
		if s == '0':
			a += '0'
			b += '0'
		elif a_is_larger:
			if s == '1':
				a += '0'
				b += '1'
			else:
				a += '0'
				b += '2'
		elif s == '1':
			a += '1'
			b += '0'
			a_is_larger = True
		else:
			a += '1'
			b += '1'
	res += a + '\n' + b + '\n'
print(res)


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	if '1' in x:
		i = x.index('1')
		first = int(x[:i]) // 2
		mx = str(first) + '1' + '0' * (n - i - 1)
		mn = str(first) + '0' + x[i + 1:]
		print(mx)
		print(mn)
	else:
		res = int(x) // 2
		print(res)
		print(res)


for _ in range(int(input())):
	n = int(input())
	x = input()
	s1 = ''
	s2 = ''
	car = 0
	for i in range(n):
		if x[i] == '2' and car == 0:
			s1 += '1'
			s2 += '1'
		elif x[i] == '1' and car == 0:
			car = 1
			s1 += '1'
			s2 += '0'
		elif x[i] == '0':
			s1 += '0'
			s2 += '0'
		elif x[i] == '2' and car == 1:
			s1 += '0'
			s2 += '2'
		elif x[i] == '1' and car == 1:
			s1 += '0'
			s2 += '1'
	print(s1)
	print(s2)


def main():
	t = int(input())
	while t > 0:
		t = t - 1
		n = int(input())
		x = str(input())
		fun(x, n)

def fun(x, n):
	i = 0
	a = ''
	b = ''
	while i < n:
		if x[i] == '2':
			a = a + '1'
			b = b + '1'
			i = i + 1
		elif x[i] == '0':
			a = a + '0'
			b = b + '0'
			i = i + 1
		else:
			a = a + '1'
			b = b + '0'
			i = i + 1
			while i < n:
				a = a + '0'
				b = b + x[i]
				i = i + 1
	print(int(a))
	print(int(b))
main()


t = int(input())
for l in range(t):
	n = int(input())
	x = input()
	a = [''] * n
	b = [''] * n
	for i in range(n):
		if x[i] == '1':
			a[i] = '1'
			b[i] = '0'
			for j in range(i + 1, n):
				b[j] = x[j]
			break
		else:
			a[i] = str((int(x[i]) - int('0')) // 2)
			b[i] = str((int(x[i]) - int('0')) // 2)
	a = ''.join(a)
	b = ''.join(b)
	if len(a) < n and len(b) < n:
		a = ''.join(a) + '0' * (n - len(a))
		b = ''.join(b) + '0' * (n - len(b))
	elif len(b) < n and len(a) == n:
		a = ''.join(a)
		b = ''.join(b) + '0' * (n - len(b))
	elif len(a) < n and len(b) == n:
		a = ''.join(a) + '0' * (n - len(a))
		b = ''.join(b)
	print(a)
	print(b)


import math
T = int(input())
for _ in range(T):
	N = int(input())
	s = input()
	a = [1 for i in range(N)]
	b = [1 for i in range(N)]
	i = 1
	while i < N:
		if s[i] == '2':
			a[i] = 1
			b[i] = 1
		elif s[i] == '0':
			a[i] = 0
			b[i] = 0
		else:
			a[i] = 1
			b[i] = 0
			j = i + 1
			while j < N:
				a[j] = 0
				b[j] = int(s[j])
				j += 1
			break
		i += 1
	for i in a:
		print(i, end='')
	print()
	for i in b:
		print(i, end='')
	print()


from sys import stdin, stdout

def read():
	x = stdin.readline().rstrip()
	return x

def __main__():
	t = int(read())
	for t0 in range(t):
		n = int(read())
		x = read()
		a = [int(i) for i in x]
		res_min = []
		res_max = []
		fl = True
		fl2 = True
		for a0 in a:
			if a0 == 1:
				fl = False
				if fl2:
					fl2 = False
					res_min.append(0)
					res_max.append(1)
				else:
					res_min.append(1)
					res_max.append(0)
			elif a0 == 0:
				res_min.append(0)
				res_max.append(0)
			elif fl:
				res_min.append(1)
				res_max.append(1)
			else:
				res_max.append(0)
				res_min.append(2)
		r1 = [str(k) for k in res_min]
		r2 = [str(k) for k in res_max]
		out1 = ''.join(r1) + '\n'
		out2 = ''.join(r2) + '\n'
		stdout.write(out1)
		stdout.write(out2)
__main__()


def solve(digits, x):
	greater = []
	smaller = []
	flag = False
	for num in x:
		num = int(num)
		if flag:
			if num == 2:
				greater.append('0')
				smaller.append('2')
			elif num == 1:
				greater.append('0')
				smaller.append('1')
			else:
				greater.append('0')
				smaller.append('0')
		elif num == 2:
			greater.append('1')
			smaller.append('1')
		elif num == 1:
			greater.append('1')
			smaller.append('0')
			flag = True
		else:
			greater.append('0')
			smaller.append('0')
	print(''.join(smaller))
	print(''.join(greater))
cases = int(input())
for i in range(cases):
	digits = input()
	x = input()
	solve(digits, x)


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	n = inputnum()
	x = inputstring()
	a = ['0'] * n
	b = ['0'] * n
	done = False
	for i in range(n):
		if x[i] == '0':
			continue
		elif x[i] == '1':
			if not done:
				a[i] = '1'
				done = True
			else:
				b[i] = '1'
		elif not done:
			a[i] = '1'
			b[i] = '1'
		else:
			b[i] = '2'
	for c in a:
		print(c, end='')
	print()
	for d in b:
		print(d, end='')
	print()


t = int(input())
for i in range(t):
	ca = cb = ''
	flag = 0
	n = int(input())
	c = input()
	for e in c:
		if flag == 0:
			if len(ca) == len(cb) == 0 or e == '2':
				ca += '1'
				cb += '1'
			elif e == '1':
				ca += '0'
				cb += '1'
				flag = 1
			else:
				ca += '0'
				cb += '0'
		elif e == '2':
			ca += '2'
			cb += '0'
		elif e == '1':
			ca += '1'
			cb += '0'
		else:
			ca += '0'
			cb += '0'
	print(ca)
	print(cb)


t = int(input())
for _ in range(t):
	_ = input()
	x = input()
	a = []
	b = []
	first_1 = True
	for c in x:
		if not first_1:
			a.append('0')
			b.append(c)
		elif c == '0':
			a.append('0')
			b.append('0')
		elif c == '1':
			first_1 = False
			a.append('1')
			b.append('0')
		else:
			a.append('1')
			b.append('1')
	print(''.join(a))
	print(''.join(b))


t = int(input())
while t != 0:
	t -= 1
	n = int(input())
	a = input()
	b = ''
	c = ''
	fl = 0
	for i in a:
		if i == '2':
			if fl == 0:
				b = b + '1'
				c = c + '1'
			else:
				b = b + '0'
				c = c + '2'
		if i == '1':
			if fl == 0:
				b = b + '1'
				c = c + '0'
				fl = 1
			else:
				b = b + '0'
				c = c + '1'
		if i == '0':
			b = b + '0'
			c = c + '0'
	print(b)
	print(c)


t = int(input())
for i in range(t):
	s1 = ''
	s2 = ''
	a = int(input())
	s = input()
	ct = 1
	ct2 = 1
	for i in s:
		if i == '0':
			s1 = s1 + '0'
			s2 = s2 + '0'
		elif i == '1':
			if ct == 1:
				s1 = s1 + '1'
				s2 = s2 + '0'
				ct = ct + 1
			else:
				s1 = s1 + '0'
				s2 = s2 + '1'
				ct = ct + 1
		elif i == '2':
			if ct == 1:
				s1 = s1 + '1'
				s2 = s2 + '1'
			else:
				s1 = s1 + '0'
				s2 = s2 + '2'
				ct2 = ct2 + 1
	print(int(s1))
	print(int(s2))


t = int(input())
for i in range(t):
	n = int(input())
	res = input()
	flg_gr = False
	s1 = ['1']
	s2 = ['1']
	for j in range(1, n):
		cur = res[j]
		if cur == '0':
			s1.append('0')
			s2.append('0')
		elif cur == '2':
			if flg_gr:
				s1.append('0')
				s2.append('2')
			else:
				s1.append('1')
				s2.append('1')
		elif cur == '1':
			if flg_gr:
				s1.append('0')
				s2.append('1')
			else:
				s1.append('1')
				s2.append('0')
				flg_gr = True
	print(''.join(s1))
	print(''.join(s2))


t = int(input())
A = []
B = []
for i in range(t):
	n = int(input())
	x = str(input())
	a = '1'
	b = '1'
	e = 0
	for i in range(1, n):
		w = x[i]
		if w == '1':
			if e == 0:
				a += '1'
				e += 1
				b += '0'
			else:
				b += '1'
				a += '0'
		elif w == '2':
			if e == 0:
				a += '1'
				b += '1'
			else:
				b += '2'
				a += '0'
		else:
			a += '0'
			b += '0'
	A.append(a)
	B.append(b)
for i in range(t):
	print(A[i])
	print(B[i])


def go():
	n = int(input())
	x = input()
	a = []
	b = []
	i = 0
	while i < n and x[i] != '1':
		if x[i] == '2':
			a.append('1')
			b.append('1')
		else:
			a.append('0')
			b.append('0')
		i += 1
	if i < n:
		a.append('1')
		b.append('0')
		i += 1
	while i < n:
		a.append('0')
		b.append(x[i])
		i += 1
	return ''.join(a) + '\n' + ''.join(b)
t = int(input())
ans = []
for _ in range(t):
	ans.append(str(go()))
print('\n'.join(ans))


def K3():
	n = int(input())
	ans = []
	for _ in range(n):
		length = int(input())
		ternary = input()
		flag = False
		a = ''
		b = ''
		for i in ternary:
			if i == '2' and flag:
				a += '0'
				b += '2'
			elif i == '1' and flag:
				a += '0'
				b += '1'
			elif i == '2':
				a += '1'
				b += '1'
			elif i == '1':
				a += '1'
				b += '0'
				flag = True
			else:
				a += '0'
				b += '0'
		ans.append([a, b])
	for i in ans:
		print(i[0])
		print(i[1])
K3()


t = int(input())
for i in range(t):
	(n, s, k) = (int(input()), input(), '')
	for i in range(n):
		if s[i] != '1':
			k = k + str(int(s[i]) // 2)
		else:
			break
	if len(k) == n:
		print(k)
		print(k)
	else:
		print(k + '1' + '0' * (n - 1 - len(k)))
		print(k + '0' + s[len(k) + 1:])


t = int(input())
import math
for case in range(t):
	n = int(input())
	s = input()
	a = ''
	b = ''
	already_1 = 0
	for i in range(n):
		if s[i] != '1' and already_1 == 0:
			a = a + str(int(s[i]) // 2)
			b = b + str(int(s[i]) // 2)
		elif s[i] == '1' and already_1 == 0:
			a = a + '1'
			b = b + '0'
			already_1 = 1
		else:
			a = a + '0'
			b = b + str(int(s[i]))
	print(a)
	print(b)


t = int(input())
for _ in range(t):
	n = int(input())
	x = str(input())
	l = []
	for c in x:
		l.append(int(c))
	abig = False
	a = []
	b = []
	for i in l:
		if i == 2:
			if abig:
				a.append('0')
				b.append('2')
			elif not abig:
				a.append('1')
				b.append('1')
		if i == 1:
			if abig:
				a.append('0')
				b.append('1')
			elif not abig:
				a.append('1')
				b.append('0')
				abig = True
		if i == 0:
			a.append('0')
			b.append('0')
	print(''.join(a))
	print(''.join(b))


for _ in range(int(input())):
	n = int(input())
	x = input()
	first = '1'
	second = '1'
	if '1' not in x:
		for i in range(1, n):
			if x[i] == '0':
				first += '0'
				second += '0'
			else:
				first += '1'
				second += '1'
	else:
		y = x.count('1')
		z = y - 1
		for i in range(1, n):
			if x[i] == '0':
				first += '0'
				second += '0'
			elif x[i] == '1' and y > z:
				first += '1'
				second += '0'
				y -= 1
			elif x[i] == '1':
				first += '0'
				second += '1'
			elif x[i] == '2':
				if y > z:
					first += '1'
					second += '1'
				else:
					first += '0'
					second += '2'
	print(first)
	print(second)


import sys
for _ in range(int(sys.stdin.readline())):
	n = int(sys.stdin.readline())
	x = sys.stdin.readline()
	a = '1'
	b = '1'
	switch = False
	for i in range(1, n):
		if switch == False:
			if x[i] == '2':
				a += '1'
				b += '1'
			elif x[i] == '1':
				a += '1'
				b += '0'
				switch = True
			else:
				a += '0'
				b += '0'
		elif x[i] == '2':
			a += '0'
			b += '2'
		elif x[i] == '1':
			a += '0'
			b += '1'
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


t = int(input())
for k in range(t):
	n = int(input())
	x = input()
	(a, b) = ([], [])
	was_zero_one = False
	for (i, d) in enumerate(x):
		if d == '0':
			a.append('0')
			b.append('0')
		elif d == '1':
			if not was_zero_one:
				a.append('1')
				b.append('0')
				was_zero_one = True
			else:
				a.append('0')
				b.append('1')
		elif d == '2':
			if not was_zero_one:
				a.append('1')
				b.append('1')
			else:
				a.append('0')
				b.append('2')
	print(''.join(a))
	print(''.join(b))


def solve(n, l):
	a = []
	b = []
	s = ''.join(map(str, l))
	temp = -1
	for i in range(n):
		if l[i] == 2:
			a.append(1)
			b.append(1)
		elif l[i] == 1:
			a.append(1)
			b.append(0)
			temp = i
			break
		else:
			a.append(0)
			b.append(0)
	if temp != -1 and temp != n - 1:
		c = ''.join(map(str, a))
		d = ''.join(map(str, b))
		c = c + '0' * (n - temp - 1)
		d = d + s[temp + 1:]
	else:
		c = ''.join(map(str, a))
		d = ''.join(map(str, b))
	print(c)
	print(d)
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input()))
	solve(n, l)


import os
import sys
from io import BytesIO, IOBase
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def main():
	try:
		for _ in range(inp()):
			n = inp()
			number = input()
			flag = False
			(a, b) = (['1'], ['1'])
			if n != 1:
				for i in range(1, n):
					value = number[i]
					if value == '1' and (not flag):
						flag = True
						a.append(value)
						b.append('0')
					elif value == '1' and flag:
						b.append(value)
						a.append('0')
					elif value == '0':
						a.append(value)
						b.append(value)
					elif value == '2' and (not flag):
						a.append('1')
						b.append('1')
					elif value == '2' and flag:
						a.append('0')
						b.append('2')
			print(''.join(a))
			print(''.join(b))
	except Exception as e:
		raise e
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	a = ''
	b = ''
	flag = 0
	for ch in x:
		if flag == 0:
			if ch == '2':
				a += '1'
				b += '1'
			elif ch == '0':
				a += '0'
				b += '0'
			elif ch == '1':
				flag = 1
				a += '1'
				b += '0'
		else:
			a += '0'
			b += ch
	print(a)
	print(b)


def solution():
	t = int(input())
	for _ in range(t):
		n = int(input())
		x = input()
		a = '1'
		b = '1'
		biggest = False
		i = 1
		while i < n:
			if x[i] == '1':
				if not biggest:
					a += '1'
					b += '0'
					biggest = True
				else:
					a += '0'
					b += '1'
			elif x[i] == '2':
				if not biggest:
					a += '1'
					b += '1'
				else:
					b += '2'
					a += '0'
			else:
				b += '0'
				a += '0'
			i += 1
		print(a)
		print(b)
solution()


t = int(input())
for ts in range(t):
	l = int(input())
	a = list(input())
	f = ''
	s = ''
	fl = 0
	for ii in range(l):
		i = a[ii]
		if i == '2':
			f += '1'
			s += '1'
		elif i == '0':
			f += '0'
			s += '0'
		else:
			f += '1' + '0' * (l - ii - 1)
			s += '0' + ''.join(a[ii + 1:])
			break
	print(f)
	print(s)


for _ in range(int(input())):
	n = int(input())
	a = list(input())
	a1 = ['' for o in range(n)]
	a2 = ['' for o in range(n)]
	c = False
	for i in range(n):
		if i == 0:
			a1[i] = '1'
			a2[i] = '1'
		elif a[i] == '0':
			a1[i] = '0'
			a2[i] = '0'
		elif a[i] == '1':
			if c:
				a2[i] = '1'
				a1[i] = '0'
			else:
				c = True
				a1[i] = '1'
				a2[i] = '0'
		elif c:
			a2[i] = '2'
			a1[i] = '0'
		else:
			a2[i] = '1'
			a1[i] = '1'
	print(*a1, sep='')
	print(*a2, sep='')


n = int(input())
for i in range(n):
	input()
	s = input()
	split = False
	a = ''
	b = ''
	for (n, i) in enumerate(s):
		if i == '0':
			a += '0'
			b += '0'
		elif i == '2':
			a += '1'
			b += '1'
		else:
			a += '1'
			b += '0'
			break
	a += '0' * (len(s) - 1 - n)
	b += s[n + 1:]
	print(a)
	print(b)


def main():
	n = int(input())
	l = input()
	ln1 = ''
	ln2 = ''
	to_2 = False
	for i in l:
		k = int(i)
		if to_2:
			ln1 += '0'
			ln2 += i
		elif k == 1:
			to_2 = True
			ln1 += '1'
			ln2 += '0'
		elif k == 2:
			ln1 += '1'
			ln2 += '1'
		else:
			ln1 += '0'
			ln2 += '0'
	print(ln1)
	print(ln2)
t = int(input())
for i in range(t):
	main()


res = []
t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	(a, b) = ('', '')
	check = False
	for dig in x:
		if dig == '0':
			a += '0'
			b += '0'
		if dig == '1':
			if not check:
				a += '1'
				b += '0'
				check = True
			else:
				a += '0'
				b += '1'
		if dig == '2':
			if not check:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
	res.append(a)
	res.append(b)
for item in res:
	print(item)


t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	s = input()
	x = '1'
	y = '1'
	for i in range(1, n):
		if x > y:
			x = x + '0'
			y = y + s[i]
		elif s[i] == '0':
			x = x + '0'
			y = y + '0'
		else:
			x = x + '1'
			y = y + str(int(s[i]) - 1)
	print(x)
	print(y)


T = int(input())
for I in range(0, T):
	N = int(input())
	X = input()
	A = '1'
	B = '1'
	R = True
	for I in X[1:]:
		if I == '0':
			A += '0'
			B += '0'
		elif R:
			if I == '1':
				A += '1'
				B += '0'
				R = False
			else:
				A += '1'
				B += '1'
		elif I == '1':
			A += '0'
			B += '1'
			R = False
		else:
			A += '0'
			B += '2'
			R = False
	print(A)
	print(B)


for _ in range(int(input())):
	n = int(input())
	x = input()
	a = ''
	b = ''
	c = 0
	for i in range(n):
		if x[i] == '1' and c == 0:
			a += '1'
			b += '0'
			c += 1
		elif x[i] == '1':
			a += '0'
			b += '1'
		elif x[i] == '2' and c == 0:
			a += '1'
			b += '1'
		elif x[i] == '2':
			a += '0'
			b += '2'
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


for _ in range(int(input())):
	n = int(input())
	(a, b) = (['0'] * n, ['0'] * n)
	a[0] = '1'
	b[0] = '1'
	t = 0
	s = list(input())
	for i in range(1, n):
		if s[i] == '0':
			a[i] == '0'
			b[i] == '0'
		elif s[i] == '1' and t == 0:
			a[i] = '1'
			b[i] = '0'
			t = 1
		elif s[i] == '1' and t == 1:
			a[i] = '0'
			b[i] = '1'
		elif s[i] == '2' and t == 1:
			a[i] = '0'
			b[i] = '2'
		elif s[i] == '2' and t == 0:
			a[i] = '1'
			b[i] = '1'
	print(''.join(a))
	print(''.join(b))


import sys
import os
from io import IOBase, BytesIO
import math
mod = 10 ** 9 + 7
pie = 3.1415926536

def modinv(n, p):
	return pow(n, p - 2, p)

def ncr(n, r, p):
	t = fact[n] * (ifact[r] * ifact[n - r] % p) % p
	return t

def ain():
	return list(map(int, sin().split()))

def sin():
	return input().strip()

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def read2DIntArray(row, col):
	arr = []
	for i in range(0, row):
		temp = list(map(int, sin().split()))
		arr.append(temp)
	return arr

def read2DCharArray(row, col):
	arr = []
	for i in range(0, row):
		temp = str(sin())
		arr.append(temp)
	return arr

def smallestNumber(n):
	lst = list(str(n))
	lst.sort()
	tmp = ''
	for (i, n) in enumerate(lst):
		if n != '0':
			tmp = lst.pop(i)
			break
	return str(tmp) + ''.join(lst)

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = False
	prime[1] = False
	lst = []
	for p in range(n + 1):
		if prime[p]:
			lst.append(p)
	return lst

def nCr(n, r):
	a = 1
	b = 1
	c = 1
	for i in range(1, n + 1):
		c *= i
	for i in range(1, r + 1):
		b *= i
	for i in range(1, n - r + 1):
		a *= i
	return c // (a * b)

def sieveOfEratosthenes1(N, s):
	prime = [False] * (N + 1)
	for i in range(2, N + 1, 2):
		s[i] = 2
	for i in range(3, N + 1, 2):
		if prime[i] == False:
			s[i] = i
			for j in range(i, int(N / i) + 1, 2):
				if prime[i * j] == False:
					prime[i * j] = True
					s[i * j] = i

def generatePrimeFactors(N):
	s = [0] * (N + 1)
	sieveOfEratosthenes1(N, s)
	curr = s[N]
	cnt = 1
	factors = []
	power = []
	while N > 1:
		N //= s[N]
		if curr == s[N]:
			cnt += 1
			continue
		factors.append(curr)
		power.append(cnt)
		curr = s[N]
		cnt = 1
	return (factors, power)

def main():
	for _ in range(int(sin())):
		n = int(sin())
		x = sin()
		res1 = '1'
		res2 = '1'
		flag = 0
		for i in range(1, n):
			d = x[i]
			if d == '0':
				res1 += '0'
				res2 += '0'
			elif d == '1':
				if flag == 0:
					res1 += '1'
					res2 += '0'
					flag = 1
				else:
					res1 += '0'
					res2 += '1'
			elif d == '2':
				if flag == 0:
					res1 += '1'
					res2 += '1'
				else:
					res1 += '0'
					res2 += '2'
		print(res1)
		print(res2)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for i in range(t):
	n = int(input())
	x = str(input())
	a = '1'
	b = '1'
	maxa = False
	for i in range(1, len(x)):
		if x[i] == '2':
			if a == b or not maxa:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
				maxa = True
		elif x[i] == '1':
			if not maxa:
				a += '1'
				b += '0'
				maxa = True
			else:
				a += '0'
				b += '1'
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


t = int(input())
while t:
	n = int(input())
	s = input()
	s1 = ''
	s2 = ''
	c = True
	for i in s[1:]:
		if c == False:
			s1 += '0'
			s2 += i
			continue
		if i == '1' and c:
			s1 += '1'
			s2 += '0'
			c = False
		elif i == '0':
			s1 += '0'
			s2 += '0'
		else:
			s1 += '1'
			s2 += '1'
	s1 = '1' + s1
	s2 = '1' + s2
	print(int(s1))
	print(int(s2))
	t = t - 1


ans = []
t = int(input())
for i in range(t):
	a = ''
	b = ''
	flag = 1
	n = int(input())
	x = int(input())
	x_str = str(x)
	for num in x_str:
		if num == '2':
			if flag == 1:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
		elif num == '0':
			a += '0'
			b += '0'
		elif flag == 1:
			a += '1'
			b += '0'
			flag = 0
		else:
			a += '0'
			b += '1'
	y = int(a)
	z = int(b)
	ans.append(y)
	ans.append(z)
for i in range(2 * t):
	print(ans[i])


import sys
input = sys.stdin.readline
t = int(input())
while t > 0:
	n = int(input())
	s = input()
	a = []
	b = []
	ma = False
	if s[0] == '1':
		a.append('2')
		b.append('2')
	if s[0] == '2':
		a.append('1')
		b.append('1')
	if s[0] == '0':
		a.append('1')
		b.append('2')
	for i in range(1, n):
		if not ma:
			if s[i] == '1':
				a.append('0')
				b.append('1')
				ma = True
			if s[i] == '2':
				a.append('1')
				b.append('1')
			if s[i] == '0':
				a.append('0')
				b.append('0')
		else:
			if s[i] == '1':
				a.append('1')
				b.append('0')
			if s[i] == '2':
				a.append('2')
				b.append('0')
			if s[i] == '0':
				a.append('0')
				b.append('0')
	print(''.join(a))
	print(''.join(b))
	t -= 1


t = int(input())
while t:
	t = t - 1
	n = int(input())
	x = [int(s) for s in input()]
	a = [0] * n
	b = [0] * n
	a[0] = 1
	b[0] = 1
	f_one = n
	for i in range(n):
		if x[i] == 1:
			f_one = i
			a[f_one] = 1
			b[f_one] = 0
			x[f_one] = 0
			break
	for i in range(1, f_one):
		if x[i] == 2:
			a[i] = 1
			b[i] = 1
		else:
			a[i] = 0
			b[i] = 0
	for j in range(f_one):
		x[j] = b[j]
	for i in a:
		print(i, end='')
	print()
	for i in x:
		print(i, end='')
	print()


for _ in range(int(input())):
	n = int(input())
	s = input()
	(a, b) = ('', '')
	i = 0
	while i < n and s[i] != '1':
		if s[i] == '2':
			a += '1'
			b += '1'
		elif s[i] == '0':
			a += '0'
			b += '0'
		i += 1
	if i != n:
		a += '1'
		b += '0'
		for j in range(i + 1, n):
			b += s[j]
			a += '0'
	print(a, b, sep='\n')


def get_min_ternary(str_number):
	half_number = []
	for (idx, str_digit) in enumerate(str_number):
		digit = int(str_digit)
		if digit in [0, 2]:
			half = digit // 2
			half_number.append(half)
			continue
		higher_number = half_number + [1] + [0] * (len(str_number) - idx - 1)
		lower_number = half_number + [0] + list(str_number[idx + 1:])
		return (stringify(higher_number), stringify(lower_number))
	str_half_number = stringify(half_number)
	return (str_half_number, str_half_number)

def stringify(array_number):
	return ''.join(map(str, array_number))
number_of_tests = int(input())
for _ in range(number_of_tests):
	input()
	str_number = input().strip()
	(n1, n2) = get_min_ternary(str_number)
	print(n1)
	print(n2)


def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, list(input())))
		d = {0: ['0', '0'], 1: ['0', '1'], 2: ['1', '1']}
		(x, y) = (['1'], ['1'])
		m = 0
		for i in range(1, n):
			if m == 0:
				if a[i] == 1:
					m = 1
					l = d[a[i]]
					x.append(l[0])
					y.append(l[1])
				else:
					l = d[a[i]]
					x.append(l[0])
					y.append(l[1])
			elif a[i] == 2:
				x.append('2')
				y.append('0')
			elif a[i] == 1:
				x.append('1')
				y.append('0')
			else:
				l = d[a[i]]
				x.append(l[0])
				y.append(l[1])
		print(''.join(x), ''.join(y), sep='\n')
main()


import os
import sys
from io import BytesIO, IOBase

def solution(n, s):
	if n == 1:
		write(1)
		write(1)
		return
	(num1, num2) = ([0] * n, [0] * n)
	(num1[0], num2[0]) = ('1', '1')
	diff = False
	for i in range(1, n):
		if s[i] == '1':
			if not diff:
				(num1[i], num2[i]) = ('1', '0')
				diff = True
			else:
				(num1[i], num2[i]) = ('0', '1')
		elif s[i] == '2':
			if not diff:
				(num1[i], num2[i]) = ('1', '1')
			else:
				(num1[i], num2[i]) = ('0', '2')
		else:
			num1[i] = '0'
			num2[i] = '0'
	write(''.join(num1))
	write(''.join(num2))

def main():
	for _ in range(r_int()):
		n = r_int()
		s = input()
		solution(n, s)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())

def w_array(arr):
	for x in arr:
		write(x, end=' ')
	write()
main()


t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	(mx, mn) = ('', '')
	for i in range(n):
		if x[i] == '1':
			mx += '1' + '0' * (n - i - 1)
			mn += '0' + x[i + 1:]
			break
		mx += str(int(x[i]) // 2)
		mn += str(int(x[i]) // 2)
	print(mx)
	print(mn)


for testcase in range(int(input())):
	input()
	a = []
	b = []
	abigger = False
	for char in input():
		if char == '0':
			a.append('0')
			b.append('0')
		if char == '1':
			if not abigger:
				a.append('1')
				b.append('0')
				abigger = True
			else:
				a.append('0')
				b.append('1')
		if char == '2':
			if abigger:
				a.append('0')
				b.append('2')
			else:
				a.append('1')
				b.append('1')
	print(''.join(a))
	print(''.join(b))


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	a = ['1']
	b = ['1']
	vala = 1
	valb = 1
	flag = 0
	flag2 = 0
	for i in range(1, n):
		if x[i] == '0':
			a.append('0')
			b.append('0')
		if x[i] == '1':
			if flag == 1:
				b.append('1')
				a.append('0')
			else:
				a.append('1')
				flag = 1
				b.append('0')
		if x[i] == '2':
			if flag == 1:
				b.append('2')
				a.append('0')
			else:
				a.append('1')
				b.append('1')
	print(''.join(a))
	print(''.join(b))


k = int(input())
for x in range(k):
	z = int(input())
	p = input()
	a = ''
	b = ''
	lp = False
	for x in range(z):
		if p[x] == '0':
			a += '0'
			b += '0'
		elif p[x] == '1':
			if lp:
				b += '1'
				a += '0'
			else:
				a += '1'
				b += '0'
				lp = True
		elif lp:
			b += '2'
			a += '0'
		else:
			a += '1'
			b += '1'
	print(a)
	print(b)


from collections import Counter as C, defaultdict as D, deque as Q
from operator import itemgetter as I
from itertools import product as P
from bisect import bisect_left as BL, bisect_right as BR
from heapq import heappush as HPUSH, heappop as HPOP
from math import floor as MF, ceil as MC, gcd as MG, factorial as F, sqrt as SQRT, inf as INFINITY, log as LOG
from sys import stdin, stdout
INPUT = stdin.readline
PRINT = stdout.write

def player1():
	print('')

def player2():
	print('')

def isPrime(n):
	for i in range(2, MC(SQRT(n)) + 1):
		if n % i == 0:
			return False
	return True

def factors(x):
	ans = []
	for i in range(1, MC(SQRT(x)) + 1):
		if x % i == 0:
			ans.append(i)
			if x % (x // i) == 0:
				ans.append(x // i)
	return ans

def main():
	for _ in range(int(INPUT())):
		n = int(INPUT())
		x = INPUT()
		a = ['0'] * n
		b = ['0'] * n
		for i in range(n):
			if x[i] == '0':
				a[i] = '0'
				b[i] = '0'
			elif x[i] == '2':
				a[i] = '1'
				b[i] = '1'
			else:
				a[i] = '1'
				b[i] = '0'
				for j in range(i + 1, n):
					b[j] = x[j]
				break
		PRINT(''.join(a) + '\n' + ''.join(b) + '\n')
main()


t = int(input())
while t > 0:
	n = int(input())
	x = input()
	a = []
	b = []
	flag = 0
	for i in x:
		if i == '2':
			if not flag:
				a.append('1')
				b.append('1')
			else:
				a.append('0')
				b.append('2')
		elif i == '0':
			a.append('0')
			b.append('0')
		elif i == '1':
			if not flag:
				a.append('1')
				b.append('0')
				flag = 1
			else:
				a.append('0')
				b.append('1')
	print(''.join(a))
	print(''.join(b))
	t -= 1


for _ in range(int(input())):
	n = int(input())
	x = int(input())
	if '1' not in set(str(x)):
		a = b = x // 2
	else:
		s = str(x)
		k = s.find('1')
		s = s[:k] + '2' + '0' * (n - k - 1)
		a = int(s) // 2
		b = x - a
	print(a)
	print(b)


def asfd(b, a):
	c = ''
	d = ''
	for i in range(a):
		if b[i] == '2':
			c += '1'
			d += '1'
		elif b[i] == '1':
			c += '1'
			d += '0'
		else:
			c += '0'
			d += '0'
	return [c, d]
for aiosd in range(int(input())):
	a = int(input())
	b = input()
	c = ''
	d = ''
	f = 0
	e1 = a
	e2 = a
	e3 = a
	e4 = a
	if '12' in b:
		e3 = b.index('12')
		f = 1
	if '11' in b:
		e1 = b.index('11')
		f = 1
	if '10' in b:
		e2 = b.index('10')
		f = 1
	if f == 0:
		(c, d) = asfd(b, a)
	else:
		e = min(e3, e1, e2, e4)
		(c, d) = asfd(b[:e + 1], e + 1)
		c += (a - e - 1) * '0'
		d += b[e + 1:]
	print(c)
	print(d)


for q in range(int(input())):
	n = int(input())
	s = list(input())
	ans = []
	ans1 = []
	f = 1
	for i in s:
		if f:
			if i == '2':
				ans.append('1')
				ans1.append('1')
			elif i == '1':
				ans.append('1')
				ans1.append('0')
				f = 0
			else:
				ans.append('0')
				ans1.append('0')
		else:
			ans.append('0')
			ans1.append(i)
	ans = ''.join(ans)
	ans1 = ''.join(ans1)
	print(ans)
	print(ans1)


n = int(input())
while n:
	input()
	string = input()
	movestringup = ''
	movestringdown = ''
	check = True
	for element in string:
		if not check:
			movestringup += '0'
			movestringdown += element
		elif element == '2':
			movestringup += '1'
			movestringdown += '1'
		elif element == '1':
			check = False
			movestringup += '1'
			movestringdown += '0'
		elif element == '0':
			movestringup += '0'
			movestringdown += '0'
	n -= 1
	print(movestringup)
	print(movestringdown)


t = int(input())
for v in range(t):
	n = int(input())
	li = list(input())
	str1 = ''
	str2 = ''
	my_ind = -1
	for i in range(n):
		if li[i] == '2':
			str1 = str1 + '1'
			str2 = str2 + '1'
		elif li[i] == '0':
			str1 = str1 + '0'
			str2 = str2 + '0'
		else:
			str1 = str1 + '1'
			str2 = str2 + '0'
			my_ind = i
			break
	if my_ind != -1:
		i = my_ind + 1
		while i < n:
			str1 = str1 + '0'
			str2 = str2 + li[i]
			i += 1
	print(str1)
	print(str2)


import math
L = lambda : list(map(int, input().split()))
M = lambda : map(int, input().split())
I = lambda : int(input())
t = I()
for i in range(t):
	n = I()
	a = input()
	b = [1]
	c = [1]
	f = 0
	for i in a[1:]:
		if i == '0' or (i == '2' and f == 0):
			x = int(i) // 2
			b.append(x)
			c.append(x)
		elif i == '1' and f == 0:
			b.append(1)
			c.append(0)
			f = 1
		else:
			b.append(0)
			c.append(i)
	print(''.join(map(str, b)))
	print(''.join(map(str, c)))


from sys import *
tc = int(stdin.readline())
for tcase in range(tc):
	n = int(stdin.readline())
	s = stdin.readline()
	a = '1'
	b = '1'
	flag = False
	for i in range(1, n):
		if s[i] is '0':
			a += '0'
			b += '0'
		elif s[i] is '1':
			if flag is False:
				a += '1'
				b += '0'
			else:
				a += '0'
				b += '1'
			flag = True
		elif flag is True:
			a += '0'
			b += '2'
		else:
			a += '1'
			b += '1'
	print('{}\n{}'.format(a, b))


t = int(input())
for _ in range(t):
	n = int(input())
	a = ''
	b = ''
	k = list(map(int, list(input())))
	flag = 0
	p = -1
	for i in range(n):
		if flag == 0:
			if k[i] == 2:
				a = a + '1'
				b = b + '1'
				continue
			elif k[i] == 0:
				a = a + '0'
				b = b + '0'
				continue
			else:
				flag = 1
				p = i + 1
				a = a + '1'
				b = b + '0'
				break
	if flag == 1:
		a = a + '0' * (n - p)
		for i in range(p, n):
			if k[i] == 0:
				b = b + '0'
			elif k[i] == 1:
				b = b + '1'
			else:
				b = b + '2'
	a = int(a.strip())
	b = int(b.strip())
	print(a)
	print(b)


def val(i, mark):
	i = int(i)
	if i == 0:
		return ('0', '0')
	if i == 1:
		if mark == 1:
			return ('1', '0')
		return ('0', '1')
	if i == 2:
		if mark == 0:
			return ('1', '1')
		return ('0', '2')
t = int(input())
for _ in range(t):
	n = int(input())
	a = input()
	tmp = int(a[0])
	mark = 0
	mi = ''
	ma = ''
	for i in a:
		if i == '1':
			mark += 1
		q = val(i, mark)
		ma += q[0]
		mi += q[1]
	print(ma)
	print(mi)


for _ in range(int(input())):
	l = int(input())
	x = input()
	num1 = []
	num2 = []
	done = False
	for i in x:
		if not done:
			if i == '2':
				num1.append('1')
				num2.append('1')
			elif i == '0':
				num1.append('0')
				num2.append('0')
			else:
				num1.append('1')
				num2.append('0')
				done = True
		else:
			num1.append('0')
			num2.append(i)
	print(''.join(num1))
	print(''.join(num2))


t = int(input())
for i in range(t):
	n = int(input())
	n1 = int(input())
	l = str(n1)
	a = '1'
	b = '1'
	tick = 0
	for j in range(1, len(l)):
		if l[j] == '2':
			if tick == 0:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
		elif l[j] == '1':
			if tick == 0:
				a += '1'
				b += '0'
				tick = 1
			else:
				b += '1'
				a += '0'
		else:
			a += '0'
			b += '0'
	print(int(a))
	print(int(b))


for i in range(int(input())):
	n = int(input())
	arr = [int(i) for i in input()]
	(a, b) = (['0' for i in range(n)], ['0' for i in range(n)])
	i = 0
	while i < n:
		if arr[i] == 0 or arr[i] == 2:
			a[i] = str(arr[i] // 2)
			b[i] = str(arr[i] // 2)
			i += 1
		else:
			a[i] = '1'
			i += 1
			break
	while i < n:
		b[i] = str(arr[i])
		i += 1
	print(''.join(a))
	print(''.join(b))


t = int(input(''))
while t > 0:
	n = int(input(''))
	s = input()
	s1 = '1'
	s2 = '1'
	c = 0
	for i in range(1, len(s)):
		if c == 0:
			if s[i] == '2':
				s1 += '1'
				s2 += '1'
			elif s[i] == '1':
				s1 += '0'
				s2 += '1'
				c = 1
			else:
				s1 += '0'
				s2 += '0'
		else:
			s1 += s[i]
			s2 += '0'
	print(s2)
	print(s1)
	t = t - 1


import sys
input = sys.stdin.readline
t = int(input())
for ti in range(1, t + 1):
	n = int(input())
	x = input()
	a = b = ''
	a1 = b1 = 0
	for i in range(n):
		if x[i] == '0':
			a += '0'
			b += '0'
		elif x[i] == '1':
			if a1 > b1:
				a += '0'
				b += '1'
				b1 += 1
			else:
				a += '1'
				b += '0'
				a1 = a1 * 3 + 1
		elif a1 == b1:
			a += '1'
			b += '1'
		elif a1 > b1:
			a += '0'
			b += '2'
			b1 += 2
		else:
			a += '2'
			b += '0'
			b1 += 2
		a1 *= 3
		b1 *= 3
	print(a)
	print(b)


t = int(input())
while t != 0:
	n = int(input())
	s = input()
	str1 = ''
	str2 = ''
	count = 0
	for i in range(len(s)):
		count += 1
		if s[i] == '0':
			str1 += '0'
			str2 += '0'
		elif s[i] == '2':
			str1 += '1'
			str2 += '1'
		else:
			str1 += '0'
			str2 += '1'
			break
	for i in range(count, len(s)):
		str1 += s[i]
		str2 += '0'
	print(str1)
	print(str2)
	t -= 1


T = int(input())
for cs in range(T):
	n = int(input())
	x = input()
	a = b = ''
	done = False
	for digit in x:
		if digit == '0':
			a += '0'
			b += '0'
		elif digit == '1':
			if done:
				a += '0'
				b += '1'
			else:
				a += '1'
				b += '0'
				done = True
		elif done:
			a += '0'
			b += '2'
		else:
			a += '1'
			b += '1'
	print(a)
	print(b)


t = int(input())
L = []
for i in range(t):
	n = int(input())
	x = list(input())
	x[0] = ['1', '1']
	a = 0
	for j in range(1, n):
		if a != 0 or x[j] != '1':
			if x[j] == '0':
				x[j] = ['0', '0']
			elif x[j] == '1':
				x[j] = ['0', '1']
			elif a == 0:
				x[j] = ['1', '1']
			else:
				x[j] = ['0', '2']
		else:
			x[j] = ['1', '0']
			a += 1
	L += [x]
for k in L:
	(p, q) = ('', '')
	for m in k:
		p += m[0]
		q += m[1]
	print(int(p))
	print(int(q))


import math
t = int(input())
while t > 0:
	n = int(input())
	l = str(input())
	a = '1'
	b = '1'
	k = 0
	if n > 1:
		for i in range(1, n):
			if l[i] == '0' and (k == 0 or k == 1):
				a = a + '0'
				b = b + '0'
			elif l[i] == '1' and k == 0:
				a = a + '1'
				b = b + '0'
				k = k + 1
			elif l[i] == '1' and k == 1:
				a = a + '0'
				b = b + '1'
			elif l[i] == '2' and k == 0:
				a = a + '1'
				b = b + '1'
			elif l[i] == '2' and k == 1:
				a = a + '0'
				b = b + '2'
		print(a)
		print(b)
	elif n == 1:
		print(a)
		print(b)
	t = t - 1


for _ in range(int(input())):
	lens = int(input())
	arrs = input()
	(a, b) = ([], [])
	done = False
	for i in range(lens):
		curr = arrs[i]
		if done:
			a.append('0')
			b.append(curr)
		else:
			if curr == '0':
				a.append('0')
				b.append('0')
			if curr == '1':
				a.append('1')
				b.append('0')
				done = True
			if curr == '2':
				a.append('1')
				b.append('1')
	print(''.join(map(str, a)))
	print(''.join(map(str, b)))


s = int(input())
for i in range(0, s):
	t = input()
	k = input()
	f = ''
	a = '1'
	b = '1'
	flag = 0
	for j in k[1:]:
		if j == '1' and flag == 0:
			a = a + '1'
			b = b + '0'
			flag = 1
		elif j == '2' and flag == 0:
			a = a + '1'
			b = b + '1'
		else:
			a = a + '0'
			b = b + j
	print(a)
	print(b)


def xor(n, x):
	maxstring = ''
	minstring = ''
	for i in x:
		if maxstring == minstring:
			if i == '0':
				maxstring += '0'
				minstring += '0'
				continue
			elif i == '1':
				maxstring += '1'
				minstring += '0'
				continue
			else:
				maxstring += '1'
				minstring += '1'
				continue
		elif i == '0':
			maxstring += '0'
			minstring += '0'
			continue
		elif i == '1':
			maxstring += '0'
			minstring += '1'
			continue
		else:
			maxstring += '0'
			minstring += '2'
			continue
	print(maxstring)
	print(minstring)
t = int(input())
array = []
for j in range(t):
	n = int(input())
	x = input()
	array.append([n, x])
for a in array:
	xor(*a)


t = int(input())
for _ in range(t):
	n = int(input())
	x = str(input())
	a = ''
	b = ''
	i = 0
	while i < n and x[i] != '1':
		if x[i] == '2':
			a += '1'
			b += '1'
		else:
			a += '0'
			b += '0'
		i += 1
	if i != n:
		a += '1' + '0' * (n - i - 1)
		b += '0' + x[i + 1:]
	print(a)
	print(b)


from math import sqrt, ceil
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	s1 = ''
	s2 = ''
	i = 0
	flg = 0
	while i < n:
		if s[i] == '2':
			s1 += '1'
			s2 += '1'
		elif s[i] == '0':
			s1 += '0'
			s2 += '0'
		else:
			s1 += '1'
			s2 += '0'
			flg = 1
			break
		i += 1
	if flg:
		s1 += '0' * (n - i - 1)
		s2 += s[i + 1:]
	print(s1)
	print(s2)


t = int(input())
for i in range(t):
	cl = int(input())
	c = input()
	l = int(c.find('1', 0, cl))
	if l != -1:
		a = str(int(c[:l]) // 2) + '0' + c[l + 1:]
		b = str(int(c[:l]) // 2) + '1' + (cl - l - 1) * '0'
		print(a)
		print(b)
	else:
		a = int(c) // 2
		print(a)
		print(a)


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		x = input()
		(v, u) = ('1', '1')
		for i in range(1, n):
			k = int(x[i])
			if k == 1:
				v += '0'
				u += '1'
				v += x[i + 1:]
				u += '0' * (n - i - 1)
				break
			elif k == 2:
				v += '1'
				u += '1'
			else:
				v += '0'
				u += '0'
		print(v)
		print(u)
main()


def listToString(s):
	str1 = ''
	return str1.join(s)
t = int(input())
for i in range(t):
	n = int(input())
	s = str(input())
	a = ['1']
	b = ['1']
	m = 0
	for i in range(1, n):
		if s[i] == '1':
			if m == 1:
				a.append('1')
				b.append('0')
			elif m == 2:
				b.append('1')
				a.append('0')
			else:
				a.append('1')
				b.append('0')
				m = 2
		elif s[i] == '2':
			if m == 0:
				a.append('1')
				b.append('1')
			elif m == 1:
				a.append('2')
				b.append('0')
			else:
				a.append('0')
				b.append('2')
		else:
			a.append('0')
			b.append('0')
	print(listToString(a))
	print(listToString(b))


def solve(num):
	result = ['', '']
	different = False
	for digit in num:
		if digit == '2':
			result[0] += '0' if different else '1'
			result[1] += '2' if different else '1'
		elif digit == '1':
			result[0] += '0' if different else '1'
			result[1] += '1' if different else '0'
			different = True
		else:
			result[0] += '0'
			result[1] += '0'
	return result
for i in range(int(input())):
	n = int(input())
	num = input()
	result = solve(num)
	print(result[0])
	print(result[1])


x = int(input())
digits = []
for i in range(x):
	length = int(input())
	number = str(input())
	a = []
	b = []
	t = 1
	for i in number:
		if t:
			if int(i) == 2:
				a.append('1')
				b.append('1')
			elif int(i) == 0:
				a.append('0')
				b.append('0')
			else:
				a.append(i)
				b.append('0')
				t = 0
		else:
			a.append('0')
			b.append(i)
	digits.append(''.join(a))
	digits.append(''.join(b))
for i in digits:
	print(i)


t = int(input())
for g in range(0, t):
	n = int(input())
	num = input()
	n1 = [1]
	n2 = [1]
	y = n
	for j in range(1, n):
		if num[j] == '1':
			y = j
			break
	for i in range(1, n):
		if num[i] == '0':
			n1.append(0)
			n2.append(0)
		elif num[i] == '2':
			if i > y:
				n1.append(0)
				n2.append(2)
			else:
				n1.append(1)
				n2.append(1)
		elif num[i] == '1':
			if i == y:
				n1.append(1)
				n2.append(0)
			else:
				n1.append(0)
				n2.append(1)
	for k in range(0, n):
		print(n1[k], end='')
	print('')
	for k in range(0, n):
		print(n2[k], end='')
	print('')


def f():
	T = int(input())
	while T != 0:
		T = T - 1
		N = int(input())
		X = str(input())
		x1 = ''
		x2 = ''
		flag = False
		for i in range(0, len(X)):
			if X[i] == '2' and flag == False:
				x1 = x1 + '1'
				x2 = x2 + '1'
			elif X[i] == '1' and flag == False:
				x1 = x1 + '1'
				x2 = x2 + '0'
				flag = True
			else:
				x1 = x1 + '0'
				x2 = x2 + X[i]
		print(x1)
		print(x2)
f()


for i in range(int(input())):
	t = int(input())
	s = int(input())
	k = str(s)
	kk = ''
	a = 0
	for j in range(len(k)):
		if k[j] == '0':
			kk = kk + '0'
		elif k[j] == '2':
			if '1' in k[:j + 1]:
				kk = kk + '0'
			else:
				kk = kk + '1'
		elif a == 1:
			kk = kk + '0'
		else:
			a = 1
			kk = kk + '1'
	c = int(kk)
	d = s - c
	print(c)
	print(d)


num = '012'
for i in range(int(input())):
	n = int(input())
	x = [num.index(i) for i in input()]
	if n == 1:
		print(['0\n0', '1\n0', '1\n1'][x[0]])
		continue
	(a, b, eq) = ([0] * n, [0] * n, 1)
	if x[0] == 0:
		(a[0], b[0], eq) = (2, 1, 0)
	elif x[0] == 1:
		a[0] = b[0] = 2
	else:
		a[0] = b[0] = 1
	for i in range(1, n):
		if x[i] == 0:
			a[i] = b[i] = 0
		elif x[i] == 1:
			if eq == 1:
				(a[i], b[i], eq) = (1, 0, 0)
			else:
				(a[i], b[i]) = (0, 1)
		elif eq == 1:
			a[i] = b[i] = 1
		else:
			(a[i], b[i]) = (0, 2)
	print(''.join([num[i] for i in a]))
	print(''.join([num[i] for i in b]))


for i in range(int(input())):
	n = int(input())
	a = input()
	d = []
	e = []
	p = 0
	z = 0
	for i in a:
		if i == '0':
			if z == 1:
				d.append('0')
				e.append('0')
			else:
				e.append('1')
				d.append('1')
		elif i == '1':
			if p == 1 and z == 1:
				d.append('0')
				e.append('1')
			elif z == 1:
				d.append('1')
				e.append('0')
				p = 1
			else:
				d.append('2')
				e.append('2')
		elif i == '2':
			if p == 1:
				d.append('0')
				e.append('2')
			else:
				d.append('1')
				e.append('1')
		z = 1
	print(''.join(d))
	print(''.join(e))


n = int(input())
for i in range(n):
	lena = int(input())
	s = input()
	a = b = '1'
	counter = 0
	for j in range(1, lena):
		if counter == 1:
			if s[j] == '2':
				a += '0'
				b += '2'
			if s[j] == '1':
				a += '0'
				b += '1'
		if counter == 0:
			if s[j] == '2':
				a += '1'
				b += '1'
			if s[j] == '1':
				counter = 1
				a += '1'
				b += '0'
		if s[j] == '0':
			a += '0'
			b += '0'
	print(a)
	print(b)


for i in range(int(input())):
	n = int(input())
	s = str(input())
	s1 = ''
	s2 = ''
	c = 0
	for j in s:
		if j == '0':
			s1 += '0'
			s2 += '0'
			c = c + 1
		elif j == '2':
			s1 += '1'
			s2 += '1'
			c = c + 1
		else:
			c = c + 1
			s1 += '1' + '0' * (n - c)
			s2 += '0' + s[c:]
			break
	print(s1)
	print(s2)


from sys import stdin, gettrace
if not gettrace():

	def input():
		return next(stdin)[:-1]

def main():

	def solve():
		input()
		xx = input()
		a = []
		b = []
		hit_one = False
		for x in xx:
			if x == '2':
				if hit_one:
					a.append('0')
					b.append('2')
				else:
					a.append('1')
					b.append('1')
			elif x == '1':
				if hit_one:
					a.append('0')
					b.append('1')
				else:
					a.append('1')
					b.append('0')
					hit_one = True
			else:
				a.append('0')
				b.append('0')
		print(''.join(a))
		print(''.join(b))
	q = int(input())
	for _ in range(q):
		solve()
main()


n = input()
p = []
for i in range(0, 2 * int(n)):
	l = input()
	if i % 2 != 0:
		p.append(l)
for i in range(0, len(p)):
	n1 = 0
	n2 = 0
	s = p[i]
	idx = s.find('1')
	if idx == -1:
		print(s.replace('2', '1'))
		print(s.replace('2', '1'))
	else:
		x = s[0:idx].replace('2', '1')
		n1 = x + '1' + '0' * (len(s) - idx - 1)
		n2 = x + '0' + s[idx + 1:len(s)]
		print(n1)
		print(n2)


for _ in range(int(input())):
	n = int(input())
	s = input()
	k = len(s)
	l1 = []
	l2 = []
	f = 0
	for i in range(k):
		if s[i] == '2' and f == 0:
			l1.append(1)
			l2.append(1)
		elif s[i] == '2' and f == 1:
			l1.append(0)
			l2.append(2)
		elif s[i] == '1' and f == 0:
			l1.append(1)
			l2.append(0)
			f = 1
		elif s[i] == '1' and f == 1:
			l1.append(0)
			l2.append(1)
		elif s[i] == '0':
			l1.append(0)
			l2.append(0)
	for i in l1:
		print(i, end='')
	print(end='\n')
	for i in l2:
		print(i, end='')
	print(end='\n')


t = int(input())
for i in range(t):
	n = int(input())
	s = input() + '9'
	t1 = ''
	t2 = ''
	i = 0
	while s[i] == '2' and i < n:
		t1 += '1'
		t2 += '1'
		i += 1
	if i == n:
		print(t1)
		print(t2)
	else:
		c = 0
		while i < n:
			if c == 0:
				if s[i] == '0':
					t1 += '0'
					t2 += '0'
				if s[i] == '1':
					t1 += '1'
					t2 += '0'
					c += 1
				if s[i] == '2':
					t1 += '1'
					t2 += '1'
				i += 1
			else:
				if s[i] == '0':
					t1 += '0'
					t2 += '0'
				if s[i] == '1':
					t1 += '0'
					t2 += '1'
				if s[i] == '2':
					t1 += '0'
					t2 += '2'
				i += 1
		print(t1)
		print(t2)


t = int(input())
answer = []
while t > 0:
	n = int(input())
	x = list(input())
	a = ['0'] * n
	b = ['0'] * n
	for i in range(n):
		if x[i] == '1':
			a[i] = '1'
			b[i] = '0'
			for j in range(i + 1, n):
				b[j] = str(x[j])
			break
		elif x[i] == '0':
			a[i] = '0'
			b[i] = '0'
		elif x[i] == '2':
			a[i] = '1'
			b[i] = '1'
	answer.append(''.join(a))
	answer.append(''.join(b))
	t -= 1
print('\n'.join(answer))


def solve():
	n = int(input())
	x = int(input())
	(a, b) = ('1', '1')
	biga = None
	for i in str(x)[1:]:
		if i == '2':
			if biga is None:
				a += '1'
				b += '1'
			elif biga:
				a += '0'
				b += '2'
			elif not biga:
				b += '2'
				a += '0'
		elif i == '1':
			if biga is None:
				biga = True
				a += '1'
				b += '0'
			else:
				a += '0'
				b += '1'
		elif i == '0':
			a += '0'
			b += '0'
	print(a)
	print(b)

def main():
	t = int(input())
	for _ in range(t):
		solve()
main()


T = int(input())
for _ in range(T):
	number = int(input())
	s = input()
	bigger = ''
	smaller = ''
	start_smaller = False
	for i in range(number):
		if s[i] == '2':
			bigger += '0' if start_smaller else '1'
			smaller += '2' if start_smaller else '1'
		elif s[i] == '1':
			bigger += '0' if start_smaller else '1'
			smaller += '1' if start_smaller else '0'
			start_smaller = True
		else:
			bigger += '0'
			smaller += '0'
	print(bigger)
	print(smaller)


for _ in range(int(input())):
	n = int(input())
	lis = list(input())
	an1 = []
	an2 = []
	k = 0
	for i in range(n):
		if k == 1:
			an2.append(lis[i])
			an1.append('0')
		elif lis[i] == '2':
			an1.append('1')
			an2.append('1')
		elif lis[i] == '1':
			an1.append('1')
			an2.append('0')
			k = 1
		elif lis[i] == '0':
			an1.append('0')
			an2.append('0')
	print(''.join(an1))
	print(''.join(an2))


lenN = int(input())
for j in range(lenN):
	str1 = ''
	str2 = ''
	n = int(input())
	wasone = False
	for i in input():
		if not wasone:
			if i == '2':
				str1 += '1'
				str2 += '1'
			elif i == '0':
				str1 += '0'
				str2 += '0'
			else:
				wasone = True
				str1 += '1'
				str2 += '0'
		else:
			str1 += '0'
			str2 += i
	print(str1)
	print(str2)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	l = ['0' for x in range(n)]
	p = ['0' for x in range(n)]
	l[0] = p[0] = '1'
	for i in range(1, n):
		if s[i] == '1':
			l[i] = '1'
			for j in range(i + 1, n):
				p[j] = s[j]
			break
		l[i] = p[i] = str(int(int(s[i]) / 2))
	print(''.join(l))
	print(''.join(p))


cases = int(input())
while cases > 0:
	n = int(input())
	line = input()
	uno = []
	dos = []
	first = False
	for i in range(0, len(line)):
		if line[i] == '1':
			if first == True:
				uno.append(0)
				dos.append(1)
			else:
				uno.append(1)
				dos.append(0)
				first = True
		elif first == True:
			uno.append(0)
			dos.append(int(line[i]))
		else:
			uno.append(int(line[i]) // 2)
			dos.append(int(line[i]) // 2)
	for i in range(0, len(uno)):
		print(uno[i], end='')
	print()
	for i in range(0, len(uno)):
		print(dos[i], end='')
	print()
	cases -= 1


from sys import stdin

def main():
	inp = stdin.readline
	for _ in range(int(inp())):
		n = int(inp())
		d = inp().strip()
		(a, b) = ([], [])
		f = True
		for i in range(n):
			if d[i] == '2' and f:
				a.append('1')
				b.append('1')
			elif d[i] == '1' and f:
				a.append('1')
				b.append('0')
				f = False
			elif d[i] == '0' and f:
				a.append('0')
				b.append('0')
			else:
				a.append('0')
				b.append(d[i])
		print(''.join(a))
		print(''.join(b))
main()


from sys import stdin
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin

def ii():
	return int(stdin.readline())

def fi():
	return float(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def lsi():
	x = list(stdin.readline())
	x.pop()
	return x

def si():
	return stdin.readline()
res = ['YES', 'NO']
for _ in range(ii()):
	f = 0
	n = ii()
	x = []
	y = []
	a = lsi()
	for i in a:
		if i == '2':
			if f:
				x.append(0)
				y.append(2)
			else:
				x.append(1)
				y.append(1)
		elif i == '0':
			x.append(0)
			y.append(0)
		elif f:
			x.append(0)
			y.append(1)
		else:
			x.append(1)
			y.append(0)
			f = 1
	print(*x, sep='')
	print(*y, sep='')


t = int(input())
a = ['0' for i in range(50004)]
b = ['0' for i in range(50004)]
x = ['0' for i in range(50004)]
for i in range(t):
	n = int(input())
	x = input()
	f = 0
	for j in range(n):
		if x[j] == '0':
			a[j] = b[j] = '0'
		elif x[j] == '2':
			if f == 0:
				a[j] = b[j] = '1'
			else:
				a[j] = '0'
				b[j] = '2'
		elif f > 0:
			a[j] = '0'
			b[j] = '1'
		else:
			a[j] = '1'
			b[j] = '0'
			f = 1
		a[n] = b[n] = '\x00'
	print(''.join(a[0:n]))
	print(''.join(b[0:n]))


t = int(input())
for i in range(0, t):
	n = int(input())
	s = input()
	s1 = ''
	s2 = ''
	s1 += '1'
	s2 += '1'
	f1 = 0
	for j in range(1, n):
		if s[j] == '1' and f1 == 0:
			s1 += '0'
			s2 += '1'
			f1 = 1
		elif s[j] == '1' and f1 == 1:
			s1 += '1'
			s2 += '0'
		elif s[j] == '0':
			s1 += '0'
			s2 += '0'
		elif s[j] == '2' and f1 == 0:
			s1 += '1'
			s2 += '1'
		else:
			s1 += '2'
			s2 += '0'
	print(s1)
	print(s2)


for h in range(int(input())):
	n = int(input())
	num = input()
	flag = False
	n1 = []
	n2 = []
	for i in range(n):
		if flag:
			n1.append('0')
			n2.append(num[i])
		elif num[i] == '2':
			n1.append('1')
			n2.append('1')
		elif num[i] == '1':
			n1.append('1')
			n2.append('0')
		else:
			n1.append('0')
			n2.append('0')
		if num[i] == '1':
			flag = True
	print(''.join(n1))
	print(''.join(n2))


INT_MAX = 10 ** 18 + 7

def INPUT():
	return list((int(i) for i in input().split()))

def LIST_1D_ARRAY(n):
	return [0 for _ in range(n)]

def LIST_2D_ARRAY(m, n):
	return [[0 for _ in range(n)] for _ in range(m)]
from random import randint
for _ in range(int(input())):
	n = int(input())
	X = input()
	ans1 = ''
	ans2 = ''
	count = 0
	bool = True
	for i in range(n):
		if X[i] == '2':
			if i == 0:
				ans1 += '1'
				ans2 += '1'
			elif bool is True:
				ans1 += '1'
				ans2 += '1'
			else:
				ans1 += '0'
				ans2 += '2'
				bool = False
		elif X[i] == '0':
			ans1 += '0'
			ans2 += '0'
		elif bool is True:
			ans1 += '1'
			ans2 += '0'
			bool = False
		else:
			ans1 += '0'
			ans2 += '1'
	print(ans1)
	print(ans2)


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	a = ''
	b = ''
	same = True
	for i in range(n):
		if same and x[i] == '2':
			a += '1'
			b += '1'
		elif x[i] == '2':
			a += '0'
			b += '2'
		elif same and x[i] == '1':
			a += '1'
			b += '0'
			same = False
		elif x[i] == '1':
			a += '0'
			b += '1'
		elif x[i] == '0':
			a += '0'
			b += '0'
	print(a)
	print(b)


t = int(input())
while t:
	t -= 1
	n = int(input())
	x = input()
	a = ''
	b = ''
	flag = True
	for i in x:
		if i == '0':
			a += '0'
			b += '0'
		if i == '1':
			if flag:
				a += '1'
				b += '0'
				flag = False
			else:
				a += '0'
				b += '1'
		if i == '2':
			if flag:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
	print(a, b, sep='\n')


for _ in range(int(input())):
	t = int(input())
	lis = list(map(int, input().strip()))
	a = []
	b = []
	f = 1
	for i in lis:
		if i == 0:
			a.append(0)
			b.append(0)
		elif i == 2:
			if f:
				a.append(1)
				b.append(1)
			else:
				a.append(0)
				b.append(2)
		else:
			if f:
				a.append(1)
				b.append(0)
			else:
				a.append(0)
				b.append(1)
			f = 0
	print(''.join(map(str, a)))
	print(''.join(map(str, b)))


for _ in range(int(input())):
	n = int(input())
	s = list(str(input()))
	(a, b) = (['0' for i in range(n)], ['0' for i in range(n)])
	a[0] = '1'
	b[0] = '1'
	for i in range(1, n):
		if s[i] == '2':
			a[i] = '1'
			b[i] = '1'
		elif s[i] == '1':
			a[i] = '1'
			b[i] = '0'
			if i != n - 1:
				b[i + 1:] = s[i + 1:]
				break
	print(''.join(a))
	print(''.join(b))


n = int(input())
m = []
for i in range(n):
	z = int(input())
	s = str(input())
	(q, r) = ([], [])
	t = True
	for i in s:
		if t:
			if int(i) == 2:
				q.append('1')
				r.append('1')
			elif int(i) == 0:
				q.append('0')
				r.append('0')
			else:
				q.append(i)
				r.append('0')
				t = False
		else:
			r.append(i)
			q.append('0')
	m.append(''.join(q))
	m.append(''.join(r))
for i in m:
	print(i)


def find(N, K):
	a = b = ''
	for i in range(N):
		if K[i] == '2':
			a += '1'
			b += '1'
		if K[i] == '0':
			a += '0'
			b += '0'
		if K[i] == '1':
			a += '1' + '0' * (N - i - 1)
			b += '0' + K[i + 1:]
			break
	print(a + '\n' + b)

def main():
	for _ in range(int(input())):
		N = int(input())
		K = input()
		find(N, K)
main()


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[1]

def sort2(l):
	return sorted(l, key=getKey, reverse=True)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(n - r))

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def main():
	for _ in range(ii()):
		n = ii()
		s = si()
		a = [0] * n
		b = [0] * n
		ma = 0
		mb = 0
		for i in range(n):
			if ma == mb:
				if s[i] == '2':
					a[i] = 1
					b[i] = 1
				elif s[i] == '1':
					a[i] = 1
					b[i] = 0
					ma = 1
					mb = 0
				else:
					a[i] = 0
					b[i] = 0
			elif ma > mb:
				if s[i] == '2':
					a[i] = 0
					b[i] = 2
				elif s[i] == '1':
					a[i] = 0
					b[i] = 1
				else:
					a[i] = 0
					b[i] = 0
		for i in range(n):
			print(a[i], end='')
		print()
		for i in range(n):
			print(b[i], end='')
		print()
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


aarr = '011'
barr = '001'

def solve(i, n, x):
	a = ''
	b = ''
	different = False
	for c in x:
		nc = int(c)
		if not different:
			a += aarr[nc]
			b += barr[nc]
			if nc == 1:
				different = True
		else:
			a += '0'
			b += c
	print(a)
	print(b)
t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	solve(i + 1, n, x)


t = int(input())
for i in range(0, t):
	a = ''
	b = ''
	n = int(input())
	x = list(input())
	z = 1
	for k in range(0, n):
		if x[k] == '0':
			a = a + '0'
			b = b + '0'
		elif x[k] == '1':
			a = a + '1'
			b = b + '0'
			break
		else:
			a = a + '1'
			b = b + '1'
		z = z + 1
	if z == n:
		print(a)
		print(b)
	else:
		for m in range(z, n):
			a = a + '0'
			b = b + x[m]
		print(a)
		print(b)


t = int(input())
while t:
	t -= 1
	n = int(input())
	k = input()
	a = ''
	b = ''
	min = a
	f = False
	for i in str(k):
		if i == '0':
			a += '0'
			b += '0'
		elif i == '1' and (not f):
			a += '1'
			b += '0'
			f = True
		elif i == '1' and f:
			a += '0'
			b += '1'
		elif i == '2' and f:
			a += '0'
			b += '2'
		elif i == '2' and (not f):
			a += '1'
			b += '1'
	print(int(a))
	print(int(b))


import sys
input = sys.stdin.readline
for ti in range(int(input().strip())):
	n = int(input().strip())
	x = input().strip()
	ans1 = []
	ans2 = []
	(a1, b1) = (0, 0)
	if x[0] == '1':
		ans1.append('1')
		ans2.append('0')
		a1 += 1
	elif x[0] == '2':
		ans1.append('1')
		ans2.append('1')
	else:
		ans1.append('0')
		ans2.append('0')
	for xi in x[1:]:
		if xi == '0':
			ans1.append('0')
			ans2.append('0')
		elif xi == '1':
			if a1 < b1:
				ans1.append('1')
				ans2.append('0')
				(a1, b1) = (0, 1)
			elif a1 > b1:
				ans1.append('0')
				ans2.append('1')
				(a1, b1) = (1, 0)
			else:
				ans1.append('1')
				ans2.append('0')
				(a1, b1) = (1, 0)
		elif a1 < b1:
			ans1.append('2')
			ans2.append('0')
			(a1, b1) = (0, 1)
		elif a1 > b1:
			ans1.append('0')
			ans2.append('2')
			(a1, b1) = (1, 0)
		else:
			ans1.append('1')
			ans2.append('1')
	ans1 = ''.join(ans1)
	ans2 = ''.join(ans2)
	print(ans1)
	print(ans2)


for _ in range(int(input())):
	input()
	x = input()
	a = b = ''
	flag = False
	for digit in x:
		if digit == '0':
			a += '0'
			b += '0'
		elif digit == '1':
			if flag:
				a += '0'
				b += '1'
			else:
				a += '1'
				b += '0'
				flag = True
		elif digit == '2':
			if flag:
				a += '0'
				b += '2'
			else:
				a += '1'
				b += '1'
	print(a)
	print(b)


for _ in range(int(input())):
	n = int(input())
	x = input()
	a = ''
	b = ''
	ok = True
	for i in range(len(x)):
		if x[i] == '2':
			if ok:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
		elif x[i] == '1':
			if ok:
				a += '1'
				b += '0'
				ok = False
			else:
				a += '0'
				b += '1'
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


import sys
readLine = lambda : sys.stdin.readline()
readInt = lambda : int(sys.stdin.readline())
readInts = lambda : [int(x) for x in sys.stdin.readline().split(' ')]

def main():
	t = readInt()
	for _ in range(t):
		n = readInt()
		x = readLine()
		x = [int(y) for y in x.rstrip()]
		x.pop(0)
		a = [1]
		b = [1]
		imbalanced = False
		for digit in x:
			if digit == 0:
				a.append(0)
				b.append(0)
			elif digit == 1:
				if imbalanced:
					a.append(0)
					b.append(1)
				else:
					a.append(1)
					b.append(0)
					imbalanced = True
			elif digit == 2:
				if imbalanced:
					a.append(0)
					b.append(2)
				else:
					a.append(1)
					b.append(1)
			else:
				print('INVALID DIGIT', digit)
		print(''.join((str(z) for z in a)))
		print(''.join((str(z) for z in b)))
main()


t = int(input())
while t > 0:
	n = int(input())
	x = input()
	transfer = False
	a = ''
	b = ''
	for i in range(n):
		if x[i] == '1' and (not transfer):
			a += '1'
			b += '0'
			transfer = True
		elif x[i] == '0' and (not transfer):
			a += '0'
			b += '0'
		elif x[i] == '2' and (not transfer):
			a += '1'
			b += '1'
		elif x[i] == '1' and transfer:
			a += '0'
			b += '1'
		elif x[i] == '0' and transfer:
			a += '0'
			b += '0'
		elif x[i] == '2' and transfer:
			a += '0'
			b += '2'
	print(a)
	print(b)
	t -= 1


import sys
input = sys.stdin.readline
t1 = int(input())
for t in range(t1):
	n = int(input())
	y = int(input())
	x = str(y)
	a = ''
	b = ''
	flag = False
	for i in range(n):
		if x[i] == '2':
			if flag == False:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
		elif x[i] == '1':
			if flag == False:
				a += '1'
				b += '0'
				flag = True
			else:
				a += '0'
				b += '1'
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	max = '1'
	min = '1'
	c = 0
	j = n
	for i in range(1, n):
		if s[i] == '0':
			max += '0'
			min += '0'
		elif s[i] == '2':
			max += '1'
			min += '1'
		elif s[i] == '1':
			max += '1'
			min += '0'
			j = i
			break
	for i in range(j + 1, n):
		max += '0'
		if s[i] == '0':
			min += '0'
		elif s[i] == '2':
			min += '2'
		elif s[i] == '1':
			min += '1'
	print(max)
	print(min)


t = int(input(''))
arr = []
for i in range(t):
	int(input(''))
	arr.append(input(''))
for i in arr:
	a = ''
	b = ''
	for j in range(len(i)):
		if i[j] == '0':
			a += '0'
			b += '0'
		elif i[j] == '1':
			if a >= b:
				a += '0'
				b += '1'
			else:
				b += '0'
				a += '1'
		elif a >= b:
			a += '1'
			b += '1'
		else:
			b += '0'
			a += '2'
	print(b)
	print(a)


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(input())
	x = ['1']
	y = ['1']
	c = True
	for q in range(1, len(s)):
		if s[q] == '0':
			x.append('0')
			y.append('0')
		if s[q] == '1' and c:
			x.append('1')
			y.append('0')
			c = False
		elif s[q] == '1' and (not c):
			x.append('0')
			y.append('1')
		if s[q] == '2' and (not c):
			x.append('0')
			y.append('2')
		if s[q] == '2' and c:
			x.append('1')
			y.append('1')
	print(''.join(x))
	print(''.join(y))


t = int(input())
for _ in range(t):
	n = int(input())
	digits = list((int(c) for c in input()))
	a = []
	b = []
	which_big = None
	for i in range(n):
		if digits[i] == 0:
			a.append(0)
			b.append(0)
		elif digits[i] == 1:
			if which_big is True:
				a.append(0)
				b.append(1)
			elif which_big is False:
				a.append(1)
				b.append(0)
			else:
				a.append(1)
				b.append(0)
				which_big = True
		elif digits[i] == 2:
			if which_big is True:
				a.append(0)
				b.append(2)
			elif which_big is False:
				a.append(2)
				b.append(0)
			else:
				a.append(1)
				b.append(1)
		else:
			raise ValueError
	print(''.join((str(c) for c in a)))
	print(''.join((str(c) for c in b)))


import random
import string
import sys
from collections import Counter
input = sys.stdin.readline

def main():
	for _ in range(int(input())):
		n = int(input())
		x = input().strip()
		r1 = r2 = ''
		is_exists = False
		for num in x:
			if is_exists:
				if num == '2':
					r1 += '0'
					r2 += '2'
				elif num == '1':
					r1 += '0'
					r2 += '1'
				else:
					r1 += '0'
					r2 += '0'
			elif num == '2':
				r1 += '1'
				r2 += '1'
			elif num == '1':
				r1 += '1'
				r2 += '0'
				is_exists = True
			else:
				r1 += '0'
				r2 += '0'
		print(r1)
		print(r2)
main()


import sys
input = lambda : sys.stdin.readline().strip()
ipnut = input

def main(t=1):
	for i in range(t):
		n = int(input())
		a = []
		b = []
		s = list(map(int, input()))
		f = False
		for i in s:
			if i == 0:
				a.append(0)
				b.append(0)
			elif i == 1 and (not f):
				a.append(1)
				b.append(0)
				f = True
			elif i == 1:
				a.append(0)
				b.append(1)
			elif f:
				a.append(0)
				b.append(2)
			else:
				a.append(1)
				b.append(1)
		print(''.join(map(str, a)))
		print(''.join(map(str, b)))
main(int(input()))


def main():
	T = int(input())
	for _ in range(T):
		n = int(input())
		x = input()
		a = ''
		b = ''
		for (i, p) in enumerate(x):
			p = int(p)
			if i == 0:
				if p == 1:
					a += '2'
					b += '2'
				elif p == 2:
					a += '1'
					b += '1'
			elif p == 1 and a <= b:
				a += '1'
				b += '0'
			elif p == 1 and a > b:
				a += '0'
				b += '1'
			elif p == 2 and a == b:
				a += '1'
				b += '1'
			elif p == 2:
				if a > b:
					a += '0'
					b += '2'
				else:
					a += '2'
					b += '0'
			else:
				a += '0'
				b += '0'
		print(a)
		print(b)
main()


master = []
for i in range(int(input())):
	input()
	l = [int(i) for i in input().strip()]
	a = ''
	b = ''
	k = 0
	for i in l:
		if i is 2:
			if k is 0:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += str(i)
		elif i is 0:
			a += '0'
			b += '0'
		elif k is 0:
			a += '1'
			b += '0'
			k += 1
		else:
			a += '0'
			b += str(i)
	master.append([a, b])
for i in master:
	print(i[0])
	print(i[1])


from sys import stdin
import math

def inp():
	return stdin.readline().strip()
t = int(inp())
for _ in range(t):
	n = int(inp())
	x = [int(x) for x in str(inp())]
	a = []
	b = []
	check = False
	for i in range(n):
		if check:
			a.append(0)
			b.append(x[i])
		if not check:
			if x[i] == 1:
				check = True
			a.append(math.ceil(x[i] / 2))
			if x[i] != 0:
				x[i] -= 1
			b.append(x[i])
	print(''.join(map(str, a)))
	print(''.join(map(str, b)))


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def case():
	n = I()
	s = input().strip()
	a = [0] * n
	b = [0] * n
	f = 1
	for i in range(n):
		if int(s[i]) % 2 == 0 and f:
			a[i] = int(s[i]) // 2
			b[i] = int(s[i]) // 2
		elif f and int(s[i]) % 2 != 0:
			a[i] = int(s[i]) // 2 + 1
			b[i] = int(s[i]) // 2
			f = 0
		else:
			a[i] = 0
			b[i] = s[i]
	print(''.join(map(str, a)))
	print(''.join(map(str, b)))
for _ in range(int(input())):
	case()


n = int(input())
for i in range(n):
	m = int(input())
	c = input()
	(a, b) = ('', '')
	for i in range(m):
		if c[i] == '0':
			a += '0'
			b += '0'
		elif c[i] == '2':
			a += '1'
			b += '1'
		else:
			a += '1'
			b += '0'
			a += (m - i - 1) * '0'
			b += c[i + 1:]
			break
	print(a)
	print(b)


import sys
import heapq

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def rinput():
	return map(int, input().split())

def rlinput():
	return list(map(int, input()))

def main():
	n = int(input())
	(q, w) = ([], [])
	s = rlinput()
	fl = False
	for i in s:
		if i == 0:
			q.append(0)
			w.append(0)
		elif i == 1 and (not fl):
			q.append(1)
			w.append(0)
			fl = True
		elif i == 1:
			q.append(0)
			w.append(1)
		elif fl:
			q.append(0)
			w.append(2)
		else:
			q.append(1)
			w.append(1)
	print(''.join(map(str, q)) + '\n' + ''.join(map(str, w)))
for i in range(iinput()):
	main()


size = input()
data = []
for i in range(0, int(size)):
	strLength = input()
	strReal = input()
	data.append([strLength, strReal])
for i in range(0, len(data)):
	lenReal = int(data[i][0])
	str = data[i][1]
	dict = {0: [('0', '0'), ('0', '0')], 1: [('0', '1'), ('0', '1')], 2: [('1', '1'), ('0', '2')], 3: [('1', '2'), ('0', '3')]}
	a = '1'
	b = '1'
	greatestFound = False
	strIndex = 1
	while greatestFound == False and strIndex < lenReal:
		if greatestFound == False:
			a = a + dict[int(str[strIndex])][0][1]
			b = b + dict[int(str[strIndex])][0][0]
			strIndex = strIndex + 1
		if int(a[-1]) > int(b[-1]):
			greatestFound = True
	for i in range(strIndex, len(str)):
		a = a + dict[int(str[i])][1][0]
		b = b + dict[int(str[i])][1][1]
	print(a)
	print(b)


for t in range(int(input())):
	if t != 0:
		print()
	n = int(input())
	c = [int(x) for x in input()]
	(a, b) = ([1], [1])
	f1 = 0
	for i in range(1, n):
		if c[i] == 0:
			a.append(0)
			b.append(0)
		elif c[i] == 1:
			if f1 == 0:
				a.append(1)
				b.append(0)
				f1 = 1
			else:
				a.append(0)
				b.append(1)
		elif c[i] == 2:
			if f1 == 0:
				if a[i - 1] == b[i - 1]:
					a.append(1)
					b.append(1)
				else:
					a.append(2)
					b.append(0)
					f1 = 1
			else:
				a.append(0)
				b.append(2)
	for x in a:
		print(x, end='')
	print()
	for x in b:
		print(x, end='')


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	x = input().strip()
	a = ''
	b = ''
	for i in x:
		if i == '2':
			a = a + '1'
			b = b + '1'
		elif i == '0':
			a = a + '0'
			b = b + '0'
		else:
			m = len(a)
			a = a + '1' + '0' * (n - m - 1)
			b = b + '0' + x[m + 1:]
			break
	print(a)
	print(b)


for _ in range(int(input())):
	n = int(input())
	a = str(int(input()))
	if n == 1:
		print(1)
		print(1)
	elif n == 2:
		print(int(a) // 2)
		print((int(a) + 1) // 2)
	else:
		a = list(map(int, a))
		i = 0
		b = []
		c = []
		while i < n:
			if a[i] == 2:
				b.append(1)
				c.append(1)
			elif a[i] == 1:
				b.append(0)
				c.append(1)
				for j in range(i + 1, n):
					if a[j] == 2:
						b.append(2)
						c.append(0)
					elif a[j] == 1:
						b.append(1)
						c.append(0)
					else:
						b.append(0)
						c.append(0)
				break
			else:
				b.append(0)
				c.append(0)
			i += 1
		print(''.join(list(map(str, b))))
		print(''.join(list(map(str, c))))


import math
t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	w = ''
	x = ''
	i = 0
	while i < n and (s[i] == '2' or s[i] == '0'):
		if s[i] == '2':
			w += '1'
			x += '1'
		else:
			w += '0'
			x += '0'
		i += 1
	if i == len(s):
		print(w)
		print(x)
	else:
		w += '1'
		x += '0'
		for j in range(n - i - 1):
			w += '0'
			x += s[j + i + 1]
		print(w)
		print(x)


t = int(input())

def solve(n, num):
	st1 = ''
	st2 = ''
	a = b = 0
	for (i, ch) in enumerate(num):
		if i == 0:
			st1 += '1'
			st2 += '1'
		else:
			ch = int(ch)
			if ch == 2:
				if a == b:
					st1 += '1'
					st2 += '1'
				elif a > b:
					st1 += '0'
					st2 += '2'
				else:
					st1 += '2'
					st2 += '0'
			elif ch == 1:
				if a == b:
					st1 += '1'
					st2 += '0'
					a = 1
				elif a < b:
					st1 += '1'
					st2 += '0'
				else:
					st1 += '0'
					st2 += '1'
			elif ch == 0:
				st1 += '0'
				st2 += '0'
	return (st1, st2)
for _ in range(t):
	n = int(input())
	num = input()
	(num1, num2) = solve(n, num)
	print(num1)
	print(num2)


def sol(num):
	flag = False
	size = len(num)
	fst = [0] * size
	scnd = [0] * size
	for i in range(0, size):
		if not flag:
			if num[i] == '1':
				flag = True
				scnd[i] = '1'
				fst[i] = '0'
			if num[i] == '0':
				scnd[i] = '0'
				fst[i] = '0'
			if num[i] == '2':
				scnd[i] = '1'
				fst[i] = '1'
		else:
			if num[i] == '1':
				scnd[i] = '0'
				fst[i] = '1'
			if num[i] == '0':
				scnd[i] = '0'
				fst[i] = '0'
			if num[i] == '2':
				scnd[i] = '0'
				fst[i] = '2'
	print(''.join(fst))
	print(''.join(scnd))

def main():
	n = int(input())
	for i in range(0, n):
		k = int(input())
		num = input()
		sol(num)
main()


def find(c, bigger):
	if bigger == 'chert':
		if c == '0':
			return ('0', '0')
		elif c == '1':
			return ('0', '1')
		return ('1', '1')
	else:
		if c == '0':
			return ('0', '0')
		elif c == '1':
			return ('0', '1')
		return ('0', '2')
t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	a = ''
	b = ''
	bigger = 'chert'
	for i in x:
		(f, s) = find(i, bigger)
		if bigger == 'chert':
			a += f
			b += s
			if int(f) > int(s):
				bigger = 'a'
			elif int(s) > int(f):
				bigger = 'b'
		elif bigger == 'a':
			a += str(min(int(s), int(f)))
			b += str(max(int(s), int(f)))
		else:
			b += str(min(int(s), int(f)))
			a += str(max(int(s), int(f)))
	print(a)
	print(b)


n = int(input())
for i in range(0, n):
	k = int(input())
	j = input()
	s1 = '1'
	s2 = '1'
	maior = False
	for i in range(1, k):
		if maior == False:
			if j[i] == '1':
				maior = True
				s1 += '1'
				s2 += '0'
			else:
				s1 += str(int(j[i]) // 2)
				s2 += str(int(j[i]) // 2)
		else:
			s1 += '0'
			s2 += j[i]
	print(s1)
	print(s2)


import sys
import math

def ii():
	return sys.stdin.readline().strip()

def idata():
	return [int(x) for x in ii().split()]

def binary_search(array, x):
	(left, right) = (-1, len(array))
	while left + 1 != right:
		middle = (left + right) // 2
		if array[middle] >= x:
			right = middle
		elif array[middle] < x:
			left = middle
	return right

def solve_of_problem():
	(n, s) = (int(ii()), ii())
	(a, b) = ('', '')
	for i in range(n):
		if s[i] == '2':
			a += '1'
			b += '1'
		elif s[i] == '1':
			a += '1' + '0' * (n - i - 1)
			b += '0' + s[i + 1:]
			break
		else:
			a += '0'
			b += '0'
	print(a, b, sep='\n')
	return
for ______ in range(int(ii())):
	solve_of_problem()


t = int(input())
for i in range(t):
	n = int(input())
	(a, b) = ([1], [1])
	x = [int(i) for i in list(input())]
	j = 1
	while j < n and x[j] != 1:
		if x[j] == 0:
			a.append(0)
			b.append(0)
		else:
			a.append(1)
			b.append(1)
		j += 1
	if j < n:
		a.append(1)
		b.append(0)
		j += 1
		while j < n:
			if x[j] == 0:
				a.append(0)
				b.append(0)
			elif x[j] == 2:
				a.append(0)
				b.append(2)
			else:
				a.append(0)
				b.append(1)
			j += 1
	print(*a, sep='')
	print(*b, sep='')


from sys import stdin, stdout
t = int(stdin.readline())
for query in range(t):
	n = int(stdin.readline())
	x = list(str(stdin.readline()))
	a = []
	b = []
	higher = 0
	for char in range(n):
		x[char] = int(x[char])
	for char in x:
		if char == 0:
			a.append(0)
			b.append(0)
		if char == 1:
			if higher == 1:
				a.append(0)
				b.append(1)
			if higher == 0:
				a.append(1)
				b.append(0)
				higher = 1
		if char == 2:
			if higher == 0:
				a.append(1)
				b.append(1)
			if higher == 1:
				a.append(0)
				b.append(2)
	if query == 0:
		stdout.write('\n')
	for char in a:
		stdout.write(str(char))
	stdout.write('\n')
	for char in b:
		stdout.write(str(char))
	stdout.write('\n')


import sys
input = sys.stdin.readline
t = int(input())
for testcase in range(t):
	n = int(input())
	x = list(input())
	a = []
	b = []
	flag = False
	for i in range(n):
		if flag:
			a.append('0')
			b.append(x[i])
		elif x[i] == '1':
			a.append('1')
			b.append('0')
			flag = True
		elif x[i] == '0':
			a.append('0')
			b.append('0')
		else:
			a.append('1')
			b.append('1')
	print(''.join(a))
	print(''.join(b))


import os
import sys
from io import BytesIO, IOBase
from bisect import bisect_left, bisect_right
import threading
arr = []

def main():
	for _ in range(int(input())):
		n = int(input())
		s = input()
		an1 = [-1] * (n + 1)
		an2 = [-1] * (n + 1)
		ind = 0
		while ind < n and s[ind] != '1':
			an1[ind] = int(s[ind]) // 2
			an2[ind] = int(s[ind]) // 2
			ind += 1
		an1[ind] = 1
		an2[ind] = 0
		ind += 1
		for i in range(ind, n):
			an2[i] = int(s[i])
			an1[i] = 0
		print(''.join([str(i) for i in an1[:n]]))
		print(''.join([str(i) for i in an2[:n]]))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _testcases_ in range(int(input())):
	n = int(input())
	s = input()
	a = ''
	b = ''
	boo = False
	for i in range(n):
		if s[i] == '2':
			if boo:
				a += '0'
				b += '2'
			else:
				a += '1'
				b += '1'
		elif s[i] == '0':
			a += '0'
			b += '0'
		elif boo:
			b += '1'
			a += '0'
		else:
			boo = True
			a += '1'
			b += '0'
	print(a)
	print(b)


q = int(input())
for _ in range(q):
	n = int(input())
	t = input()
	a = ''
	b = ''
	ifeqal1 = 0
	for i in t:
		if i == '2':
			if ifeqal1 == 0:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
		if i == '0':
			a += '0'
			b += '0'
		if i == '1':
			if ifeqal1 == 0:
				a += '1'
				b += '0'
				ifeqal1 = 1
			else:
				a += '0'
				b += '1'
	print(int(a))
	print(int(b))


rightmost = {'2': ('1', '1'), '1': ('2', '2'), '0': ('1', '2')}
others = {'2': ('2', '0'), '1': ('1', '0'), '0': ('0', '0')}

def solve(n, x):
	(larger_num, smaller_num) = (['1'], ['1'])
	same_start = True
	for i in range(1, n):
		cur_digit = x[i]
		if same_start and cur_digit == '2':
			larger_num.append('1')
			smaller_num.append('1')
		elif same_start:
			digits = others[cur_digit]
			larger_num.append(max(digits))
			smaller_num.append(min(digits))
			if digits[0] != digits[1]:
				same_start = False
		else:
			digits = others[cur_digit]
			larger_num.append(min(digits))
			smaller_num.append(max(digits))
	return (''.join(smaller_num), ''.join(larger_num))
t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	(small, large) = solve(n, x)
	print(small)
	print(large)


t = int(input())
while t > 0:
	n = int(input())
	l = input()
	c = list(l)
	a = ['1']
	b = ['1']
	flag = 0
	for x in range(1, len(c)):
		if c[x] == '0':
			a.append('0')
			b.append('0')
		if flag == 0:
			if c[x] == '1':
				a.append('1')
				b.append('0')
				flag = 1
			if c[x] == '2':
				a.append('1')
				b.append('1')
		else:
			if c[x] == '1':
				a.append('0')
				b.append('1')
			if c[x] == '2':
				a.append('0')
				b.append('2')
	s1 = ''
	s2 = ''
	for x in a:
		s1 += x
	for x in b:
		s2 += x
	print(s1)
	print(s2)
	t -= 1


import sys
import os
from io import BytesIO, IOBase
from collections import Counter, deque
import math

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def ddd():
	return collections.defaultdict(collections.defaultdict(int))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(ii()):
	n = ii()
	s = input()
	(res1, res2) = ('1', '1')
	f = 0
	for i in range(1, n):
		if s[i] == '1':
			if f == 0:
				res1 += '1'
				res2 += '0'
				f = 1
			else:
				res1 += '0'
				res2 += '1'
		if s[i] == '2':
			if f == 0:
				res1 += '1'
				res2 += '1'
			else:
				res1 += '0'
				res2 += '2'
		if s[i] == '0':
			res1 += '0'
			res2 += '0'
	print(res1)
	print(res2)


for i in range(int(input())):
	n = int(input())
	s = input()
	a = '1'
	b = '1'
	great = False
	for q in range(1, n):
		if s[q] == '0':
			a += '0'
			b += '0'
		elif s[q] == '2':
			if great == False:
				a += '1'
				b += '1'
			else:
				a += '2'
				b += '0'
		elif great == False:
			a += '0'
			b += '1'
			great = True
		else:
			a += '1'
			b += '0'
	print(a)
	print(b)


t = int(input())
for j in range(t):
	n = int(input())
	s = input()
	p = list(s)
	alt = 1
	a = []
	b = []
	for i in range(n):
		if p[i] == '2':
			if alt:
				a.append('1')
				b.append('1')
			else:
				a.append('0')
				b.append('2')
		elif p[i] == '1':
			if alt:
				a.append('1')
				b.append('0')
				alt = 0
			else:
				a.append('0')
				b.append('1')
		else:
			a.append('0')
			b.append('0')
	for i in range(n):
		print(a[i], end='')
	print()
	for i in range(n):
		print(b[i], end='')
	print()


tests = int(input())
for i in range(tests):
	n = int(input())
	x = input()
	a = ''
	b = ''
	ones = False
	for d in x:
		if not ones:
			if d == '0':
				a += '0'
				b += '0'
			elif d == '2':
				a += '1'
				b += '1'
			else:
				a += '1'
				b += '0'
				ones = True
		else:
			a += '0'
			b += d
	print(a)
	print(b)


T = int(input())
for t in range(T):
	n = int(input())
	x = list(input())
	a = []
	b = []
	j = 0
	for i in x:
		i = int(i)
		if i % 2 == 0:
			a.append(str(i // 2))
			b.append(str(i // 2))
			j += 1
		else:
			a.append('1')
			b.append('0')
			break
	a.extend(['0'] * (n - j - 1))
	b.extend(x[j + 1:])
	print(''.join(a))
	print(''.join(b))


from sys import stdin, stdout
input = stdin.readline

def a():
	t = int(input())
	for _ in range(t):
		(a, b) = map(int, input().split())
		if a % b == 0:
			print(0)
		else:
			print(str(b - a % b))

def b():
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		bpos1 = 0
		bpos2 = 0
		for i in range(2, n + 1):
			asdf = i * (i - 1) // 2
			if asdf >= k:
				bpos1 = i
				bpos2 = bpos1 - (asdf - k) - 1
				break
		string = ['a'] * n
		string[n - bpos1] = 'b'
		string[n - bpos2] = 'b'
		print(''.join(string))

def c():
	t = int(input())
	for _ in range(t):
		n = int(input())
		x = [int(i) for i in input().rstrip()]
		a = [0] * n
		b = [0] * n
		ind = 0
		for i in x:
			if i == 0:
				a[ind] = 0
				b[ind] = 0
			elif i == 1:
				a[ind] = 1
				b[ind] = 0
				break
			else:
				a[ind] = 1
				b[ind] = 1
			ind += 1
		for i in range(ind + 1, n):
			b[i] = x[i]
		for i in a:
			stdout.write(str(i))
		stdout.write('\n')
		for i in b:
			stdout.write(str(i))
		stdout.write('\n')
c()


import os
import sys
from io import BytesIO, IOBase
from math import *
readn = lambda : int(input())
readl = lambda : list(map(int, input().split()))
reads = lambda : input()
readns = lambda : map(int, input().split())

def main():
	for _ in range(readn()):
		n = readn()
		s = reads()
		ans1 = ['1']
		ans2 = ['1']
		nx = False
		for x in s[1:]:
			if x == '0':
				ans1.append('0')
				ans2.append('0')
			elif x == '1':
				if nx:
					ans1.append('0')
					ans2.append('1')
				else:
					ans1.append('1')
					ans2.append('0')
				nx = True
			elif x == '2':
				if nx:
					ans1.append('0')
					ans2.append('2')
				else:
					ans1.append('1')
					ans2.append('1')
		print(''.join(ans1))
		print(''.join(ans2))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from sys import stdin, stdout
Pi = lambda x: stdout.write(str(x) + '\n')
S = lambda x: x * (x + 1) // 2
I = lambda x: 1 + 2 * x
R = lambda : stdin.readline()
Ri = lambda x: map(int, x.split())
Rs = lambda x: map(str, x.split())
Rf = lambda x: map(float, x.split())

def main():
	t = int(R())
	for x in range(t):
		m = int(R())
		s = R().strip('\n')
		(A, B) = ([], [])
		for i in range(m):
			n = int(s[i])
			if n % 2 == 0:
				A.append(str(n // 2))
				B.append(str(n // 2))
			else:
				A.append('1')
				B.append('0')
				while len(A) < m:
					A.append('0')
				for j in range(i + 1, m):
					B.append(s[j])
				break
		print(''.join(A))
		print(''.join(B))
main()


from sys import stdin
input = stdin.readline
import bisect
import math
for xoxo in range(1):
	for _ in range(int(input())):
		n = int(input())
		k = input()
		n2 = ''
		n1 = ''
		p = 0
		while k[p] != '1':
			if k[p] == '0':
				n1 += '0'
				n2 += '0'
			else:
				n1 += '1'
				n2 += '1'
			p += 1
			if p == n:
				break
		if p <= n - 1:
			if k[p] == '1':
				n1 += '1'
				n2 += '0'
		for i in range(p + 1, n):
			if k[i] == '1':
				n1 += '0'
				n2 += '1'
			elif k[i] == '0':
				n1 += '0'
				n2 += '0'
			else:
				n1 += '0'
				n2 += '2'
		print(n1)
		print(n2)


t = int(input())
for i in range(t):
	n = int(input())
	k = list(input())
	a = ['1'] * n
	b = ['1'] * n
	lead = 0
	for j in range(1, n):
		if k[j] == '0':
			a[j] = '0'
			b[j] = '0'
		elif k[j] == '1':
			if lead == 0:
				a[j] = '1'
				b[j] = '0'
				lead = 1
			else:
				a[j] = '0'
				b[j] = '1'
		elif lead == 0:
			a[j] = '1'
			b[j] = '1'
		else:
			a[j] = '0'
			b[j] = '2'
	print(''.join(a))
	print(''.join(b))


n = int(input())
for i in range(n):
	m = int(input())
	s = input()
	(a, b) = ('', '')
	same = True
	for j in range(m):
		if s[j] == '2':
			if same:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
		elif s[j] == '1':
			if same:
				a += '1'
				b += '0'
				same = False
			else:
				a += '0'
				b += '1'
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


import sys

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	(n, x) = (int(input()), list(input()))
	(ans1, ans2) = ([], [])
	count = 0
	for i in range(n):
		if not count:
			if x[i] == '2':
				ans1.append('1')
				ans2.append('1')
			elif x[i] == '0':
				ans1.append('0')
				ans2.append('0')
			else:
				ans1.append('0')
				ans2.append('1')
				count += 1
		elif x[i] == '2':
			ans1.append('2')
			ans2.append('0')
		elif x[i] == '0':
			ans1.append('0')
			ans2.append('0')
		else:
			ans1.append('1')
			ans2.append('0')
	print(''.join(ans1))
	print(''.join(ans2))


from bisect import *
t = int(input())

def solve(n, x):
	(r1, r2) = ([], [])
	found1 = False
	for (i, c) in enumerate(x):
		if c == '1' and (not found1):
			found1 = True
			r1.append('1')
			r2.append('0')
		elif c == '2' and (not found1):
			r1.append('1')
			r2.append('1')
		else:
			r1.append('0')
			r2.append(c)
	return ''.join(r1) + '\n' + ''.join(r2)
for test in range(1, t + 1):
	n = int(input())
	x = input()
	print(solve(n, x))


t = int(input())
for i in range(t):
	n = int(input())
	k = input()
	(perv, vtor) = ('', '')
	maxc = 0
	for i in k:
		if i == '0':
			perv += '0'
			vtor += '0'
		elif i == '2' and maxc == 0:
			perv += '1'
			vtor += '1'
		elif i == '2':
			perv += '2'
			vtor += '0'
		elif maxc == 0:
			perv += '0'
			vtor += '1'
			maxc = 1
		else:
			perv += '1'
			vtor += '0'
	print(perv)
	print(vtor)


count = int(input())
while count > 0:
	inp_count = int(input())
	inp = int(input())
	lst_1 = ['1']
	lst_2 = ['1']
	str_inp = str(inp)
	for e in str_inp[1:]:
		if e == '2':
			lst_1.append('1')
			lst_2.append('1')
		elif e == '0':
			lst_1.append('0')
			lst_2.append('0')
		elif e == '1':
			lst_1.append('1')
			lst_2.append('0')
			break
	for e in str_inp[len(lst_1):]:
		lst_1.append('0')
		lst_2.append(e)
	print(int(''.join(lst_1)))
	print(int(''.join(lst_2)))
	count -= 1


for _ in range(int(input())):
	x = int(input())
	w = input()
	out1 = out2 = ''
	flag = False
	for i in range(x):
		if w[i] == '1' and flag == False:
			out1 += '1'
			out2 += '0'
			flag = True
			continue
		if w[i] == '1' and flag == True:
			out2 += '1'
			out1 += '0'
		elif w[i] == '2' and flag == False:
			out1 += '1'
			out2 += '1'
		elif w[i] == '2' and flag == True:
			out2 += '2'
			out1 += '0'
		else:
			out1 += '0'
			out2 += '0'
	print(out1)
	print(out2)


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input()))
	switch = False
	a = [1]
	b = [1]
	for j in s[1:]:
		if switch == False:
			a.append(j - j // 2)
			b.append(j // 2)
			if a[-1] > b[-1]:
				switch = True
		else:
			a.append(0)
			b.append(j)
	print(''.join(map(str, a)))
	print(''.join(map(str, b)))


t = int(input())
while t > 0:
	n = int(input())
	st = list(input())
	a = list('0' * n)
	b = list('0' * n)
	last = 'b'
	bigger = 'c'
	for i in range(n):
		if bigger == 'c':
			if st[i] == '2':
				a[i] = '1'
				b[i] = '1'
			elif st[i] == '1':
				if last == 'b':
					a[i] = '1'
					last = 'a'
					bigger = 'a'
				else:
					b[i] = '1'
					last = 'b'
					bigger = 'b'
		elif bigger == 'a':
			if st[i] == '2':
				a[i] = '0'
				b[i] = '2'
			elif st[i] == '1':
				b[i] = '1'
		elif bigger == 'b':
			if st[i] == '2':
				a[i] = '2'
				b[i] = '0'
			elif st[i] == '1':
				a[i] = '1'
	print(''.join(a))
	print(''.join(b))
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	l1 = ['0' for j in range(len(x))]
	l2 = ['0' for j in range(len(x))]
	flag = 0
	ans = 0
	for j in range(len(x)):
		if x[j] == '0':
			l1[j] == '0'
			l2[j] == '0'
		if x[j] == '1':
			flag = 1
			l1[j] = '1'
			ans = j
			break
		if x[j] == '2':
			l1[j] = '1'
			l2[j] = '1'
	if flag == 1:
		for j in range(ans + 1, len(x)):
			l2[j] = x[j]
	print(''.join(l1))
	print(''.join(l2))


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input()))
	ans = ['', '']
	fl = False
	for i in range(n):
		if s[i] == 0:
			ans[0] += '0'
			ans[1] += '0'
		elif s[i] == 1:
			if not fl:
				fl = True
				ans[0] += '1'
				ans[1] += '0'
				continue
			ans[0] += '0'
			ans[1] += '1'
		else:
			if not fl:
				ans[0] += '1'
				ans[1] += '1'
				continue
			ans[0] += '0'
			ans[1] += '2'
	print(ans[0])
	print(ans[1])


for j in range(int(input())):
	m = int(input())
	ans = input()
	li1 = ['1']
	li2 = ['1']
	sety = False
	for i in range(1, m):
		if int(ans[i]) == 2:
			if sety:
				li1.append('2')
				li2.append('0')
			else:
				li1.append('1')
				li2.append('1')
		if int(ans[i]) == 1:
			if sety:
				li1.append('1')
				li2.append('0')
			else:
				li1.append('0')
				li2.append('1')
				sety = True
		if int(ans[i]) == 0:
			li1.append('0')
			li2.append('0')
	print(''.join(li2))
	print(''.join(li1))


t = int(input())
for _ in range(t):
	l = int(input())
	x = input()
	ans1 = ''
	ans2 = ''
	for i in range(len(x)):
		if x[i] == '0' or x[i] == '2':
			ans1 += str(int(x[i]) // 2)
			ans2 += str(int(x[i]) // 2)
		else:
			ans1 += '1'
			ans2 += '0'
			for j in range(i + 1, len(x)):
				ans1 += '0'
				ans2 += x[j]
			break
	print(ans1, ans2, sep='\n')


for test_i in range(int(input())):
	n = int(input())
	x = input()
	(a, b) = ('1', '1')
	i = 0
	while i < n - 1:
		i += 1
		if x[i] == '2':
			a += '1'
			b += '1'
		elif x[i] == '0':
			a += '0'
			b += '0'
		else:
			a += '1'
			b += '0'
			break
	while i < n - 1:
		i += 1
		if x[i] == '2':
			a += '0'
			b += '2'
		elif x[i] == '0':
			a += '0'
			b += '0'
		else:
			a += '0'
			b += '1'
	print(a, b, sep='\n')


t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	a = ''
	b = ''
	cnta = 0
	cntb = 0
	eq = 0
	for j in x:
		if j == '0':
			a += '0'
			b += '0'
		elif j == '1':
			if eq == 0:
				a += '1'
				b += '0'
				eq = 1
			else:
				b += '1'
				a += '0'
		elif j == '2':
			if eq == 0:
				a += '1'
				b += '1'
			else:
				a += '0'
				b += '2'
	print(a)
	print(b)


t = int(input())
ans = []
for i in range(t):
	n = int(input())
	x = input()
	a = [1]
	b = [1]
	for j in range(1, n):
		if x[j] == '0':
			a += [0]
			b += [0]
		if x[j] == '2':
			a += [1]
			b += [1]
		if x[j] == '1':
			a += ['0' + x[j + 1:]]
			b += ['1' + '0' * (n - j - 1)]
			break
	ans.append([b, a])
for i in ans:
	for j in range(2):
		print(''.join(map(str, i[j])))


import sys

def compose_solution(n, x):
	flag = False
	a_string = ''
	b_string = ''
	for c in x:
		if not flag and c == '2':
			a_digit = 1
			b_digit = 1
		elif not flag and c == '1':
			a_digit = 1
			b_digit = 0
			flag = True
		else:
			a_digit = 0
			b_digit = int(c)
		a_string += str(a_digit)
		b_string += str(b_digit)
	return (a_string, b_string)

def main():
	next(sys.stdin)
	for line in sys.stdin:
		n = int(line)
		x = next(sys.stdin).strip()
		(a_string, b_string) = compose_solution(n, x)
		print(a_string)
		print(b_string)
main()


from sys import stdin

def iinput():
	return int(stdin.readline())

def sinput():
	return input()

def minput():
	return map(int, stdin.readline().split())

def linput():
	return list(map(int, stdin.readline().split()))
t = iinput()
while t:
	t -= 1
	n = iinput()
	s = sinput()
	a = ''
	b = ''
	for i in range(n):
		if s[i] == '0':
			a += '0'
			b += '0'
		elif s[i] == '1':
			a += '1'
			b += '0'
			for j in range(i + 1, n):
				b += s[j]
				a += '0'
			break
		else:
			a += '1'
			b += '1'
	print(a, b, sep='\n')


t = int(input())
for _ in range(t):
	n = int(input())
	x = list(map(int, list(input())))
	a = []
	b = []
	index = 0
	for i in x:
		if i == 2:
			a.append('1')
			b.append('1')
		elif i == 0:
			a.append('0')
			b.append('0')
		else:
			break
		index += 1
	if index < n:
		a.append('0')
		b.append('1')
	for i in range(index + 1, n):
		if x[i] == 2:
			a.append('2')
			b.append('0')
		if x[i] == 1:
			a.append('1')
			b.append('0')
		elif x[i] == 0:
			a.append('0')
			b.append('0')
	a1 = int(''.join(a))
	b1 = int(''.join(b))
	print(a1)
	print(b1)


t = int(input())
for p in range(t):
	n = int(input())
	l1 = list(input())
	l = list(map(int, l1))
	a = []
	b = []
	check = 0
	for i in l:
		if check == 0:
			if i == 2:
				a.append('1')
				b.append('1')
				continue
			if i == 0:
				a.append('0')
				b.append('0')
				continue
			if i == 1:
				a.append('1')
				b.append('0')
				check = 1
				continue
		if check == 1:
			if i == 2:
				a.append('0')
				b.append('2')
				continue
			if i == 0:
				a.append('0')
				b.append('0')
				continue
			if i == 1:
				a.append('0')
				b.append('1')
				continue
	print(''.join(a))
	print(''.join(b))


from pprint import pprint
import sys
input = sys.stdin.readline
q = int(input())
for _ in range(q):
	n = int(input())
	s = input()
	a = ['0'] * n
	b = ['0'] * n
	a[0] = '1'
	b[0] = '1'
	islock = False
	for i in range(1, n):
		if islock:
			b[i] = s[i]
			continue
		if s[i] == '2':
			a[i] = '1'
			b[i] = '1'
			continue
		if s[i] == '0':
			a[i] = '0'
			b[i] = '0'
			continue
		if s[i] == '1':
			a[i] = '1'
			b[i] = '0'
			islock = True
	print(''.join(a))
	print(''.join(b))


from sys import stdin, stdout
input = stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	s = s[:-1]
	ch = s[0]
	s = s[1:]
	a = ''
	b = ''
	val = -12
	if ch == '0':
		a = '1'
		b = '2'
		val = -1
	elif ch == '1':
		a = '2'
		b = '2'
		val = 0
	else:
		a = '1'
		b = '1'
		val = 0
	for x in s:
		if x == '0':
			a += '0'
			b += '0'
		elif x == '1':
			if val == 1:
				a += '0'
				b += '1'
			elif val == 0:
				a += '1'
				b += '0'
				val = 1
			else:
				a += '1'
				b += '0'
		elif x == '2':
			if val == 1:
				a += '0'
				b += '2'
			elif val == 0:
				a += '1'
				b += '1'
			else:
				a += '2'
				b += '0'
	stdout.write(a + '\n')
	stdout.write(b + '\n')


for _ in range(int(input())):
	n = int(input())
	s = input()
	a = [int(x) for x in s]
	a1 = []
	a2 = []
	i = 0
	while i < n:
		if a[i] == 2:
			a1 += [1]
			a2 += [1]
		elif a[i] == 0:
			a1 += [0]
			a2 += [0]
		else:
			a1 += [1]
			a2 += [0]
			i += 1
			break
		i += 1
	while i < n:
		a2 += [a[i]]
		a1 += [0]
		i += 1
	print(*a1, sep='')
	print(*a2, sep='')


for i in range(0, int(input())):
	n = int(input())
	string = input()
	ansFirst = ''
	ansSecond = ''
	if n == 1:
		print(1)
		print(1)
		continue
	a = ''
	b = ''
	ifLarger = 0
	for item in string:
		if ifLarger == 1:
			if item == '2':
				a = '0'
				b = '2'
			elif item == '1':
				a = '0'
				b = '1'
			else:
				a = b = '0'
		elif item == '2':
			a = '1'
			b = '1'
		elif item == '1':
			a = '1'
			b = '0'
			ifLarger = 1
		else:
			a = b = '0'
		ansFirst = ansFirst + a
		ansSecond = ansSecond + b
	print(ansFirst)
	print(ansSecond)


t = int(input())
while t:
	n = int(input())
	num = input()
	a = [0 for i in range(n)]
	b = [0 for i in range(n)]
	a[0] = 1
	b[0] = 1
	for i in range(1, n):
		if num[i] == '2':
			a[i] = 1
			b[i] = 1
		elif num[i] == '1':
			a[i] = 1
			b[i] = 0
		else:
			a[i] = 0
			b[i] = 0
	if num[-1] == 0:
		a[i] = 1
		b[i] = 2
	f = 0
	for i in range(n):
		if f == 0 and a[i] != b[i]:
			f = 1
			continue
		if f == 1:
			b[i] += a[i]
			a[i] = 0
	for i in a:
		print(i, end='')
	print()
	for i in b:
		print(i, end='')
	print()
	t -= 1


for _ in range(int(input())):
	k = input()
	n = list(input())
	flag = 0
	(a, b) = ('', '')
	for i in range(len(n)):
		if int(n[i]) == 2:
			if flag > 0:
				b += '2'
				a += '0'
			else:
				a += '1'
				b += '1'
		if int(n[i]) == 1:
			if flag == 0:
				flag += 1
				a += '1'
				b += '0'
				flag += 1
			else:
				a += '0'
				b += '1'
		if int(n[i]) == 0:
			a += '0'
			b += '0'
	print(a)
	print(b)


import sys
input = lambda : sys.stdin.readline().rstrip()

def calc(S):
	f = 0
	A = []
	B = []
	for s in S:
		a = int(s)
		if a == 1:
			if f:
				A.append('0')
				B.append('1')
			else:
				f = 1
				A.append('1')
				B.append('0')
		if a == 0:
			A.append('0')
			B.append('0')
		if a == 2:
			if f:
				A.append('0')
				B.append('2')
			else:
				A.append('1')
				B.append('1')
	print(''.join(A))
	print(''.join(B))
T = int(input())
for _ in range(T):
	N = int(input())
	calc(input())


from sys import stdout

def solve():
	t = int(input())
	for i in range(t):
		input()
		x = input()
		(a, b) = ('0', '0')
		q = None
		for d in x:
			if d == '2':
				if a == b:
					a += '1'
					b += '1'
				elif not q or q is None:
					a += '2'
					b += '0'
					q = True
				else:
					b += '2'
					a += '0'
					if q is None:
						q = False
			elif d == '1':
				if not q or q is None:
					a += '1'
					b += '0'
					q = True
				else:
					a += '0'
					b += '1'
					if q is None:
						q = False
			else:
				a += '0'
				b += '0'
		stdout.write(a[1:])
		stdout.write('\n')
		stdout.write(b[1:])
		stdout.write('\n')
solve()


t = int(input())
for _ in range(t):
	n = int(input())
	ter = list(map(int, input()))
	a = []
	b = []
	one = False
	for bit in ter:
		if one:
			a.append(0)
			b.append(bit)
		elif bit == 2 or (bit == 0 and (not one)):
			a.append(bit // 2)
			b.append(bit // 2)
		elif bit == 1:
			a.append(1)
			b.append(0)
			one = True
	print(''.join(map(str, a)))
	print(''.join(map(str, b)))


from itertools import *
t = int(input())
for i in range(t):
	n = int(input())
	x = input()
	(a, b) = ('', '')
	neq = False
	for i in x:
		if i == '2':
			if neq:
				a += '0'
				b += '2'
			else:
				a += '1'
				b += '1'
		if i == '1':
			if not neq:
				neq = True
				a += '1'
				b += '0'
			else:
				a += '0'
				b += '1'
		if i == '0':
			a += '0'
			b += '0'
	print(a)
	print(b)


from sys import stdin

def solve(tc):
	n = int(stdin.readline())
	s = stdin.readline().strip()
	biased = False
	a = ['1']
	b = ['1']
	for c in s[1:]:
		if c == '2':
			if biased:
				a.append('0')
				b.append('2')
			else:
				a.append('1')
				b.append('1')
		elif c == '1':
			if biased:
				a.append('0')
				b.append(c)
			else:
				a.append('1')
				b.append('0')
				biased = True
		else:
			a.append('0')
			b.append('0')
	print(''.join(a))
	print(''.join(b))
LOCAL_TEST = not __debug__
if LOCAL_TEST:
	infile = __file__.split('.')[0] + '-test.in'
	stdin = open(infile, 'r')
tcs = int(stdin.readline().strip())
tc = 1
while tc <= tcs:
	solve(tc)
	tc += 1


import sys
input = sys.stdin.readline
for i in range(int(input())):
	n = int(input())
	a = list(input())
	a.pop()
	ansa = []
	ansb = []
	gr = 0
	for j in range(n):
		if a[j] == '2':
			if gr == 1:
				ansa.append(0)
				ansb.append(2)
			else:
				ansa.append(1)
				ansb.append(1)
		elif a[j] == '1':
			if gr == 1:
				ansa.append(0)
				ansb.append(1)
			else:
				ansa.append(1)
				ansb.append(0)
				gr = 1
		else:
			ansa.append(0)
			ansb.append(0)
	print(*ansa, sep='')
	print(*ansb, sep='')


t = int(input())
for i in range(t):
	n = int(input())
	x = list(map(int, input()))
	a = [0] * len(x)
	b = [0] * len(x)
	k = 0
	for i in range(len(x)):
		if x[i] == 1 and k == 0:
			a[i] = 1
			k = 1
		elif x[i] == 1 and k == 1:
			b[i] = 1
		elif x[i] == 2 and k == 0:
			a[i] = 1
			b[i] = 1
		elif x[i] == 2 and k == 1:
			a[i] = 0
			b[i] = 2
	print(*a, sep='')
	print(*b, sep='')


import math
t = int(input())
for _ in range(t):
	l = int(input())
	s = input()
	i = 0
	s1 = ''
	s2 = ''
	while i < l and (s[i] == '2' or s[i] == '0'):
		if s[i] == '2':
			s1 += '1'
			s2 += '1'
		else:
			s1 += '0'
			s2 += '0'
		i += 1
	if i < l:
		s1 += '0'
		s2 += s[i]
		i += 1
	if i < l:
		s1 += s[i:]
		while i < l:
			s2 += '0'
			i += 1
	print(s2)
	print(s1)


import sys
from collections import Counter

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(INT()):
	N = INT()
	X = input()
	A = [''] * N
	B = [''] * N
	done = 0
	for i in range(N):
		if done:
			A[i] = '0'
			B[i] = X[i]
			continue
		if X[i] == '0':
			A[i] = B[i] = '0'
		elif X[i] == '2':
			A[i] = B[i] = '1'
		else:
			A[i] = '1'
			B[i] = '0'
			done = 1
	print(''.join(A))
	print(''.join(B))


for i in range(int(input())):
	n = int(input())
	x = input()
	a = ['1']
	b = ['1']
	for k in range(n - 1):
		a.append('0')
		b.append('0')
	count = 1
	for j in range(1, len(x)):
		if count == 0:
			b[j] = x[j]
		if count == 1:
			if x[j] == '2':
				a[j] = '1'
				b[j] = '1'
			if x[j] == '1':
				count = 0
				a[j] = '1'
				b[j] = '0'
	print(int(''.join(a)))
	print(int(''.join(b)))


t = int(input())
l = []
for i in range(t):
	n = int(input())
	x = list(input())
	t1 = []
	t2 = []
	a = 0
	for j in range(n):
		k = int(x[j])
		if a == 0:
			if k == 2:
				t1.append('1')
				t2.append('1')
			elif k == 0:
				t1.append('0')
				t2.append('0')
			else:
				t1.append('1')
				t2.append('0')
				a = 1
		else:
			t1.append('0')
			t2.append(str(k))
	l.append(int(''.join(t1)))
	l.append(int(''.join(t2)))
for i in l:
	print(i)


t = int(input())
for _ in range(t):
	n = int(input())
	num = input()
	num = [int(i) for i in num]
	(a, b) = ([], [])
	curr = 'a'
	eq = 0
	for i in num:
		if i == 0:
			a.append(0)
			b.append(0)
		if i == 1:
			if curr == 'a':
				a.append(1)
				b.append(0)
			else:
				b.append(1)
				a.append(0)
			if eq == 0:
				eq = 1
				curr = 'b'
		if i == 2:
			if eq == 0:
				a.append(1)
				b.append(1)
			else:
				b.append(2)
				a.append(0)
	print(''.join((str(i) for i in a)))
	print(''.join((str(i) for i in b)))


T = int(input())
for t in range(T):
	l = int(input())
	x = input()
	a = '1'
	b = '1'
	one = '1'
	zero = '0'
	flip = False
	for i in range(1, l, 1):
		if x[i] == '1':
			a += one
			b += zero
			if not flip:
				one = '0'
				zero = '1'
				flip = True
		elif x[i] == '2':
			if flip:
				a += '0'
				b += '2'
			else:
				a += '1'
				b += '1'
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


n = int(input())
h = []
j = []
for i in range(n):
	a = int(input())
	t = list(map(int, input()))
	flag = 0
	h.append(1)
	j.append(1)
	for b in range(1, a):
		if t[b] == 0:
			h.append(0)
			j.append(0)
		elif t[b] == 1 and flag == 0:
			h.append(0)
			j.append(1)
			flag = 1
		elif t[b] == 1 and flag == 1:
			h.append(1)
			j.append(0)
		elif t[b] == 2 and flag == 0:
			h.append(1)
			j.append(1)
		elif t[b] == 2 and flag == 1:
			h.append(2)
			j.append(0)
	h.append('*')
	j.append('*')
g = 0
n = 0
while g < len(h):
	if h[g] == '*':
		print()
		while n < len(j):
			if j[n] == '*':
				print()
				n = n + 1
				break
			else:
				print(j[n], end='')
			n = n + 1
	else:
		print(h[g], end='')
	g = g + 1


import sys
import math
for _ in range(int(input())):
	n = int(input())
	s = input()
	a1 = ''
	a2 = ''
	flg = 0
	for i in s:
		if flg:
			if i == '2':
				a1 += '0'
				a2 += '2'
			elif i == '1':
				a1 += '0'
				a2 += '1'
			else:
				a1 += '0'
				a2 += '0'
		elif i == '2':
			a1 += '1'
			a2 += '1'
		elif i == '1':
			a1 += '1'
			a2 += '0'
			flg = 1
		else:
			a1 += '0'
			a2 += '0'
	print(a1)
	print(a2)


t = int(input())
for jjj in range(t):
	n = int(input())
	x = input()
	a = ''
	b = ''
	ind = 0
	fl = False
	for i in x:
		if i == '3':
			a += '2'
			b += '1'
		elif i == '2':
			if not fl:
				a += '1'
				b += '1'
			else:
				a += '2'
				b += '0'
		elif i == '1':
			if ind == 0:
				a += '2'
				b += '2'
			else:
				if not fl:
					a += '0'
					b += '1'
				else:
					a += '1'
					b += '0'
				fl = True
		else:
			a += '0'
			b += '0'
		ind += 1
	print(a)
	print(b)


for _ in range(int(input())):
	n = int(input())
	x = str(input())
	a = '1' * n
	if '1' in x:
		a = '1' * (x.index('1') + 1) + '0' * (n - x.index('1') - 1)
	for i in range(n):
		if x[i] == '0':
			a = a[:i] + '0' + a[i + 1:]
	b = int(x) - int(a)
	print(a)
	print(b)


for _ in range(int(input())):
	n = int(input())
	x = input()
	a = []
	b = []
	flag = 0
	for i in range(n):
		if x[i] == '2':
			if flag == 0:
				a.append('1')
				b.append('1')
			else:
				a.append('0')
				b.append('2')
		if x[i] == '1':
			if flag == 0:
				a.append('1')
				b.append('0')
				flag = 1
			else:
				a.append('0')
				b.append('1')
		if x[i] == '0':
			a.append('0')
			b.append('0')
	s1 = ''
	s2 = ''
	s1 = s1.join(a)
	s2 = s2.join(b)
	print(s1)
	print(s2)


t = int(input())
for j in range(t):
	n = int(input())
	a = input()
	um = False
	b = ''
	c = ''
	for i in range(n):
		if um:
			b += '0'
			c += a[i]
		elif a[i] == '1':
			b += '1'
			c += '0'
			um = True
		else:
			b += str(int(a[i]) // 2)
			c += str(int(a[i]) // 2)
	print(int(b))
	print(int(c))


def answer(x):
	tieAGun = None
	a = [1] + [0] * (len(x) - 1)
	b = [1] + [0] * (len(x) - 1)
	ab = [a, b]
	for i in range(1, len(x)):
		if tieAGun is None:
			if x[i] == 2:
				a[i] = 1
				b[i] = 1
			if x[i] == 1:
				tieAGun = 0
				a[i] = 1
		else:
			ab[1 - tieAGun][i] = x[i]
	return ''.join([str(i) for i in a]) + '\n' + ''.join([str(i) for i in b])
testCount = int(input())
for _ in range(testCount):
	n = input()
	x = input().rstrip()
	print(answer([int(i) for i in x]))


t = int(input())
for test_case in range(t):
	n = int(input())
	x = input()
	a = '1'
	b = '1'
	for i in range(1, len(x)):
		char = x[i]
		if char == '2':
			a += '1'
			b += '1'
		if char == '0':
			a += '0'
			b += '0'
		if char == '1':
			a += '1'
			b += '0'
			for j in range(i + 1, len(x)):
				a += '0'
				b += x[j]
			break
	print(a)
	print(b)


for _ in range(int(input())):
	input()
	s = input()
	res1 = [''] * len(s)
	res2 = [''] * len(s)
	switch = False
	for (i, e) in enumerate(s):
		if i == 0:
			if e == '1':
				(res1[i], res2[i]) = ('2', '2')
			else:
				(res1[i], res2[i]) = ('1', '1')
		elif e == '0':
			(res1[i], res2[i]) = ('0', '0')
		elif e == '1':
			if switch:
				(res1[i], res2[i]) = ('0', '1')
			else:
				(res1[i], res2[i]) = ('1', '0')
				switch = True
		elif switch:
			(res1[i], res2[i]) = ('0', '2')
		else:
			(res1[i], res2[i]) = ('1', '1')
	print(''.join(res1))
	print(''.join(res2))


t = int(input())
while t:
	t -= 1
	n = int(input())
	s = input()
	a1 = ''
	a2 = ''
	for i in range(len(s)):
		if s[i] == '2':
			a1 += '1'
			a2 += '1'
		elif s[i] == '0':
			a1 += '0'
			a2 += '0'
		else:
			a1 += '1' + '0' * (len(s) - i - 1)
			a2 += '0' + s[i + 1:]
			break
	print(a1)
	print(a2)


count = int(input())
for i in range(count):
	n = int(input())
	x = input()
	a = ''
	b = ''
	one_detected = 0
	for j in range(n):
		if one_detected == 0:
			if x[j] == '2':
				a += '1'
				b += '1'
			elif x[j] == '1':
				one_detected = 1
				a += '0'
				b += '1'
			else:
				a += '0'
				b += '0'
		elif x[j] == '2':
			a += '2'
			b += '0'
		elif x[j] == '1':
			a += '1'
			b += '0'
		else:
			a += '0'
			b += '0'
	print(a)
	print(b)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().strip()))
	s1 = [0] * n
	s2 = [0] * n
	s1[0] = 1
	s2[0] = 1
	flag = True
	for j in range(1, n):
		if l[j] == 1:
			s1[j] = 1
			flag = False
			p = j + 1
			break
		if l[j] == 2:
			s1[j] = 1
			s2[j] = 1
		if l[j] == 0:
			s1[j] = 0
			s2[j] = 0
	if flag == False:
		for k in range(p, n):
			s2[k] = l[k]
	print(''.join((str(x) for x in s1)))
	print(''.join((str(x) for x in s2)))


T = int(input())
for t in range(T):
	n = int(input())
	num = input()
	o1 = []
	o2 = []
	first = True
	for x in num:
		if x == '2':
			if first:
				o1.append('1')
				o2.append('1')
			else:
				o1.append('2')
				o2.append('0')
		elif x == '1':
			o1.append('1')
			o2.append('0')
			if first:
				(o1, o2) = (o2, o1)
				first = False
		else:
			o1.append('0')
			o2.append('0')
	print(''.join(o1))
	print(''.join(o2))


def main_function():
	t = int(input())
	for i in range(t):
		n = int(input())
		x = input()
		a = ''
		for j in range(n):
			if x[j] != '1':
				a += '1' if x[j] == '2' else '0'
			else:
				b = a + '0' + x[j + 1:]
				a += '1' + '0' * (n - j - 1)
				print(a + '\n' + b)
				break
		else:
			print(a + '\n' + a)
main_function()


for _ in range(int(input())):
	n = int(input())
	num = input()
	num1 = [1]
	num2 = [1]
	equal = True
	for i in range(1, n):
		if not equal:
			num1.append('0')
			num2.append(num[i])
			continue
		if num[i] == '2':
			num1.append('1')
			num2.append('1')
		elif num[i] == '3':
			num1.append('2')
			num2.append('1')
			equal = False
		elif num[i] == '1':
			num1.append('1')
			num2.append('0')
			equal = False
		else:
			num1.append('0')
			num2.append('0')
	print(*num1, sep='')
	print(*num2, sep='')


testCases = int(input())
for _ in range(testCases):
	n = int(input())
	s = input()
	a = ''
	b = ''
	for i in range(n):
		if s[i] == '1':
			a += '1'
			a += '0' * (n - i - 1)
			b += '0'
			b += s[i + 1:]
			break
		else:
			a += str(int(s[i]) // 2)
			b += str(int(s[i]) // 2)
	print(a)
	print(b)


def I():
	return list(map(int, input().split()))
for __ in range(int(input())):
	a = ''
	b = ''
	n = int(input())
	c = input()
	f = False
	for i in range(n):
		if c[i] == '1':
			if f:
				a += '1'
				b += '0'
			else:
				a += '0'
				b += '1'
				f = 1
		elif c[i] == '0':
			a += '0'
			b += '0'
		elif not f:
			a += '1'
			b += '1'
		else:
			a += '2'
			b += '0'
	print(a)
	print(b)


from sys import stdin, stdout
rl = lambda : stdin.readline()
rll = lambda : stdin.readline().split()

def txor(a, b):
	ans = []
	for (ai, bi) in zip(a, b):
		ans.append((a + b) % 3)
	return ans

def main():
	t = int(rl())
	for _ in range(t):
		n = int(rl())
		x = [int(x) for x in list(rll()[0])]
		(a, b) = ([], [])
		flag = True
		for dig in x:
			if dig == 2:
				if flag:
					a.append(1)
					b.append(1)
				else:
					a.append(0)
					b.append(2)
			elif dig == 1:
				if flag:
					a.append(1)
					b.append(0)
					flag = False
				else:
					a.append(0)
					b.append(1)
			else:
				a.append(0)
				b.append(0)
		stdout.write(''.join((str(x) for x in a)))
		stdout.write('\n')
		stdout.write(''.join((str(x) for x in b)))
		stdout.write('\n')
	stdout.close()
main()


def solve():
	size = int(input())
	string = input()
	a = []
	b = []
	hit_one = False
	for ele in string:
		if ele == '2':
			if hit_one:
				a.append('0')
				b.append('2')
			else:
				a.append('1')
				b.append('1')
		elif ele == '1':
			if hit_one:
				a.append('0')
				b.append('1')
			else:
				a.append('1')
				b.append('0')
				hit_one = True
		else:
			a.append('0')
			b.append('0')
	return (''.join(a), ''.join(b))
n = int(input())
ans = []
for i in range(n):
	(c, d) = solve()
	ans.append(c)
	ans.append(d)
for ele in ans:
	print(ele)


for _ in range(int(input())):
	n = int(input())
	x = input()
	a = []
	b = []
	c = 0
	flag = False
	for i in range(n):
		if x[i] == '2':
			a.append('1')
			b.append('1')
		elif x[i] == '0':
			a.append('0')
			b.append('0')
		else:
			a.append('1')
			b.append('0')
			c = i
			flag = True
			break
	if flag == False or c == n - 1:
		a = ''.join(a)
		b = ''.join(b)
	else:
		a = ''.join(a) + '0' * (n - c - 1)
		b = ''.join(b) + x[c + 1:n]
	print(a)
	print(b)


for _ in range(int(input())):
	n = int(input())
	x = input()
	a = []
	b = []
	flag = 0
	for j in range(len(x)):
		i = x[j]
		if flag == 0:
			if i == '2':
				a.append('1')
				b.append('1')
			elif i == '1':
				flag = 1
				a.append('1')
				b.append('0')
			else:
				a.append('0')
				b.append('0')
		elif flag == 1:
			if i == '2':
				a.append('0')
				b.append('2')
			elif i == '1':
				a.append('0')
				b.append('1')
			else:
				a.append('0')
				b.append('0')
	print(''.join(a))
	print(''.join(b))


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(input())
	l_set = set(l)
	if '1' in l_set:
		ind = l.index('1')
	else:
		ind = n
	l1 = []
	l2 = []
	for i in range(ind):
		if l[i] == '0':
			l1.append('0')
			l2.append('0')
		elif l[i] == '2':
			l1.append('1')
			l2.append('1')
	li = ['0'] * (n - ind - 1)
	l1 += li
	li = l[ind + 1:]
	l2 += li
	if '1' in l_set:
		l1.insert(ind, '1')
		l2.insert(ind, '0')
	l1 = ''.join(l1)
	l2 = ''.join(l2)
	print(l1)
	print(l2)


import sys

def solve(k, s):
	(a, b) = (['1'], ['1'])
	c1 = False
	for i in range(1, k):
		if s[i] == '2':
			if not c1:
				a.append('1')
				b.append('1')
			else:
				a.append('0')
				b.append('2')
		if s[i] == '0':
			a.append('0')
			b.append('0')
		if s[i] == '1':
			if not c1:
				a.append('1')
				b.append('0')
			else:
				a.append('0')
				b.append('1')
			c1 = True
	print(''.join(a))
	print(''.join(b))
n = int(sys.stdin.readline())
for i in range(n):
	k = int(sys.stdin.readline())
	s = sys.stdin.readline()
	solve(k, s)


t = int(input())
for _ in range(t):
	l = int(input())
	n = list(input())
	a = ['0'] * l
	b = ['0'] * l
	a[0] = '1'
	b[0] = '1'
	val = False
	for i in range(1, l):
		if int(a[i - 1]) > int(b[i - 1]) or val:
			if a[i - 1] > b[i - 1] and (not val):
				val = True
			if n[i] == '2':
				b[i] = '2'
			elif n[i] == '1':
				b[i] = '1'
		elif n[i] == '2':
			a[i] = '1'
			b[i] = '1'
		elif n[i] == '1':
			a[i] = '1'
	print(''.join(a))
	print(''.join(b))


t = int(input())
while t:
	n = input()
	sr = input()
	r = 0
	p = 0
	s = ''
	while r < len(sr):
		if sr[r] == '0':
			s += '0'
		elif sr[r] == '1' and p == 0:
			s += '1'
			p = 1
		elif sr[r] == '2' and p == 0:
			s += '1'
		else:
			s += '0'
		r += 1
	print(s)
	print(int(sr) - int(s))
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	x = input()
	(a, b) = ([0 for _ in range(n)], [0 for _ in range(n)])
	flag = 0
	for i in range(n):
		if i > 0 and a[i - 1] > b[i - 1]:
			flag = 1
		if x[i] == '0':
			(a[i], b[i]) = ('0', '0')
		elif x[i] == '1':
			if flag == 0:
				(a[i], b[i]) = ('1', '0')
			else:
				(a[i], b[i]) = ('0', '1')
		elif x[i] == '2':
			if flag == 0:
				(a[i], b[i]) = ('1', '1')
			else:
				(a[i], b[i]) = ('0', '2')
	print(''.join(a))
	print(''.join(b))


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
import random
from queue import PriorityQueue
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from itertools import permutations
from math import factorial as f

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p
from collections import defaultdict
from heapq import heappop, heappush, heapify
t = int(input())
for _ in range(t):
	n = int(input())
	c = input()
	(x, y) = ([], [])
	flag = 0
	for i in range(n):
		if c[i] == '0':
			if i == 0:
				x.append('2')
				y.append('1')
				flag = 1
			else:
				x.append('0')
				y.append('0')
		elif c[i] == '1':
			if i != 0:
				if not flag:
					x.append('1')
					y.append('0')
					flag = 1
				else:
					x.append('0')
					y.append('1')
			if i == 0:
				x[0] = '2'
				y[0] = '2'
		elif c[i] == '2':
			if not flag:
				x.append('1')
				y.append('1')
			else:
				x.append('0')
				y.append('2')
	print(''.join(x))
	print(''.join(y))


def solve():
	N = int(input())
	S = input()
	A = ''
	B = ''
	for i in range(N):
		if S[i] == '1':
			A += '1' + '0' * (N - i - 1)
			B += '0' + S[i + 1:]
			break
		else:
			A += str(int(S[i]) // 2)
			B += str(int(S[i]) // 2)
	print(A)
	print(B)
T = int(input())
for _ in range(T):
	solve()


def linp():
	return list(map(int, input().split()))

def minp():
	return map(int, input().split())

def iinp():
	return int(input())

def test():
	return int(input())

def inp():
	return input()

def solve():
	n = iinp()
	l = list(inp())
	a = ['0'] * n
	b = ['0'] * n
	flag = False
	for i in range(n):
		if flag:
			if l[i] == '2':
				a[i] = '0'
				b[i] = '2'
			elif l[i] == '1':
				a[i] = '0'
				b[i] = '1'
		elif l[i] == '2':
			a[i] = '1'
			b[i] = '1'
		elif l[i] == '1':
			a[i] = '1'
			b[i] = '0'
			flag = True
	a_n = ''.join(a)
	b_n = ''.join(b)
	print(a_n)
	print(b_n)

def main():
	for _ in range(test()):
		solve()
main()


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	a = '1'
	b = '1'
	h = {'0': 0}
	flag = 0
	for i in s[1:]:
		if i is '2' and h['0'] == 0:
			a += '1'
			b += '1'
		elif i is '2' and h['0'] == 1:
			a += '0'
			b += '2'
		elif i is '1':
			if flag == 0:
				a += '1'
				b += '0'
				h['0'] += 1
				flag += 1
			else:
				a += '0'
				b += '1'
		elif i is '0':
			a += '0'
			b += '0'
	print(a)
	print(b)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	(s1, s2) = (['1'], ['1'])
	s = s[1:len(s)]
	c = 0
	for i in s:
		if i == '0':
			s1.append('0')
			s2.append('0')
		if i == '1' and c == 357:
			s1.append('0')
			s2.append('1')
		if i == '1' and c == 0:
			s1.append('1')
			s2.append('0')
			c = 357
		if i == '2' and c == 0:
			s1.append('1')
			s2.append('1')
		if i == '2' and c == 357:
			s1.append('0')
			s2.append('2')
	ss1 = ''
	ss2 = ''
	for i in range(n):
		ss1 += s1[i]
		ss2 += s2[i]
	print(ss1)
	print(ss2)


t = int(input())
for _ in range(t):
	n = int(input())
	temp = input()
	temp = list(temp)
	arr = []
	for i in range(len(temp)):
		arr.append(int(temp[i]))
	a = []
	b = []
	flag = 0
	for i in range(n):
		if arr[i] == 2 and flag == 0:
			a.append(1)
			b.append(1)
		elif arr[i] == 2 and flag == 1:
			a.append(0)
			b.append(2)
		elif arr[i] == 1 and flag == 0:
			a.append(1)
			b.append(0)
			flag = 1
		elif arr[i] == 1 and flag == 1:
			a.append(0)
			b.append(1)
		elif arr[i] == 0:
			a.append(0)
			b.append(0)
	a1 = ''.join([str(elem) for elem in a])
	b1 = ''.join([str(elem) for elem in b])
	print(a1)
	print(b1)


def stringmagic(n, s):
	(s1, s2, flag) = ('', '', 0)
	for (i, l) in enumerate(s):
		if l == '1' and flag == 0:
			s1 += '1'
			s2 += '0'
			flag = 1
		elif l == '1':
			s1 += '0'
			s2 += '1'
		elif l == '2' and flag == 0:
			s1 += '1'
			s2 += '1'
		elif l == '2':
			s1 += '0'
			s2 += '2'
		elif l == '0':
			s1 += '0'
			s2 += '0'
	print(s1)
	if s2[0] == '0':
		s2 = s2[1:]
	print(s2)
for i in range(int(input())):
	n = int(input())
	s = input()
	stringmagic(n, s)


for _ in range(int(input())):
	n = int(input())
	a = input()
	b = [1] + [0] * (n - 1)
	c = [1] + [0] * (n - 1)
	for i in range(1, n):
		if a[i] == '2' and '1' not in a[0:i]:
			b[i] = 1
			c[i] = 1
		elif a[i] == '2' and '1' in a[0:i]:
			b[i] = 0
			c[i] = 2
		elif a[i] == '1' and '1' not in a[0:i]:
			b[i] = 1
			c[i] = 0
		elif a[i] == '1' and '1' in a[0:i]:
			b[i] = 0
			c[i] = 1
		elif a[i] == '0':
			b[i] = 0
			c[i] = 0
	print(*b, sep='')
	print(*c, sep='')


for _ in range(int(input())):
	n = int(input())
	s = input()
	larger = '1'
	smaller = '1'
	oneDone = False
	for char in s[1:]:
		if char == '0':
			larger += '0'
			smaller += '0'
		elif char == '1':
			if oneDone:
				smaller += '1'
				larger += '0'
			else:
				oneDone = True
				larger += '1'
				smaller += '0'
		elif oneDone:
			larger += '0'
			smaller += '2'
		else:
			larger += '1'
			smaller += '1'
	print(larger)
	print(smaller)


for _ in range(int(input())):
	n = int(input())
	x = int(input())
	x = list(str(x))
	a = [0] * n
	b = [0] * n
	p = 0
	for i in range(n):
		if p == 0:
			if x[i] == '2':
				a[i] = 1
				b[i] = 1
			elif x[i] == '0':
				a[i] = 0
				b[i] = 0
			else:
				a[i] = 1
				b[i] = 0
				p = 1
		elif x[i] == '2':
			a[i] = 0
			b[i] = 2
		elif x[i] == '0':
			a[i] = 0
			b[i] = 0
		else:
			a[i] = 0
			b[i] = 1
	print(''.join((str(x) for x in a)))
	print(''.join((str(x) for x in b)))


import heapq as hp
import collections
import bisect
import math
import re

def unpack(func=int):
	return map(func, input().split())

def l_unpack(func=int):
	return list(map(func, input().split()))

def s_unpack(func=int):
	return sorted(map(func, input().split()))

def ml_unpack(n):
	return [int(input()) for i in range(n)]

def range_n():
	return range(int(input()))

def counter(a):
	d = {}
	for x in a:
		if x in d:
			d[x] += 1
		else:
			d[x] = 1
	return d

def getint():
	return int(input())

def setbits(x):
	count = 0
	while x:
		x = x & x - 1
		count += 1
	return count

def main():
	for _ in range_n():
		n = getint()
		x = input()
		i = 0
		(a, b) = ([0] * n, [0] * n)
		while i < n:
			if x[i] == '2':
				(a[i], b[i]) = (1, 1)
			elif x[i] == '1':
				(a[i], b[i]) = (1, 0)
				break
			else:
				(a[i], b[i]) = (0, 0)
			i += 1
		i += 1
		while i < n:
			if x[i] == '2':
				(a[i], b[i]) = (0, 2)
			elif x[i] == '1':
				(a[i], b[i]) = (0, 1)
			else:
				(a[i], b[i]) = (0, 0)
			i += 1
		print(*a, sep='')
		print(*b, sep='')
main()


for i in range(int(input())):
	n = int(input())
	strx = input()
	x = int(strx)
	if x & 1 == 0 and strx.count('1') == 0:
		val = x // 2
		print(val)
		print(val)
	elif strx.count('1') == 1 and strx[-1] == 1:
		val = (x - 1) // 2
		print(val)
		print(val + 1)
	else:
		ind = strx.index('1')
		lstrx = list(strx)
		lstrx[ind:] = '2' + '0' * (n - ind - 1)
		strx = ''.join(lstrx)
		newx = int(strx)
		val = newx // 2
		print(val)
		print(x - val)


for _ in range(int(input())):
	n = int(input())
	s = input()
	a = '1'
	b = '1'
	f = 0
	for i in s[1:]:
		if f:
			a += '0'
			b += i
			continue
		if i == '0':
			a += '0'
			b += '0'
		elif i == '2':
			a += '1'
			b += '1'
		elif not f:
			a += '1'
			b += '0'
			f = 1
		else:
			a += '0'
			b += i
	print(a + '\n' + b)


t = int(input())
for i in range(0, t):
	n = input()
	s = input()
	s1 = '1'
	s2 = '1'
	temp = 1
	for e in s[1:]:
		temp += 1
		if e == '0':
			s1 += '0'
			s2 += '0'
		elif e == '2':
			s1 += '1'
			s2 += '1'
		else:
			s1 += '1'
			s2 += '0'
			break
	if temp < len(s):
		s1 += '0' * (len(s) - temp)
		s2 += s[temp:]
	print(s1)
	print(s2)


from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 300010
MOD = 10 ** 9 + 7
spf = [i for i in range(MAXN)]
spf[0] = spf[1] = -1

def sieve():
	for i in range(2, MAXN, 2):
		spf[i] = 2
	for i in range(3, int(MAXN ** 0.5) + 1):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def fib(n, m):
	if n == 0:
		return [0, 1]
	else:
		(a, b) = fib(n // 2)
		c = a % m * (b % m * 2 - a % m) % m
		d = a % m * (a % m) % m + b % m * b % m % m
		if n % 2 == 0:
			return [c, d]
		else:
			return [d, c + d]

def charIN(x=' '):
	return sys.stdin.readline().strip().split(x)

def arrIN(x=' '):
	return list(map(int, sys.stdin.readline().strip().split(x)))

def ncr(n, r):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % MOD
		den = den * (i + 1) % MOD
	return num * pow(den, MOD - 2, MOD) % MOD

def flush():
	return sys.stdout.flush()
for _ in range(int(input())):
	n = int(input())
	x = [int(i) for i in input()]
	a = [0] * n
	b = [0] * n
	z = -1
	for i in range(n):
		if x[i] == 2:
			a[i] = b[i] = 1
		elif x[i] == 1:
			z = i
			break
		else:
			a[i] = b[i] = 0
	if z == -1:
		print(''.join(map(str, a)))
		print(''.join(map(str, b)))
	else:
		a[z] = 1
		b[z] = 0
		for i in range(z + 1, n):
			if x[i] == 2:
				a[i] = 0
				b[i] = 2
			elif x[i] == 1:
				a[i] = 0
				b[i] = 1
			else:
				a[i] = b[i] = 0
		print(''.join(map(str, a)))
		print(''.join(map(str, b)))


def solve(d, x_str):
	al = ['1'] + [None] * (d - 1)
	bl = ['1'] + [None] * (d - 1)
	match = {2: ('1', '1'), 1: ('1', '0'), 0: ('0', '0')}
	for i in range(1, len(x_str)):
		c = int(x_str[i])
		(al[i], bl[i]) = match[c]
		if c == 1:
			match = {2: ('0', '2'), 1: ('0', '1'), 0: ('0', '0')}
	a = int(''.join(al))
	b = int(''.join(bl))
	return (a, b)
t = int(input())
for ti in range(t):
	d = int(input())
	x_str = input().strip()
	(a, b) = solve(d, x_str)
	print(f'{a}\n{b}')


t = int(input())
for q in range(t):
	n = int(input())
	x = input()
	a = ['1']
	b = ['1']
	c = 0
	for w in range(1, n):
		if c == 1:
			a.append('0')
			b.append(x[w])
		elif x[w] == '2':
			a.append('1')
			b.append('1')
		elif x[w] == '1':
			a.append('1')
			b.append('0')
			c = 1
		elif x[w] == '0':
			a.append('0')
			b.append('0')
	print(''.join(a))
	print(''.join(b))


for i in range(int(input())):
	n = map(int, input().split())
	c = input()
	(a, b) = ('', '')
	flag = 0
	for i in c:
		if flag:
			a += '0'
			b += i
		elif i == '0':
			a += '0'
			b += '0'
		elif i == '2':
			a += '1'
			b += '1'
		else:
			a += '1'
			b += '0'
			flag = 1
	print(a)
	print(b)