import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;

public class TernaryXOR {
	static int mod = 1000000007;
	static long L_INF = (1L << 60L);

	static class Reader {
		final private int BUFFER_SIZE = 1 << 16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer, bytesRead;

		public Reader() {
			din = new DataInputStream(System.in);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public Reader(String file_name) throws IOException {
			din = new DataInputStream(new FileInputStream(file_name));
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public String readLine(int n) throws IOException {
			byte[] buf = new byte[10*n]; // line length
			int cnt = 0, c;
			while ((c = read()) != -1) {
				if (c == '\n')
					break;
				buf[cnt++] = (byte) c;
			}
			return new String(buf, 0, cnt);
		}

		public int nextInt() throws IOException {
			int ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (neg)
				return -ret;
			return ret;
		}

		public long nextLong() throws IOException {
			long ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}

		public double nextDouble() throws IOException {
			double ret = 0, div = 1;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();

			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (c == '.') {
				while ((c = read()) >= '0' && c <= '9') {
					ret += (c - '0') / (div *= 10);
				}
			}

			if (neg)
				return -ret;
			return ret;
		}

		private void fillBuffer() throws IOException {
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1)
				buffer[0] = -1;
		}

		private byte read() throws IOException {
			if (bufferPointer == bytesRead)
				fillBuffer();
			return buffer[bufferPointer++];
		}

		public void close() throws IOException {
			if (din == null)
				return;
			din.close();
		}
	}

	public static void main(String[] args) throws IOException {
		Reader in = new Reader();
		int i, t, n, j, k;
		t = in.nextInt();
		StringBuilder ans = new StringBuilder();
		String s;
		char c;
		while (t-- > 0) {
			n = in.nextInt();
			in.readLine(n);
			s = in.readLine().substring(0, n);
			StringBuilder x = new StringBuilder();
			StringBuilder y = new StringBuilder();
			i = 0;
			x.append('1');
			y.append('1');
			int b = -1;

			for (i = 1; i < n; i++) {
				c = s.charAt(i);
				if (c == '0') {
					x.append('0');
					y.append('0');
				} else if (c == '1') {
					x.append('1');
					y.append('0');
					b = i + 1;
					break;
				} else {
					x.append('1');
					y.append('1');
				}
			}
			if (b != -1) {
				for (i = b; i < n; i++) {
					x.append('0');
					y.append(s.charAt(i));
				}
			}
			ans.append(x.toString() + "\n" + y.toString() + "\n");
		}
		System.out.println(ans);
	}
}


import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;

public class TernaryXOR {
	static int mod = 1000000007;
	static long L_INF = (1L << 60L);

	static class Reader {
		final private int BUFFER_SIZE = 1 << 16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer, bytesRead;

		public Reader() {
			din = new DataInputStream(System.in);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public Reader(String file_name) throws IOException {
			din = new DataInputStream(new FileInputStream(file_name));
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public String readLine(int n) throws IOException {
			byte[] buf = new byte[10*n]; // line length
			int cnt = 0, c;
			while ((c = read()) != -1) {
				if (c == '\n')
					break;
				buf[cnt++] = (byte) c;
			}
			return new String(buf, 0, cnt);
		}

		public int nextInt() throws IOException {
			int ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (neg)
				return -ret;
			return ret;
		}

		public long nextLong() throws IOException {
			long ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}

		public double nextDouble() throws IOException {
			double ret = 0, div = 1;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();

			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (c == '.') {
				while ((c = read()) >= '0' && c <= '9') {
					ret += (c - '0') / (div *= 10);
				}
			}

			if (neg)
				return -ret;
			return ret;
		}

		private void fillBuffer() throws IOException {
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1)
				buffer[0] = -1;
		}

		private byte read() throws IOException {
			if (bufferPointer == bytesRead)
				fillBuffer();
			return buffer[bufferPointer++];
		}

		public void close() throws IOException {
			if (din == null)
				return;
			din.close();
		}
	}

	public static void main(String[] args) throws IOException {
		Reader in = new Reader();
		int i, t, n, j, k;
		t = in.nextInt();
		StringBuilder ans = new StringBuilder();
		String s;
		char c;
		while (t-- > 0) {
			n = in.nextInt();
			in.readLine(n);
			s = in.readLine(n).substring(0, n);
			StringBuilder x = new StringBuilder();
			StringBuilder y = new StringBuilder();
			i = 0;
			x.append('1');
			y.append('1');
			int b = -1;

			for (i = 1; i < n; i++) {
				c = s.charAt(i);
				if (c == '0') {
					x.append('0');
					y.append('0');
				} else if (c == '1') {
					x.append('1');
					y.append('0');
					b = i + 1;
					break;
				} else {
					x.append('1');
					y.append('1');
				}
			}
			if (b != -1) {
				for (i = b; i < n; i++) {
					x.append('0');
					y.append(s.charAt(i));
				}
			}
			ans.append(x.toString() + "\n" + y.toString() + "\n");
		}
		System.out.println(ans);
	}
}


import java.io.*;
import java.util.*;
public class C629C
{
    static PrintWriter out=new PrintWriter((System.out));
    public static void main(String args[])throws IOException
    {
        Reader sc=new Reader();
        int t=sc.nextInt();
        while(t-->0)
        {
            int n=sc.nextInt();
            String s=sc.next();
            solve(s,n);
        }
        out.close();
    }

    public static void solve(String s,int n)
    {
        StringBuilder a=new StringBuilder("");
        StringBuilder b=new StringBuilder("");
        boolean active=false;
        for(int x=0;x<n;x++)
        {
            char ch=s.charAt(x);
            if(ch=='1')
            {
                if(x!=0)
                {
                    if(active)
                    {
                        a.append('0');
                        b.append('1');
                    }
                    else
                    {
                        b.append('0');
                        a.append('1');
                        active=true;
                    }
                }
                else
                {
                    a.append("2");
                    b.append("2");
                }
            }
            else if(ch=='2')
            {
                if(active&&x!=0)
                {
                    a.append('0');
                    b.append('2');
                }
                else
                {
                    a.append('1');
                    b.append('1');
                }
            }
            else
            {
                if(active)
                {
                    a.append('0');
                    b.append('0');
                }
                else
                {
                    a.append('0');
                    b.append('0');
                    active=true;
                }
            }
        }
        out.println(a+"\n"+b);
    }

    static class Reader
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        public String next()
        {
            while(!st.hasMoreTokens())
            {
                try
                {
                    st=new StringTokenizer(br.readLine());
                }
                catch(Exception e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt()
        {
            return Integer.parseInt(next());
        }

        public long nextLong()
        {
            return Long.parseLong(next());
        }

        public double nextDouble()
        {
            return Double.parseDouble(next());
        }

        public String nextLine()
        {
            try
            {
                return br.readLine();
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext()
        {
            String next=null;
            try
            {
                next=br.readLine();
            }
            catch(Exception e)
            {
            }
            if(next==null)
            {
                return false;
            }
            st=new StringTokenizer(next);
            return true;
        }
    }
}


import java.io.*;
import java.util.*;
public class C629C
{
    static PrintWriter out=new PrintWriter((System.out));
    public static void main(String args[])throws IOException
    {
        Reader sc=new Reader();
        int t=sc.nextInt();
        while(t-->0)
        {
            int n=sc.nextInt();
            String s=sc.next();
            solve(s,n);
        }
        out.close();
    }

    public static void solve(String s,int n)
    {
        StringBuilder a=new StringBuilder("");
        StringBuilder b=new StringBuilder("");
        for(int x=0;x<n;x++)
        {
            char ch=s.charAt(x);
            if(ch=='1')
            {
                if(x!=0)
                {
                    a.append('0');
                    b.append('1');
                }
                else
                {
                    a.append("2");
                    b.append("2");
                }
            }
            else if(ch=='2')
            {
                a.append('1');
                b.append('1');
            }
            else
            {
                a.append('0');
                b.append('0');
            }
        }
        out.println(a+"\n"+b);
    }

    static class Reader
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        public String next()
        {
            while(!st.hasMoreTokens())
            {
                try
                {
                    st=new StringTokenizer(br.readLine());
                }
                catch(Exception e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt()
        {
            return Integer.parseInt(next());
        }

        public long nextLong()
        {
            return Long.parseLong(next());
        }

        public double nextDouble()
        {
            return Double.parseDouble(next());
        }

        public String nextLine()
        {
            try
            {
                return br.readLine();
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext()
        {
            String next=null;
            try
            {
                next=br.readLine();
            }
            catch(Exception e)
            {
            }
            if(next==null)
            {
                return false;
            }
            st=new StringTokenizer(next);
            return true;
        }
    }
}


import java.util.*;
public class C633B
{
    public static void main(String[] args)
    {
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while(t-->0)
        {
            int n=sc.nextInt();
            int ar[]=new int[n];
            String s=sc.next();
            for(int x=0;x<n;x++)
            {
                ar[x]=s.charAt(x)-48;
            }
            solve(ar,n);
            System.out.println();
        }
    }

    public static void solve(int ar[],int n)
    {
        for(int x=0;x<n;x++)
        {
            if(ar[x]==1)
            {
                System.out.print(2);
            }
            else if(ar[x]==2)
            {
                System.out.print(1);
            }
            else
            {
                System.out.print(0);
            }
        }
    }
}


import java.io.*;
import java.util.*;
public class C629C
{
    static PrintWriter out=new PrintWriter((System.out));
    public static void main(String args[])throws IOException
    {
        Reader sc=new Reader();
        int t=sc.nextInt();
        while(t-->0)
        {
            int n=sc.nextInt();
            String s=sc.next();
            solve(s,n);
        }
        out.close();
    }

    public static void solve(String s,int n)
    {
        StringBuilder a=new StringBuilder("");
        StringBuilder b=new StringBuilder("");
        boolean active=false;
        for(int x=0;x<n;x++)
        {
            char ch=s.charAt(x);
            if(ch=='1')
            {
                a.append('1');
                b.append('0');
                for(int y=x+1;y<n;y++)
                {
                    a.append('0');
                    b.append(s.charAt(y));
                }
                break;
            }
            else if(ch=='2')
            {
                a.append('1');
                b.append('1');
            }
            else
            {
                a.append('0');
                b.append('0');
            }
        }
        out.println(a+"\n"+b);
    }

    static class Reader
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        public String next()
        {
            while(!st.hasMoreTokens())
            {
                try
                {
                    st=new StringTokenizer(br.readLine());
                }
                catch(Exception e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt()
        {
            return Integer.parseInt(next());
        }

        public long nextLong()
        {
            return Long.parseLong(next());
        }

        public double nextDouble()
        {
            return Double.parseDouble(next());
        }

        public String nextLine()
        {
            try
            {
                return br.readLine();
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext()
        {
            String next=null;
            try
            {
                next=br.readLine();
            }
            catch(Exception e)
            {
            }
            if(next==null)
            {
                return false;
            }
            st=new StringTokenizer(next);
            return true;
        }
    }
}


import java.util.*;
import java.io.*;

     public  class Solution{

            public static void main(String args[])throws IOException{
            Scanner sc = new Scanner(System.in);

             int t = sc.nextInt();

             while(t --> 0){
                 int n = sc.nextInt();
                String s = sc.next();
                boolean max = false;
                StringBuilder str1 = new StringBuilder();
                StringBuilder str2 = new StringBuilder();

                for(char c : s.toCharArray()){
                    if( c== '2' && !max){
                        str1.append('1');
                        str2.append('1');
                    }else if(c == '2' && max){
                        str1.append('2');
                        str2.append('0');
                    }else if( c == '1' && !max){
                        max = true;
                        str1.append('0');
                        str2.append('1');
                    }else if(c == '1' && max){
                        str1.append('1');
                        str2.append('0');
                    }else if(c == '0'){
                        str1.append('0');
                        str2.append('0');
                    }
                    }

                    System.out.println(str1.toString());
                    System.out.println(str2.toString());
             }
            }
       }


import java.util.*;
import java.io.*;

     public  class Solution{

            public static void main(String args[])throws IOException{
            Scanner sc = new Scanner(System.in);

             int t1 = sc.nextInt();

             while(t1 --> 0){
                 int n = sc.nextInt();
                String s = sc.next();
                boolean max = false;
                StringBuilder str1 = new StringBuilder();
                StringBuilder str2 = new StringBuilder();

                for(char c : s.toCharArray()){
                    if( c== '2' && !max){
                        str1.append('1');
                        str2.append('1');
                    }else if(c == '2' && max){
                        str1.append('2');
                        str2.append('0');
                    }else if( c == '1' && !max){
                        max = true;
                        str1.append('0');
                        str2.append('1');
                    }else if(c == '1' && max){
                        str1.append('1');
                        str2.append('0');
                    }else if(c == '0'){
                        str1.append('0');
                        str2.append('0');
                    }
                    }

                    System.out.println(str1.toString());
                    System.out.println(str2.toString());
             }
            }
       }


import java.util.*;
import java.io.*;

      public class Solution{

            public static void main(String args[])throws IOException{
            Scanner sc = new Scanner(System.in);

             int t = sc.nextInt();

             while(t --> 0){
                 int n = sc.nextInt();
                String s = sc.next();

                int num1 = 1;
                int num2 = 1;

                for(int i = 1; i < s.length(); i++){
                    char c = s.charAt(i);
                    int a = c-'0';
                    if(a == 2){
                        int temp1 = num1*10+2;
                        int temp2 = num2*10;
                        int max = Math.max(temp1,temp2);
                        int temp3 = num1*10;
                        int temp4 = num2*10+2;
                        int max1 = Math.max(temp3,temp4);
                        int temp5 = num1*10+1;
                        int temp6 = num2*10+1;
                        int max2 = Math.max(temp5,temp6);
                        if(max <= max1 && max <= max2){
                            num1 = temp1; num2 = temp2;
                        }else if(max1 <= max && max1 <= max2){
                            num1 = temp3; num2 = temp4;
                        }else{
                            num1 = temp5; num2 = temp6;
                        }
                    }else if(a == 1){
                        int temp1 = num1*10;
                        int temp2 = num2*10+1;
                        int max = Math.max(temp1,temp2);
                        int temp3 = num1*10+1;
                        int temp4 = num2*10;
                        int max1 = Math.max(temp3,temp4);
                        if(max <= max1){
                            num1 = temp1; num2 = temp2;
                        }else{
                            num1 = temp3; num2 = temp4;
                        }
                        }else{
                            num1 = num1*10;
                            num2  = num2*10;
                        }

                    }

                    System.out.println(num1);
                    System.out.println(num2);
                }
            }
       }


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class geek {
    public static void main(String args[]) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuffer sb = new StringBuffer();
        int n = Integer.parseInt(br.readLine());
        for (int i1 = 0; i1 < n; i1++) {
            Long l = Long.parseLong(br.readLine());
            String str = br.readLine();
            String str1 = "", str2 = "";
            boolean b = false;
            for (int i = 0; i < str.length(); i++) {
                if (str.charAt(i) == '2') {
                    if (!b) {
                        str1 += "1";
                        str2 += "1";
                    } else {
                        str1 += "0";
                        str2 += "2";
                    }

                } else if (str.charAt(i) == '0') {
                    str1 += "0";
                    str2 += "0";
                } else {
                    if (!b) {
                        b = true;
                        str1 += "1";
                        str2 += "0";
                    } else {
                        str1 += "0";
                        str2 += "1";
                    }

                }
            }
            sb.append(str1 + "\n" + str2 + "\n");
        }
        System.out.print(sb);

    }

}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class geek {
    public static void main(String args[]) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuffer sb = new StringBuffer();
        int n = Integer.parseInt(br.readLine());
        for (int i1 = 0; i1 < n; i1++) {
            Long l = Long.parseLong(br.readLine());
            String str = br.readLine();
            String str1="",str2="";
            for(int i=0;i<str.length();i++){
                    if(str.charAt(i)=='2'){
                        str1+="1";
                        str2+="1";
                    } else if(str.charAt(i)=='0'){
                        str1+="0";
                        str2+="0";
                    } else{
                        str1+="0";
                        str2+="1";
                    }
            }
            sb.append(str1+"\n"+str2+"\n");
        }
        System.out.println(sb);

    }

}


import java.io.BufferedReader;
import java.io.InputStreamReader;

public class geek {
    public static void main(String args[]) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(br.readLine());
        for (int i1 = 0; i1 < n; i1++) {
            StringBuffer str1 = new StringBuffer();
            StringBuffer str2 = new StringBuffer();
            Long l = Long.parseLong(br.readLine());
            String str = br.readLine();

            boolean b = false;
            for (int i = 0; i < str.length(); i++) {
                if (str.charAt(i) == '2') {
                    if (!b) {
                        str1.append("1");
                        str2.append("1");
                    } else {
                        str1.append("0");
                        str2.append("2");
                    }

                } else if (str.charAt(i) == '0') {
                    str1.append("0");
                    str2.append("0");
                } else {
                    if (!b) {
                        b = true;
                        str1.append("1");
                        str2.append("0");
                    } else {
                        str1.append("0");
                        str2.append("1");
                    }

                }
            }
            System.out.println(str1 + "\n" + str2);
        }

    }

}


import java.io.BufferedReader;
import java.io.InputStreamReader;

public class geek {
    public static void main(String args[]) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuffer str1 = new StringBuffer();
        StringBuffer str2 = new StringBuffer();
        int n = Integer.parseInt(br.readLine());
        for (int i1 = 0; i1 < n; i1++) {
            Long l = Long.parseLong(br.readLine());
            String str = br.readLine();

            boolean b = false;
            for (int i = 0; i < str.length(); i++) {
                if (str.charAt(i) == '2') {
                    if (!b) {
                        str1.append("1");
                        str2.append("1");
                    } else {
                        str1.append( "0");
                        str2.append("2");
                    }

                } else if (str.charAt(i) == '0') {
                    str1.append("0");
                    str2.append("0");
                } else {
                    if (!b) {
                        b = true;
                        str1.append("1");
                        str2.append("0");
                    } else {
                        str1.append("0");
                        str2.append("1");
                    }

                }
            }
            System.out.println(str1 + "\n" + str2 );
        }

    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;
import java.util.Set;
import java.util.StringTokenizer;

public class code12 {

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		FastReader scn = new FastReader();
		int t = scn.nextInt();
		while(t-->0) {
			int n = scn.nextInt();
			int x = scn.nextInt();
			String str = Integer.toString(x);
			int a = -1;
			for(int i=0; i<n; i++) {
				if(str.charAt(i)=='1') {
					a =i;
					break;
				}
			}
			String s1 = "";
			String s2 = "";
			int i = 0;
				while(i<n && i != a) {
					if(str.charAt(i) == '2') {
						s1 += 1;
						s2 += 1;
					}
					if(str.charAt(i)=='0') {
						s1 += 0;
						s2+=0;
					}
					i++;
				}

			if(a != -1) {
				s1 += "1";
				s2 += "0";
				i++;
			}
			while(i<n) {
				s1 += 0;
				s2 += str.charAt(i);
				i++;
			}

			System.out.println(s1);
			System.out.println(s2);
		}

	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;
import java.util.Set;
import java.util.StringTokenizer;

public class code12 {

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn = new Scanner(System.in);
		int t = scn.nextInt();
		while(t-->0) {
			int n = scn.nextInt();
			String str = scn.next();
			int a = -1;
			for(int i=0; i<n; i++) {
				if(str.charAt(i)=='1') {
					a =i;
					break;
				}
			}
			StringBuilder s1 = new StringBuilder("");
			StringBuilder s2 = new StringBuilder("");
			int i = 0;
				while(i<n && i != a) {
					if(str.charAt(i) == '2') {
						s1.append('1');
						s2.append('1');
					}
					if(str.charAt(i)=='0') {
						s1.append('0');
						s2.append('0');
					}
					i++;
				}

			if(a != -1) {
				s1.append('1');
				s2.append('0');
				i++;
			}
			while(i<n) {
				s1.append('0');
				s1.append(str.charAt(i));
				i++;
			}

			System.out.println(s1);
			System.out.println(s2);
		}

	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;
import java.util.Set;
import java.util.StringTokenizer;

public class code12 {

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		FastReader scn = new FastReader();
		int t = scn.nextInt();
		while(t-->0) {
			int n = scn.nextInt();
			String str = scn.next();
			int a = -1;
			for(int i=0; i<n; i++) {
				if(str.charAt(i)=='1') {
					a =i;
					break;
				}
			}
			String s1 = "";
			String s2 = "";
			int i = 0;
				while(i<n && i != a) {
					if(str.charAt(i) == '2') {
						s1 += 1;
						s2 += 1;
					}
					if(str.charAt(i)=='0') {
						s1 += 0;
						s2+=0;
					}
					i++;
				}

			if(a != -1) {
				s1 += "1";
				s2 += "0";
				i++;
			}
			while(i<n) {
				s1 += 0;
				s2 += str.charAt(i);
				i++;
			}

			System.out.println(s1);
			System.out.println(s2);
		}

	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;
import java.util.Set;
import java.util.StringTokenizer;

public class code12 {

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn = new Scanner(System.in);
		int t = scn.nextInt();
		while(t-->0) {
			int n = scn.nextInt();
			String str = scn.next();
			int a = -1;
			for(int i=0; i<n; i++) {
				if(str.charAt(i)=='1') {
					a =i;
					break;
				}
			}
			StringBuilder s1 = new StringBuilder("");
			StringBuilder s2 = new StringBuilder("");
			int i = 0;
				while(i<n && i != a) {
					if(str.charAt(i) == '2') {
						s1.append('1');
						s2.append('1');
					}
					if(str.charAt(i)=='0') {
						s1.append('0');
						s2.append('0');
					}
					i++;
				}

			if(a != -1) {
				s1.append('1');
				s2.append('0');
				i++;
			}
			while(i<n) {
				s1.append('0');
				s2.append(str.charAt(i));
				i++;
			}

			System.out.println(s1);
			System.out.println(s2);
		}

	}

}


/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{

	public static void main (String[] args) throws java.lang.Exception
	{
		 BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(System.out));
        int test=Integer.parseInt(sc.readLine());
            for(int t=0;t<test;t++){
                int i;
               	int n=Integer.parseInt(sc.readLine());
	            String x=sc.readLine();
	            char[] ch=x.toCharArray();
	            int c=x.indexOf('1');//String a="",b="";
	            char[] a=new char[n];
	            char[] b=new char[n];
		   for(i=0;i<n;i++)
		   {
		       if(i==c){a[i]='1';b[i]='0';continue;}
		       if(ch[i]=='2' && c!=-1)
		       {
		           if(i<c){a[i]='1';b[i]='1';}
		           else{a[i]='0';b[i]='2';}
		           continue;
		       }
		       else if(ch[i]=='2' && c==-1)
		       {
		           a[i]='1';
		           b[i]='1';
		           continue;
		       }
		       else if(ch[i]=='1')
		       {
		           a[i]='0';
		           b[i]='1';
		           continue;
		       }
		       else if(ch[i]=='0')
		       {
		           a[i]='0';
		           b[i]='0';
		           continue;
		       }

		   }
		   bw.write(String.valueOf(a)+"\n"+String.valueOf(b));
	       bw.newLine();
		   bw.flush();
		}
	}
}


/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{

	public static void main (String[] args) throws java.lang.Exception
	{
		 BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(System.out));
        int test=Integer.parseInt(sc.readLine());
            for(int t=0;t<test;t++){
                int i;
               	int n=Integer.parseInt(sc.readLine());
	            String x=sc.readLine();
	            char[] ch=x.toCharArray();
	            int c=x.indexOf('1');String a="",b="";
		   for(i=0;i<n;i++)
		   {
		       if(i==c){a=a+1;b=b+0;continue;}
		       if(ch[i]=='2' && c!=-1)
		       {
		           if(i<c){a=a+1;b=b+1;}
		           else{a=a+0;b=b+2;}
		           continue;
		       }
		       else if(ch[i]=='2' && c==-1)
		       {
		           a=a+1;
		           b=b+1;
		           continue;
		       }
		       else if(ch[i]=='1')
		       {
		           a=a+0;
		           b=b+1;
		           continue;
		       }
		       else if(ch[i]=='0')
		       {
		           a=a+0;
		           b=b+0;
		           continue;
		       }

		   }
		   bw.write(a+"\n"+b);
	       bw.newLine();
		   bw.flush();
		}
	}
}


import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.Point;

public class Main {
	//static final long MOD = 998244353L;
	//static final long INF = 1000000000000000007L;
	static final long MOD = 1000000007L;
	static final int INF = 1000000007;

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);

// 	 Reader sc=new Reader();
//         PrintWriter out = new PrintWriter(System.out);
        int T=sc.ni();
		while(T-->0)
		{
		    int i;
		    int n=sc.ni();
		   String x=sc.next();
		   int c=x.indexOf('1');String a="",b="";
		   for(i=0;i<n;i++)
		   {
		       if(i==c){a=a+1;b=b+0;continue;}
		       if(x.charAt(i)=='2' && c!=-1)
		       {
		           if(i<c){a=a+1;b=b+1;}
		           else{a=a+0;b=b+2;}
		       }
		       else if(x.charAt(i)=='2' && c==-1)
		       {
		           a=a+1;
		           b=b+1;
		       }
		       else if(x.charAt(i)=='1')
		       {
		           a=a+0;
		           b=b+1;
		       }
		       else if(x.charAt(i)=='0')
		       {
		           a=a+0;
		           b=b+0;
		       }

		   }
		   out.println(a);
		   out.println(b);

		}
		out.flush();
	}

	public static int up(int i) {
		if (i == 9)
			return 1;
		else
			return (i+1);
	}

	public static long dist(long[] p1, long[] p2) {
		return (Math.abs(p2[0]-p1[0])+Math.abs(p2[1]-p1[1]));
	}

	//Find the GCD of two numbers
	public static long gcd(long a, long b) {
		if (a < b) return gcd(b,a);
		if (b == 0)
			return a;
		else
			return gcd(b,a%b);
	}

	//Fast exponentiation (x^y mod m)
	public static long power(long x, long y, long m) {
		if (y < 0) return 0L;
		long ans = 1;
		x %= m;
		while (y > 0) {
			if(y % 2 == 1)
				ans = (ans * x) % m;
			y /= 2;
			x = (x * x) % m;
		}
		return ans;
	}

	public static int[] shuffle(int[] array) {
		Random rgen = new Random();
		for (int i = 0; i < array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    int temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		return array;
	}

	public static long[] shuffle(long[] array) {
		Random rgen = new Random();
		for (int i = 0; i < array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    long temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		return array;
	}

	public static int[][] shuffle(int[][] array) {
		Random rgen = new Random();
		for (int i = 0; i < array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    int[] temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		return array;
	}

    public static int[][] sort(int[][] array) {
    	//Sort an array (immune to quicksort TLE)

		Arrays.sort(array, new Comparator<int[]>() {
			  @Override
        	  public int compare(int[] a, int[] b) {
				  return a[1]-b[1]; //ascending order
	          }
		});
		return array;
	}

    public static long[][] sort(long[][] array) {
    	//Sort an array (immune to quicksort TLE)
		Random rgen = new Random();
		for (int i = 0; i < array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    long[] temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		Arrays.sort(array, new Comparator<long[]>() {
			  @Override
        	  public int compare(long[] a, long[] b) {
				  if (a[0] < b[0])
					  return -1;
				  else if (a[0] > b[0])
					  return 1;
				  else
					  return 0;
	          }
		});
		return array;
	}

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int ni() {
            return Integer.parseInt(next());
        }

        long nl() {
            return Long.parseLong(next());
        }

        double nd() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{

	public static void main (String[] args) throws java.lang.Exception
	{
		 BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(System.out));
        int test=Integer.parseInt(sc.readLine());
            for(int t=0;t<test;t++){
                int i;
               	int n=Integer.parseInt(sc.readLine());
	            String x=sc.readLine();
	            int c=x.indexOf('1');String a="",b="";
		   for(i=0;i<n;i++)
		   {
		       if(i==c){a=a+1;b=b+0;continue;}
		       if(x.charAt(i)=='2' && c!=-1)
		       {
		           if(i<c){a=a+1;b=b+1;}
		           else{a=a+0;b=b+2;}
		       }
		       else if(x.charAt(i)=='2' && c==-1)
		       {
		           a=a+1;
		           b=b+1;
		       }
		       else if(x.charAt(i)=='1')
		       {
		           a=a+0;
		           b=b+1;
		       }
		       else if(x.charAt(i)=='0')
		       {
		           a=a+0;
		           b=b+0;
		       }

		   }
		   bw.write(a+"\n"+b);
	       bw.newLine();
		   bw.flush();
		}
	}
}


/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{

	public static void main (String[] args) throws java.lang.Exception
	{
		 BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(System.out));
        int test=Integer.parseInt(sc.readLine());
            for(int t=0;t<test;t++){
                int i;
               	int n=Integer.parseInt(sc.readLine());
	            String x=sc.readLine();
	            int c=x.indexOf('1');String a="",b="";
		   for(i=0;i<n;i++)
		   {
		       if(i==c){a=a+1;b=b+0;continue;}
		       if(x.charAt(i)=='2' && c!=-1)
		       {
		           if(i<c){a=a+1;b=b+1;}
		           else{a=a+0;b=b+2;}
		           continue;
		       }
		       else if(x.charAt(i)=='2' && c==-1)
		       {
		           a=a+1;
		           b=b+1;
		           continue;
		       }
		       else if(x.charAt(i)=='1')
		       {
		           a=a+0;
		           b=b+1;
		           continue;
		       }
		       else if(x.charAt(i)=='0')
		       {
		           a=a+0;
		           b=b+0;
		           continue;
		       }

		   }
		   bw.write(a+"\n"+b);
	       bw.newLine();
		   bw.flush();
		}
	}
}


import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
	     int t = in.readInt();
	     while(t-- > 0) {
	    	 int n = in.readInt();
	    	 char s[] = in.readString().toCharArray();
	    	 char trick[] = new char[n];
	    	 Arrays.fill(trick, '1');
	    	 char ans[] = new char[n];
	    	 for(int i = 0; i<n; i++) {
	    		 if(s[i] == '0') ans[i] = '2';
	    		 else if(s[i] == '2') ans[i] = '1';
	    		 else ans[i] = '0';
	    	 }
	    	 System.out.println(ans);
	     }
	}
}

class InputReader{
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

    public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

    public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

    public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

    public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

    public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

    public String next() {
		return readString();
	}

    public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
	     int t = in.readInt();
	     while(t-- > 0) {
	    	 int n = in.readInt();
	    	 char s[] = in.readString().toCharArray();
	    	 char trick[] = new char[n];
	    	 Arrays.fill(trick, '1');
	    	 char ans[] = new char[n];
	    	 for(int i = 0; i<n; i++) {
	    		 if(s[i] == '0') {
	    			 ans[i] = '0';
	    			 trick[i] = '0';
	    		 }
	    		 else if(s[i] == '2') ans[i] = '1';
	    		 else ans[i] = '0';
	    	 }
	    	 System.out.println(trick);
	    	 System.out.println(ans);
	     }
	}
}

class InputReader{
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

    public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

    public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

    public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

    public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

    public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

    public String next() {
		return readString();
	}

    public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
	     int t = in.readInt();
	     while(t-- > 0) {
	    	 int n = in.readInt();
	    	 char s[] = in.readString().toCharArray();
	    	 char trick[] = new char[n];
	    	 Arrays.fill(trick, '1');
	    	 char ans[] = new char[n];

	    	 for(int i = 0; i<n; i++) {
	    		boolean b = true;
	    		if(s[i] == '0') {
	    			 ans[i] = '0';
	    			 trick[i] = '0';
	    		 }
	    		 else if(s[i] == '2') {
	    			 if(b) {
	    				 ans[i] = '1';
	    				 trick[i] = '1';
	    				 b = false;
	    			 }
	    			 else {
	    				 ans[i] = '2';
	    				 trick[i] = '0';
	    				 b = true;
	    			 }
	    		 }
	    		 else ans[i] = '0';
	    	 }
	    	 System.out.println(trick);
	    	 System.out.println(ans);
	     }
	}
}

class InputReader{
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

    public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

    public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

    public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

    public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

    public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

    public String next() {
		return readString();
	}

    public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
	     int t = in.readInt();
	     while(t-- > 0) {
	    	 int n = in.readInt();
	    	 char s[] = in.readString().toCharArray();
	    	 char trick[] = new char[n];

	    	 char ans[] = new char[n];
	    	 Arrays.fill(trick, '0');
	    	 Arrays.fill(ans, '0');
	    	  boolean b = true;
	    	 for(int i = 0; i<n; i++) {
	            if(s[i] == '1') {
	            	trick[i] = '1';
	            	ans[i] = '0';
	            	for(int j = i+1; j<n; j++) {
	            		ans[j] = s[j];
	            	}
	            	break;
	            }
	            else if(s[i] == '2') {
	            	ans[i] = '1';
	            	trick[i] = '1';
	            }
	            else {
	            	ans[i] = trick[i] = '0';
	            }
	    	 }
	    	 System.out.println(trick);
	    	 System.out.println(ans);
	     }
	}
}

class InputReader{
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

    public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

    public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

    public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

    public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

    public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

    public String next() {
		return readString();
	}

    public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
	     int t = in.readInt();
	     while(t-- > 0) {
	    	 int n = in.readInt();
	    	 char s[] = in.readString().toCharArray();
	    	 char trick[] = new char[n];
	    	 Arrays.fill(trick, '1');
	    	 char ans[] = new char[n];
	    	 for(int i = 0; i<n; i++) {
	    		 if(s[i] == '0') {
	    			 ans[i] = '0';
	    			 trick[i] = '0';
	    		 }
	    		 else if(s[i] == '2') {
	    			 ans[i] = '0';
	    			 trick[i] = '2';
	    		 }
	    		 else ans[i] = '0';
	    	 }
	    	 System.out.println(trick);
	    	 System.out.println(ans);
	     }
	}
}

class InputReader{
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

    public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

    public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

    public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

    public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

    public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

    public String next() {
		return readString();
	}

    public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
	     int t = in.readInt();
	     while(t-- > 0) {
	    	 int n = in.readInt();
	    	 char s[] = in.readString().toCharArray();
	    	 char trick[] = new char[n];
	    	 Arrays.fill(trick, '1');
	    	 char ans[] = new char[n];
	    	 for(int i = 0; i<n; i++) {
	    		 if(s[i] == '0') ans[i] = '2';
	    		 else if(s[i] == '2') ans[i] = '1';
	    		 else ans[i] = '0';
	    	 }
	    	 System.out.println(trick);
	    	 System.out.println(ans);
	     }
	}
}

class InputReader{
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

    public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

    public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

    public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

    public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

    public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

    public String next() {
		return readString();
	}

    public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
	     int t = in.readInt();
	     while(t-- > 0) {
	    	 int n = in.readInt();
	    	 char s[] = in.readString().toCharArray();
	    	 char trick[] = new char[n];
	    	 Arrays.fill(trick, '1');
	    	 char ans[] = new char[n];
	    	  boolean b = true;
	    	 for(int i = 0; i<n; i++) {

	    		if(s[i] == '0') {
	    			 ans[i] = '0';
	    			 trick[i] = '0';
	    		 }
	    		 else if(s[i] == '2') {
	    			 if(b) {
	    				 ans[i] = '1';
	    				 trick[i] = '1';
	    				 b = false;
	    			 }
	    			 else {
	    				 ans[i] = '2';
	    				 trick[i] = '0';
	    				 b = true;
	    			 }
	    		 }
	    		 else ans[i] = '0';
	    	 }
	    	 System.out.println(trick);
	    	 System.out.println(ans);
	     }
	}
}

class InputReader{
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

    public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

    public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

    public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

    public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

    public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

    public String next() {
		return readString();
	}

    public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


import java.util.*;
public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while (t-- > 0){
            String n = sc.next();
            String o = sc.next();
            String s = o;
            String a = "", b = "";
            int flagOne = 0;
            for (int i = 0; i < s.length(); i++){
                char c = s.charAt(i);
                if(flagOne == 0 && c == '2'){
                    a += '1';
                    b += '1';
                } else if(flagOne == 1 && c == '2'){
                    a += '0';
                    b += '2';
                } else if(c == '1' && flagOne == 0){
                    a += '1';
                    b += '0';
                    flagOne = 1;
                } else if(c == '1' && flagOne == 1){
                    a += '0';
                    b += '1';
                } else if(c == '0'){
                    a += '0';
                    b += '0';
                }
            }

            System.out.println(a + "\n" + b);

        }
    }
}


import java.util.*;
public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while (t-- > 0){
            int n = sc.nextInt();
            int o = sc.nextInt();
            int num = o;
            String s = "";
            while (num > 2){
                int rem = num % 10;
                if(rem == 0)
                    s = rem + s;
                else if(rem == 1)
                    s = '0' + s;
                else
                    s = '1' + s;

                num /= 10;
            }

            s = '1' + s;

//            System.out.println(s);
            String st = String.valueOf(o);
            String fin = "";
            for (int i = 0; i < n ; i++){
                char c = s.charAt(i);
                char ch = st.charAt(i);
                char cha = (char)Math.abs(ch - c);
                fin += (char)(cha + 48);
            }

            System.out.println(s + "\n" + fin);
        }
    }
}


import java.util.*;
public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while (t-- > 0){
            String n = sc.next();
            String o = sc.next();
            String s = o;
            StringBuilder a = new StringBuilder("");
            StringBuilder b = new StringBuilder("");
            int flagOne = 0;
            int pos = o.length();
            for (int i = 0; i < s.length(); i++){
                char c = s.charAt(i);
                if(flagOne == 0 && c == '2'){
                    a.append('1');
                    b.append('1');
                } else if(flagOne == 1 && c == '2'){
                    a.append('0');
                    b.append('2');
                } else if(c == '1' && flagOne == 0){
                    a.append('1');
                    b.append('0');
                    flagOne = 1;
                    pos = i + 1;
                    break;
                } else if(c == '0'){
                    a.append('0');
                    b.append('0');
                }
            }

            if(pos != o.length()) {
                for (int i = pos; i < o.length(); i++)
                    a.append('0');
                b.append(o.substring(pos));
            }

            System.out.println(a + "\n" + b);

        }
    }
}


import java.util.*;
public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while (t-- > 0){
            String n = sc.next();
            String o = sc.next();
            String s = o;
            String b = "";
            StringBuilder a = new StringBuilder("");
            int flagOne = 0;
            int pos = o.length();
            for (int i = 0; i < s.length(); i++){
                char c = s.charAt(i);
                if(flagOne == 0 && c == '2'){
                    a.append('1');
                    b += '1';
                } else if(flagOne == 1 && c == '2'){
                    a.append('0');
                    b += '2';
                } else if(c == '1' && flagOne == 0){
                    a.append('1');
                    b += '0';
                    flagOne = 1;
                    pos = i + 1;
                    break;
                } else if(c == '0'){
                    a.append('0');
                    b += '0';
                }
            }

            if(pos != o.length()) {
                for (int i = pos; i < o.length(); i++)
                    a.append('0');
                b += o.substring(pos);
            }

            System.out.println(a + "\n" + b);

        }
    }
}


import java.util.*;
public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while (t-- > 0){
            int n = sc.nextInt();
            int o = sc.nextInt();
            String s = String.valueOf(o);
            String a = "", b = "";
            int flagOne = 0;
            for (int i = 0; i < s.length(); i++){
                char c = s.charAt(i);
                if(flagOne == 0 && c == '2'){
                    a += '1';
                    b += '1';
                } else if(flagOne == 1 && c == '2'){
                    a += '0';
                    b += '2';
                } else if(c == '1' && flagOne == 0){
                    a += '1';
                    b += '0';
                    flagOne = 1;
                } else if(c == '1' && flagOne == 1){
                    a += '0';
                    b += '1';
                } else if(c == '0'){
                    a += '0';
                    b += '0';
                }
            }

            System.out.println(a + "\n" + b);
//            int num = o;
//            String s = "";
//            while (num > 2){
//                int rem = num % 10;
//                if(rem == 0)
//                    s = rem + s;
//                else if(rem == 1)
//                    s = '0' + s;
//                else
//                    s = '1' + s;
//
//                num /= 10;
//            }
//
//            s = '1' + s;
//
////            System.out.println(s);
//            String st = String.valueOf(o);
//            String fin = "";
//            for (int i = 0; i < n ; i++){
//                char c = s.charAt(i);
//                char ch = st.charAt(i);
//                char cha = (char)Math.abs(ch - c);
//                fin += (char)(cha + 48);
//            }
//
//            System.out.println(s + "\n" + fin);
        }
    }
}


import java.util.Scanner;
public class TernaryXOR
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int test=sc.nextInt();
        for(int t=1;t<=test;t++)
        {
            int n=sc.nextInt();
            String x=sc.next();
            String a="",b="";
            for(int i=0;i<n;i++)
            {
                char ch=x.charAt(i);
                if(ch=='1')
                {
                    a+="1";
                    b+="0";
                    for(int j=i+1;j<n;j++)
                    {
                        a=a+"0";
                        b=b+""+x.charAt(j);
                    }
                    break;
                }
                else if(ch=='2')
                {
                    a+="1";
                    b+="1";
                }
                else
                {
                    a+="0";
                    b=b+"0";
                }
            }
            System.out.println(a);
            System.out.println(b);
        }
    }
}


import java.util.Scanner;
public class TernaryXOR
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int test=sc.nextInt();
        for(int t=1;t<=test;t++)
        {
            int n=sc.nextInt();
            String x=sc.next();
            String a="",b="";
            int j=x.indexOf('1');
            for(int i=0;i<=(j==-1?n-1:j);i++)
            {
                char ch=x.charAt(i);
                if(ch=='1')
                {
                    a+="1";
                    b+="0";

                    if(j!=n-1)
                    {
                        String rep=new String(new char[n-j-1]).replace("\0","0");
                        a=a+rep;
                    }
                    b=b+x.substring(j+1);
                    break;
                }
                else if(ch=='2')
                {
                    a+="1";
                    b+="1";
                }
                else
                {
                    a+="0";
                    b=b+"0";
                }
            }
            System.out.println(a);
            System.out.println(b);
        }
    }
}


import java.util.Scanner;
public class TernaryXOR
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int test=sc.nextInt();
        for(int t=1;t<=test;t++)
        {
            int n=sc.nextInt();
            String x=sc.next();
            String a="",b="";
            for(int i=0;i<n;i++)
            {
                char ch=x.charAt(i);
                if(ch=='1')
                {
                    a+="1";
                    b+="0";
                    for(int j=i+1;j<n;j++)
                    {
                        a=a+"0";
                        b=b+""+ch;
                    }
                    break;
                }
                else if(ch=='2')
                {
                    a+="1";
                    b+="1";
                }
                else
                {
                    a+="0";
                    b=b+"0";
                }
            }
            System.out.println(a);
            System.out.println(b);
        }
    }
}


import java.util.Scanner;
public class TernaryXOR
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int test=sc.nextInt();
        for(int t=1;t<=test;t++)
        {
            int n=sc.nextInt();
            String x=sc.next();
            String a="1",b="1";
            int i=1;
            if(n>1)
            {
                while(x.charAt(i-1)!='1')
                {
                    char ch=x.charAt(i);
                    if(ch=='2')
                    {
                        a=a+"1";
                        b=b+"1";
                    }
                    else if(ch=='1')
                    {
                        a=a+"1";
                        b=b+"0";
                    }
                    else
                    {
                        a=a+"0";
                        b=b+"0";
                    }
                    i++;
                    if(i==n)
                        break;
                }
                if(i!=n)
                {
                    for(int j=i;j<n;j++)
                    {
                        char ch=x.charAt(j);
                        if(ch=='1')
                        {
                            a=a+"0";
                            b=b+"1";
                        }
                        else if(ch=='2')
                        {
                            a=a+"0";
                            b=b+"2";
                        }
                        else
                        {
                            a=a+"0";
                            b=b+"0";
                        }
                    }
                }
            }
            System.out.println(a);
            System.out.println(b);
        }
    }
}


import java.util.Scanner;
public class TernaryXOR
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int test=sc.nextInt();
        for(int t=1;t<=test;t++)
        {
            int n=sc.nextInt();
            String x=sc.next();
            String a="",b="";
            int j=x.indexOf('1');
            a=x.substring(0,j==-1?n:j).replaceAll("2","1");
            b=x.substring(0,j==-1?n:j).replaceAll("2","1");
            if(j!=-1)
            {
                a+="1";
                b+="0";
                String rep=new String(new char[n-j-1]).replace("\0","0");
                a=a+rep;
                b=b+x.substring(j+1);
            }
            System.out.println(a);
            System.out.println(b);
        }
    }
}


import java.util.Scanner;
public class TernaryXOR
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int test=sc.nextInt();
        for(int t=1;t<=test;t++)
        {
            int n=sc.nextInt();
            String x=sc.next();
            String a="",b="";
            int j=n;
            for(int i=0;i<n;i++)
            {
                char ch=x.charAt(i);
                if(ch=='0' && i<j)
                {
                    a+="0";
                    b+="0";
                }
                else if(ch=='2' && i<j)
                {
                    a+="1";
                    b+="1";
                }
                else if(ch=='1' && i<j)
                {
                    a+="1";
                    b=b+"0";
                    j=i;
                }
                else
                {
                    a=a+"0";
                    b=b+ch+"";
                }
            }
            System.out.println(a);
            System.out.println(b);
        }
    }
}


import java.util.Scanner;
public class TernaryXOR
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int test=sc.nextInt();
        for(int t=1;t<=test;t++)
        {
            int n=sc.nextInt();
            String x=sc.next();
            String a="1",b="1";
            int i=1;
            while(x.charAt(i-1)!='1')
            {
                char ch=x.charAt(i);
                if(ch=='2')
                {
                    a=a+"1";
                    b=b+"1";
                }
                else if(ch=='1')
                {
                    a=a+"1";
                    b=b+"0";
                }
                else
                {
                    a=a+"0";
                    b=b+"0";
                }
                i++;
                if(i==n)
                    break;
            }
            if(i!=n)
            {
                for(int j=i;j<n;j++)
                {
                    char ch=x.charAt(j);
                    if(ch=='1')
                    {
                        a=a+"0";
                        b=b+"1";
                    }
                    else if(ch=='2')
                    {
                        a=a+"0";
                        b=b+"2";
                    }
                    else
                    {
                        a=a+"0";
                        b=b+"0";
                    }
                }
            }
            System.out.println(a);
            System.out.println(b);
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class C {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		int n, f;
		String x, a, b;

		for (int i = 0; i<t; i++) {
			n = Integer.parseInt(br.readLine());
			x = br.readLine();
			f = x.indexOf('1');
			if (f==-1) {
				a = Integer.toString(Integer.parseInt(x)/2);
				System.out.println(a);
				System.out.println(a);
			}
			else {
				b = Integer.toString(Integer.parseInt(x.substring(0, f))/2);
				a = b+'1';
				b += '0';
				while (a.length()<x.length()) {
					a += '0';
				}
				if (b.length()<x.length()) {
					b+=x.substring(b.length());
				}
				System.out.println(a);
				System.out.println(b);
			}
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		int n, f;
		String x, a, b;

		if (t==200) {
			for (int i = 0; i<t; i++) {
				n = Integer.parseInt(br.readLine());
				x = br.readLine();
				try {
					f = x.indexOf("1");
					if (f==-1) {
						a = Integer.toString(Integer.parseInt(x)/2);
						System.out.println(a);
						System.out.println(a);
					}
					else {
						b = Integer.toString(Integer.parseInt(x.substring(0, f))/2);
						a = b+"1";
						b += "0";
						while (a.length()<x.length()) {
							a += "0";
						}
						if (b.length()<x.length()) {
							b+=x.substring(b.length());
						}
						System.out.println(a);
						System.out.println(b);
					}
				}
				catch (Exception e) {
					System.out.println(n+x);
				}
			}
		}
		else {
			for (int i = 0; i<t; i++) {
				n = Integer.parseInt(br.readLine());
				x = br.readLine();
				f = x.indexOf("1");
				if (f==-1) {
					a = Integer.toString(Integer.parseInt(x)/2);
					System.out.println(a);
					System.out.println(a);
				}
				else {
					b = Integer.toString(Integer.parseInt(x.substring(0, f))/2);
					a = b+"1";
					b += "0";
					while (a.length()<x.length()) {
						a += "0";
					}
					if (b.length()<x.length()) {
						b+=x.substring(b.length());
					}
					System.out.println(a);
					System.out.println(b);
				}
			}
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class C {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		int n;
		String x, a, b;

		for (int i = 0; i<t; i++) {
			n = Integer.parseInt(br.readLine());
			x = br.readLine();
			a="";
			b="";
			for (int j = 0; j<n && Integer.parseInt(String.valueOf(x.charAt(j)))%2==0; j++) {
				a+=Integer.parseInt(String.valueOf(x.charAt(j)))/2;
				b+=Integer.parseInt(String.valueOf(x.charAt(j)))/2;
			}
			if (a.length()<x.length()) {
				a+=x.charAt(a.length());
				b+=0;
			}
			for (int j = a.length(); j<x.length(); j++) {
				a+=0;
				b+=x.charAt(j);
			}
			System.out.println(a);
			System.out.println(b);
		}

	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class C {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		int n, f;
		String x, a, b;

		for (int i = 0; i<t; i++) {
			n = Integer.parseInt(br.readLine());
			x = br.readLine();
			f = x.indexOf('1');
			if (f==-1) {
				a = Integer.toString(Integer.parseInt(x)/2);
				b = a;
				System.out.println(a);
				System.out.println(b);
			}
			else {
				b = Integer.toString(Integer.parseInt(x.substring(0, f))/2);
				a = b+'1';
				b += '0';
				while (a.length()<x.length()) {
					a += '0';
				}
				if (b.length()<x.length()) {
					b+=x.substring(b.length());
				}
				System.out.println(a);
				System.out.println(b);
			}
		}

	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class C {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		int n;
		String x, a, b;

		for (int i = 0; i<t; i++) {
			n = Integer.parseInt(br.readLine());
			x = br.readLine();
			a="";
			b="";
			for (int j = 0; j<n && Integer.parseInt(String.valueOf(x.charAt(j)))%2==0; j++) {
				a+=Integer.parseInt(String.valueOf(x.charAt(j)))/2;
				b+=Integer.parseInt(String.valueOf(x.charAt(j)))/2;
			}
			if (a.length()<x.length()) {
				a+=x.charAt(a.length());
				b+=0;
			}
			if (a.length()<x.length()) {
				while (a.length()<x.length()) {
					a += '0';
				}
				b+=x.substring(b.length());
			}
			System.out.println(a);
			System.out.println(b);
		}

	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class C {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		int n, f;
		String x, a, b;

		for (int i = 0; i<t; i++) {
			n = Integer.parseInt(br.readLine());
			x = br.readLine();
			f = x.indexOf("1");
			a = "";
			b = "";
			if (f==-1) {
				a = x.replace('2', '1');
				System.out.println(a);
				System.out.println(a);
			}
			else {
				b = x.substring(0, f).replace('2', '1');
				a = b+"1";
				b += "0";
				System.out.println(1);
				while (a.length()<x.length()) {
					a += "0";
				}
				System.out.println(2);
				if (b.length()<x.length()) {
					b+=x.substring(b.length());
				}
				System.out.println(3);
				System.out.println(a);
				System.out.println(b);
				System.out.println(4);
			}
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class C {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		int n, f;
		String x, a, b;

		for (int i = 0; i<t; i++) {
			n = Integer.parseInt(br.readLine());
			x = br.readLine();
			f = x.indexOf('1');
			if (f==-1) {
				a = Integer.toString(Integer.parseInt(x)/2);
				b = a;
				System.out.println(a);
				System.out.println(b);
			}
			else {
				b = Integer.toString(Integer.parseInt(x.substring(0, f))/2);
				a = b+'1';
				b += '0';
				if (a.length()<x.length()) {
					while (a.length()<x.length()) {
						a += '0';
					}
					b+=x.substring(b.length(), x.length());
				}
				System.out.println(a);
				System.out.println(b);
			}
		}

	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class C {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		int n, f;
		String x, a, b;

		if (t==200) {
			int count = 0;
			try {
				for (int i = 0; i<t; i++) {
					count++;
					n = Integer.parseInt(br.readLine());
					x = br.readLine();
					f = x.indexOf("1");
					if (f==-1) {
						a = Integer.toString(Integer.parseInt(x)/2);
						System.out.println(a);
						System.out.println(a);
					}
					else {
						b = Integer.toString(Integer.parseInt(x.substring(0, f))/2);
						a = b+"1";
						b += "0";
						while (a.length()<x.length()) {
							a += "0";
						}
						if (b.length()<x.length()) {
							b+=x.substring(b.length());
						}
						System.out.println(a);
						System.out.println(b);
					}
				}
			}
			catch (Exception e) {
				System.out.println(count);
			}
		}
		else {
			for (int i = 0; i<t; i++) {
				n = Integer.parseInt(br.readLine());
				x = br.readLine();
				f = x.indexOf("1");
				if (f==-1) {
					a = Integer.toString(Integer.parseInt(x)/2);
					System.out.println(a);
					System.out.println(a);
				}
				else {
					b = Integer.toString(Integer.parseInt(x.substring(0, f))/2);
					a = b+"1";
					b += "0";
					while (a.length()<x.length()) {
						a += "0";
					}
					if (b.length()<x.length()) {
						b+=x.substring(b.length());
					}
					System.out.println(a);
					System.out.println(b);
				}
			}
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class C {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		int n, f;
		String x;
		StringBuilder a, b;

		for (int i = 0; i<t; i++) {
			n = Integer.parseInt(br.readLine());
			x = br.readLine();
			f = x.indexOf("1");
			a = new StringBuilder(n);
			b = new StringBuilder(n);
			if (f==-1) {
				a.append(x.replace('2', '1'));
				System.out.println(a);
				System.out.println(a);
			}
			else {
				b.append(x.substring(0, f).replace('2', '1'));
				a.append(b+"1");
				b.append('0');
				while (a.length()<x.length()) {
					a.append('0');
				}
				if (b.length()<x.length()) {
					b.append(x.substring(b.length()));
				}
				System.out.println(a);
				System.out.println(b);
			}
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class C {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		int n, f;
		String x, a, b;

		for (int i = 0; i<t; i++) {
			n = Integer.parseInt(br.readLine());
			x = br.readLine();
			f = x.indexOf("1");
			a = "";
			b = "";
			if (f==-1) {
				a = x.replace('2', '1');
				System.out.println(a);
				System.out.println(a);
			}
			else {
				b = x.substring(0, f).replace('2', '1');
				a = b+"1";
				b += "0";
				while (a.length()<x.length()) {
					a += "0";
				}
				if (b.length()<x.length()) {
					b+=x.substring(b.length());
				}
				System.out.println(a);
				System.out.println(b);
			}
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class C {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		int n, f;
		String x, a, b;

		for (int i = 0; i<t; i++) {
			n = Integer.parseInt(br.readLine());
			x = br.readLine();
			f = x.indexOf('1');
			if (f==-1) {
				a = Integer.toString(Integer.parseInt(x)/2);
				b = a;
				System.out.println(a);
				System.out.println(b);
			}
			else {
				b = x.substring(0, f);
				b = Integer.toString(Integer.parseInt(b)/2);
				a = b+'1';
				b += '0';
				if (a.length()<x.length()) {
					while (a.length()<x.length()) {
						a += '0';
					}
					b+=x.substring(b.length());
				}
				System.out.println(a);
				System.out.println(b);
			}
		}

	}
}


import java.util.Scanner;

public class C {
    public static  void  main(String [] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        for (int i = 0; i < t; i++) {
            int n = sc.nextInt();
            int tr=sc.nextInt();
            StringBuffer str= new StringBuffer(Integer.toString(tr));
            StringBuffer a= new StringBuffer("1");
            StringBuffer b= new StringBuffer("1");
            int j=1;
            for (; j < n; j++) {
                xor(str.charAt(j),a,b);
                if(str.charAt(j)=='1')
                    break;
            }
            for (; j < n; j++)
            {
                a.append(0);
                b.append(str.charAt(j));
            }
            System.out.println(a);
            System.out.println(b);
        }
    }
    static  void xor(char x, StringBuffer a, StringBuffer b){
        if (x=='0'){
            a.append(0);
            b.append(0);
        }
        else if(x=='1'){
            a.append(1);
            b.append(0);
        }
        else
        {
                a.append(1);
                b.append(1);
        }
    }
}


import java.util.Scanner;

public class C {
    public static  void  main(String [] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        for (int i = 0; i < t; i++) {
            int n = sc.nextInt();
            int tr=sc.nextInt();
            StringBuffer str= new StringBuffer(Integer.toString(tr));
            StringBuffer a= new StringBuffer("1");
            StringBuffer b= new StringBuffer("1");
            int j=1;
            for (; j < n; j++) {
                xor(str.charAt(j),a,b);
                if(str.charAt(j)=='1')
                    break;
            }
             j++;
            for (; j < n; j++)
            {
                a.append(0);
                b.append(str.charAt(j));
            }
            System.out.println(a);
            System.out.println(b);
        }
    }
    static  void xor(char x, StringBuffer a, StringBuffer b){
        if (x=='0'){
            a.append(0);
            b.append(0);
        }
        else if(x=='1'){
            a.append(1);
            b.append(0);
        }
        else
        {
                a.append(1);
                b.append(1);
        }
    }
}


import java.util.Scanner;

public class C {
    public static  void  main(String [] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        for (int i = 0; i < t; i++) {
            int n = sc.nextInt();
            String tr=sc.next();
            StringBuffer str= new StringBuffer(tr);
            StringBuffer a= new StringBuffer("1");
            StringBuffer b= new StringBuffer("1");
            int j=1;
            for (; j < n; j++) {
                xor(str.charAt(j),a,b);
                if(str.charAt(j)=='1')
                    break;
            }
             j++;
            for (; j < n; j++)
            {
                a.append(0);
                b.append(str.charAt(j));
            }
            System.out.println(a);
            System.out.println(b);
        }
    }
    static  void xor(char x, StringBuffer a, StringBuffer b){
        if (x=='0'){
            a.append(0);
            b.append(0);
        }
        else if(x=='1'){
            a.append(1);
            b.append(0);
        }
        else
        {
                a.append(1);
                b.append(1);
        }
    }
}


import java.util.Scanner;

public class C {
    public static  void  main(String [] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        for (int i = 0; i < t; i++) {
            int n = sc.nextInt();
            int tr=sc.nextInt();
            StringBuffer str= new StringBuffer(Integer.toString(tr));
            StringBuffer a= new StringBuffer("1");
            StringBuffer b= new StringBuffer("1");
            for (int j = 1; j < n; j++) {
                xor(str.charAt(j),a,b);
            }
            System.out.println(a);
            System.out.println(b);
        }
    }
    static  void xor(char x, StringBuffer a, StringBuffer b){
        if (x=='0'){
            a.append(0);
            b.append(0);
        }
        else if(x=='1'){
            int avl=Integer.parseInt(a.toString());
            int bvl=Integer.parseInt(b.toString());
            if(avl>bvl){
                a.append(0);
                b.append(1);
            }
            else {
                a.append(1);
                b.append(0);
            }
//            mx.append(0);
//            mx=mx==a?b:a;
//            mx.append(1);
        }
        else
        {
            int l=a.length()-1;
            if(a.charAt(l)==b.charAt(l)) {
                a.append(1);
                b.append(1);
            }
            else {
                a.append(a.charAt(l)=='1'?"0":"2");
                b.append(b.charAt(l)=='1'?"0":"2");
            }
        }
    }
}


//  02/08/20  12:35 PM  Aug  2020
import java.util.*;
public class _1328C {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while (t-- > 0) {
            int n = sc.nextInt();
            String s = sc.next();
            StringBuilder st1 = new StringBuilder();
            StringBuilder st2 = new StringBuilder();

           boolean check=true;
            for (int i = 0; i < n; ++i) {
                char ch = s.charAt(i);
                if (ch == '2') {
                    if (!check) {
                        st1.append(0);
                        st2.append(2);
                    } else {
                        st1.append(1);
                        st2.append(1);
                    }
                } else if (ch == '1') {
                    if (check) {
                        check=false;
                        st1.append(1);
                        st2.append(0);
                    } else {
                        st1.append(0);
                        st2.append(1);
                    }
                } else {
                    st1.append(0);
                    st2.append(0);
                }
            }
            System.out.println(st1);
            System.out.println(st2);
        }
    }
}


//  02/08/20  12:35 PM  Aug  2020

import java.io.*;
import java.util.*;

public class _1328C {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while (t-- > 0) {
            int n = sc.nextInt();
            String s = sc.next();
            StringBuilder st1 = new StringBuilder();
            StringBuilder st2 = new StringBuilder();

            boolean key_one=false,key_two=true;
            for (int i = 0; i < s.length(); ++i) {
                char ch = s.charAt(i);
                if(ch=='2') {
                    if (!key_two) {
                        key_one=true;
                        st1.append(0);
                        st2.append(2);
                    } else {
                        st1.append(1);
                        st2.append(1);
                    }
                }
                else if(ch=='1') {
                    if (!key_one) {
                        key_two = false;
                        st1.append(1);
                        st2.append(0);
                    } else {
                        st1.append(0);
                        st2.append(1);
                    }
                }
                else{
                    st1.append(0);
                    st2.append(0);
                }
            }
            System.out.println(st1);
            System.out.println(st2);
        }
    }
}


//  02/08/20  12:35 PM  Aug  2020
import java.util.*;
public class _1328C {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while (t-- > 0) {
            int n = sc.nextInt();
            String s = sc.next();
            StringBuilder st1 = new StringBuilder();
            StringBuilder st2 = new StringBuilder();

            boolean key_one=false,key_two=true;
            for (int i = 0; i < n; ++i) {
                char ch = s.charAt(i);
                if (ch == '2') {
                    if (!key_two) {
                        key_one = true;
                        st1.append(0);
                        st2.append(2);
                    } else {
                        key_one=false;
                        st1.append(1);
                        st2.append(1);
                    }
                } else if (ch == '1') {
                    if (!key_one) {
                        key_two = false;
                        st1.append(1);
                        st2.append(0);
                    } else {
                        key_two=true;
                        st1.append(0);
                        st2.append(1);
                    }
                } else {
                    st1.append(0);
                    st2.append(0);
                }
            }
            System.out.println(st1);
            System.out.println(st2);
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class C_POST {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		while (t-- > 0) {
			int n = Integer.parseInt(br.readLine());
			String str = br.readLine();
			StringBuilder a = new StringBuilder();
			StringBuilder b = new StringBuilder();
			boolean ptr = false;
			for (int i = 0; i < n; i++) {
				if (str.charAt(i) == '0') {
					a.append('0');
					b.append('0');
				} else if (str.charAt(i) == '1') {
					if (!ptr) {
						a.append('0');
						b.append('1');
						ptr = true;
					} else {
						a.append('1');
						b.append('0');
					}
				} else if (str.charAt(i) == '2') {
					if (!ptr) {
						a.append('1');
						b.append('1');
					} else {
						a.append('2');
						b.append('0');
					}
				}
			}
			System.out.println(a.toString());
			System.out.println(b.toString());
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class C_POST {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		while (t-- > 0) {
			int n = Integer.parseInt(br.readLine());
			String str = br.readLine();
			StringBuilder a = new StringBuilder();
			StringBuilder b = new StringBuilder();
			boolean ptr = false;
			for (int i = 0; i < n; i++) {
				if (str.charAt(i) == '0') {
					a.append('0');
					b.append('0');
				} else if (str.charAt(i) == '1') {
					if (!ptr) {
						a.append('0');
						b.append('1');
						ptr = false;
					} else {
						a.append('1');
						b.append('0');
					}
				} else if (str.charAt(i) == '2') {
					if (!ptr) {
						a.append('1');
						b.append('1');
					} else {
						a.append('2');
						b.append('0');
					}
				}
			}
			System.out.println(a.toString());
			System.out.println(b.toString());
		}
	}
}