Problem: You are given a correct solution of the sudoku puzzle. If you don't know what is the sudoku, you can read about it [here](http://tiny.cc/636xmz).

The picture showing the correct sudoku solution:

<image>

Blocks are bordered with bold black color.

Your task is to change at most 9 elements of this field (i.e. choose some 1 ≤ i, j ≤ 9 and change the number at the position (i, j) to any other number in range [1; 9]) to make it anti-sudoku. The anti-sudoku is the 9 × 9 field, in which:

  * Any number in this field is in range [1; 9]; 
  * each row contains at least two equal elements; 
  * each column contains at least two equal elements; 
  * each 3 × 3 block (you can read what is the block in the link above) contains at least two equal elements. 



It is guaranteed that the answer exists.

You have to answer t independent test cases.

Input

The first line of the input contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t test cases follow.

Each test case consists of 9 lines, each line consists of 9 characters from 1 to 9 without any whitespaces — the correct solution of the sudoku puzzle.

Output

For each test case, print the answer — the initial field with at most 9 changed elements so that the obtained field is anti-sudoku. If there are several solutions, you can print any. It is guaranteed that the answer exists.

Example

Input


1
154873296
386592714
729641835
863725149
975314628
412968357
631457982
598236471
247189563


Output


154873396
336592714
729645835
863725145
979314628
412958357
631457992
998236471
247789563

Solution (in JAVA):

Solution:
import java.io.OutputStream;
import java.util.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedHashSet;
import java.io.Writer;
import java.math.BigInteger;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.Period;
import java.time.temporal.ChronoUnit;
import java.io.OutputStreamWriter;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Egor Kulikov (egor@egork.net)
 */
public class Solution {

    public static void main(String[] args) throws FileNotFoundException {

        InputStream inputStream = System.in;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(System.out);
        Solutio solver = new Solutio();
      
        int testCount =Integer.parseInt(in.next());
       // int sum=in.readInt(),te=0;
		// if(sum==1)
		for (int i = 1; i <= testCount; i++) 
		{
			solver.solve(i, in, out);
			out.flush();
		}
		
        
    }
//**********************SOLVE    HERE     EVERYTHING******************************



    //1 2 3 4 5 
    static class Solutio {
        public void solve(int testNumber, InputReader in, PrintWriter out) throws FileNotFoundException {
        	
//        	int n=in.readInt();
//        	String arr[]=new String[n];
//        	for(int i=0;i<n;i++)
//        	{
//        		arr[i]=in.readString();
//        	}
//        	Arrays.sort(arr,new StringComparator());
//        	String k="";
//        	int st=-1,en=-1;
//        	for(int i=0;i<n;i++)
//        	{
//        		if(arr[i].charAt(0)!='*')
//        		{
//        			st=i;
//        		}
//        		if(arr[i].charAt(arr[i].length()-1)!='*')
//        		{
//        			en=i;
//        		}
//        		
//        	}
//        	if(st!=-1)
//        	{
//        		char ch=arr[st].charAt(0);
//        		for(int i=0;i<n;i++)
//        		{
//        			if(arr[i].charAt(0)!='*' && arr[i].charAt(0)!=ch)
//        			{
//        				System.out.println("Case #"+testNumber+": *");
//        				return;
//        			}
//        		}
//        		
//        	}
//        	if(en!=-1)
//        	{
//        		char ch=arr[en].charAt(arr[en].length()-1);
//        		for(int i=0;i<n;i++)
//        		{
//        			if(arr[i].charAt(arr[i].length()-1)!='*' && arr[i].charAt(arr[i].length()-1)!=ch)
//        			{
//        				System.out.println("Case #"+testNumber+": *");
//        				return;
//        			}
//        		}
//        		
//        	}
        	
        	
//        	int n=in.readInt();
//        	int arr[]=new int[n];
//        	int ch[]=new int[n+1];
//        	for(int i=0;i<n;i++) {
//        		arr[i]=in.readInt();
//        		ch[arr[i]]++;
//        	}
//        	int max=0,ind=-1;
//        	for(int i=1;i<=n;i++)
//        	{
//        		if(ch[i]>max)
//        		{
//        			max=ch[i];
//        			ind=i;
//        		}
//        	}
//        	int dis=0;
//        	for(int i=1;i<=n;i++)
//        	{
//        		if(ch[i]>0 && i!=ind)
//        		{
//        			dis++;
//        		}
//        	}
//        	if(dis<max)
//        	{
//        		dis++;
//        		max--;
//        	}
//        	if(max<dis)
//        	{
//        		System.out.println(max);return;
//        	}
//        	if(max==dis)
//        	{
//        		System.out.println(max);return;
//        	}
//        	System.out.println(Math.max(max, dis));
//        	
//        	

        	StringBuffer s;
        	int arr[][]=new int[9][9];
        	for(int i=0;i<9;i++)
        	{
        		s=new StringBuffer(in.readString());
        		for(int j=0;j<9;j++)
        		{
        			arr[i][j]=Character.getNumericValue(s.charAt(j));
        		}
        	}    
        	int j=0,k=1;
        	for(int i=0;i<20;i+=3,j++)
        	{
        		if(i>=9) {
        			i=1+i-9;}
        		
        			if(arr[i][j]==1)
        				arr[i][j]=2;
        			else
        				arr[i][j]=1;
        			
        			if(i==8)
        				break;
        		
        	}
        	for(int i=0;i<9;i++)
        	{
        		for(j=0;j<9;j++)
        			out.print(arr[i][j]);
        		out.println();
        	}
        	
        	
        	
        }
        }
    static class StringComparator implements Comparator<String>
    {

		@Override
		public int compare(String arg0, String arg1) {
			
			return arg0.length()-arg1.length();
		}
    	
    	
    }
        
       static ArrayList<Integer> primeSieve(int n) 
        { 
            ArrayList<Integer> li=new ArrayList<Integer>();
            li.add(1);
            boolean prime[] = new boolean[n+1]; 
            for(int i=0;i<n;i++) 
                prime[i] = true; 
              
            for(int p = 2; p*p <=n; p++) 
            { 
                // If prime[p] is not changed, then it is a prime 
                if(prime[p] == true) 
                { 
                    // Update all multiples of p 
                    for(int i = p*2; i <= n; i += p) 
                        prime[i] = false; 
                } 
            } 

            for(int i = 2; i <= n; i++) 
            { 
                if(prime[i] == true) 
                    li.add(i);
            }
            return li;
        } 
       
       static class Tree
       {
    	   
    	   
       }
        
      
  

//*********************END        HERE       EVERYTHING*******************************    

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

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

        public void readIntArrays(int[]... arrays) {
            for (int i = 0; i < arrays[0].length; i++) {
                for (int j = 0; j < arrays.length; j++) {
                    arrays[j][i] = readInt();
                }
            }
        }

        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 {
                if (Character.isValidCodePoint(c)) {
                    res.appendCodePoint(c);
                }
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

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

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

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

    }
}