The only difference between the easy and hard versions is that tokens of type O do not appear in the input of the easy version.

Errichto gave Monogon the following challenge in order to intimidate him from taking his top contributor spot on Codeforces.

In a Tic-Tac-Toe grid, there are n rows and n columns. Each cell of the grid is either empty or contains a token. There are two types of tokens: X and O. If there exist three tokens of the same type consecutive in a row or column, it is a winning configuration. Otherwise, it is a draw configuration.

<image> The patterns in the first row are winning configurations. The patterns in the second row are draw configurations. 

In an operation, you can change an X to an O, or an O to an X. Let k denote the total number of tokens in the grid. Your task is to make the grid a draw in at most ⌊ k/3⌋ (rounding down) operations.

You are not required to minimize the number of operations.

Input

The first line contains a single integer t (1≤ t≤ 100) — the number of test cases.

The first line of each test case contains a single integer n (1≤ n≤ 300) — the size of the grid.

The following n lines each contain a string of n characters, denoting the initial grid. The character in the i-th row and j-th column is '.' if the cell is empty, or it is the type of token in the cell: 'X' or 'O'.

It is guaranteed that not all cells are empty.

In the easy version, the character 'O' does not appear in the input.

The sum of n across all test cases does not exceed 300.

Output

For each test case, print the state of the grid after applying the operations.

We have proof that a solution always exists. If there are multiple solutions, print any.

Example

Input


3
3
.X.
XXX
.X.
6
XX.XXX
XXXXXX
XXX.XX
XXXXXX
XX.X.X
XXXXXX
5
XXX.X
.X..X
XXX.X
..X..
..X..


Output


.X.
XOX
.X.
XX.XXO
XOXXOX
OXX.XX
XOOXXO
XX.X.X
OXXOXX
XOX.X
.X..X
XXO.O
..X..
..X..

Note

In the first test case, there are initially three 'X' consecutive in the second row and the second column. By changing the middle token to 'O' we make the grid a draw, and we only changed 1≤ ⌊ 5/3⌋ token.

In the second test case, we change only 9≤ ⌊ 32/3⌋ tokens, and there does not exist any three 'X' or 'O' consecutive in a row or column, so it is a draw.

In the third test case, we change only 3≤ ⌊ 12/3⌋ tokens, and the resulting grid is a draw.


import java.io.*;
import java.text.DecimalFormat;
import java.util.*;


    public class educational97A  {
    	
    	
    	public static void main(String[] args)throws Exception {
    		
    		  Scanner sc =new Scanner(System.in);
    		  int t=sc.nextInt();
    		
    		  while(t-->0) {
    			 
    			  int n=sc.nextInt();
    			  
    			 char[][] inp=new char[n][n];
    			 
    			  for(int i=0;i<n;i++) {
    				  inp[i]=sc.nextLine().toCharArray();
    				  
    			  }
    		int [] freq=new int[3];
    		for(int i=0;i<n;i++) {
    			for(int j=0;j<n;j++) {
    				if(inp[i][j]=='X') {
    					freq[(i+j)%3]++;
    				}
    			}
    		}
    		int cur=freq[0];
    		int idx=0;
    		for(int i=1;i<3;i++) {
    			if(freq[i]<cur) {
    				cur=freq[i];
    				idx=i;
    			}
    		}
    	
    		for(int i=0;i<n;i++) {
    			for(int j=0;j<n;j++) {
    				if((i+j)%3==idx&&inp[i][j]=='X') {
    					inp[i][j]='O';
    				}
    			}
    		}
    		for(int i=0;i<n;i++) {
    			for(int j=0;j<n;j++) {
    				System.out.print(inp[i][j]);
    			}
    			System.out.println();
    		}
    		
    			}}
    
    	


	public static void print(char[]a,int k) {
		int i=0;int j=0;;int c=0;
		for( i=0;i<k;i++) {
			for(j=0;j<k;j++) {
				System.out.print(a[c++]);
			}
			System.out.println();
		}
		return;
	}

    static long npr (int n, int r) 
    { 
        return fact[n] / fact[n - r]; 
    } 
  static long fact[];
	static int[]indices;
	static int cnmax;
	static int cnmin;
	public static void binaryasearch(int pos) {
	int left=0;
	int right=indices.length-1;
	
	while(left<right) {
		int mid=(left+right)/2;
		if(indices[mid]<=pos) {
			left=mid+1;
		    cnmax++;		    
		}
		else {
			right=mid;
			cnmin++;
		}
	}
}
 
	static class Pair implements Comparable<Pair>{
		int a, b;
 
		public Pair(int a1, int b1) {
			a = a1;
			b = b1;
 
		}

		@Override
		public int compareTo(Pair o) {
			// TODO Auto-generated method stub
			return a-o.a;
		}
		public int dist(Pair o) {
			return Math.abs(a-o.a)+Math.abs(b-o.b);
		}
	}

    	
    	  	 	static class SegmentTree{
    	   	 		String[] arr , sTree;
    	   	 	static	int N;
    	   	 		public SegmentTree(String[] in){
    	   	 			arr=in;
    	   	 		N=arr.length-1;
    	   	 			sTree=new String[2*N];
    	   	 			
    	   	 			build(1,1,N);
    	   	 		}
    	   	 		public void build(int node, int l, int r){
    	   	 			if(l==r){
    	   	 				sTree[node]=arr[l];
    	   	 			}
    	   	 			else{
    	   	 				int leftchild=node*2;
    	   	 				int rightchild=node*2+1;
    	   	 				int mid =(l+r)/2;
    	   	 				build(leftchild,l,mid);
    	   	 				build(rightchild,mid+1,r);
    	   	 				sTree[node]=sTree[leftchild].concat(sTree[rightchild]);
    	   	 			}
    	   	 		}
    	   	 		public  void update(int i, String val){
    	   	 			int node =i+N-1;
    	   	 			arr[i]=val;
    	   	 			sTree[node]=val;
    	   	 			node=node/2;
    	   	 			while(node>0){
    	   	 			int leftchild=node *2;
       	 				int rightchild=node*2+1;
       	 			sTree[node]=sTree[leftchild].concat(sTree[rightchild]);
       	 			node=node/2;
    	   	 			}
    	   	 			return;
    	   	 			
    	   	 		}
    	   	 		public String query(int i, int j){
    	   	 			 return query(1,1, N,  i, j);
    	   	 		}
    	   	 		public String query(int node,int l, int r, int i , int j){
    	   	 			if(i>r||j<l){
    	   	 				return "";
    	   	 			}
    	   	 			if(i<=l&&r<=j){
    	   	 				return sTree[node];
    	   	 			}
    	   	 		int leftchild=node*2;
    	 				int rightchild=node*2+1;
    	 				int mid =(l+r)/2;
    	 				
    	 			return	(query(leftchild,l,mid,i,j).concat(query(rightchild,mid+1,r,i,j)));
    	 				
    	   	 		}
    	   	 	}
     
    	  	 	static ArrayList<Pair>factors;
    	    	static boolean isComposite[];
    	    	static ArrayList<Integer> primes;
    	    	public static boolean isprime(long n){
    	    		if(n<=100001){
    	    			return !isComposite[(int)n];
    	    		}
    	    		for(int i=0;i<primes.size();i++){
    	    			if(primes.get(i)*primes.get(i)*1l>n){
    	    				break;
    	    			}
    	    			if(n%primes.get(i)==0){
    	    				return false;
    	    			}
    	    			
    	    		}
    	    		return true;
    	    	}
    	    	
    	    	
    	    	public static void sieve(int n){
    	    		isComposite=new boolean[n+1];
    	    		primes =new ArrayList<Integer>();
    	    		isComposite[0]=true;
    	    		isComposite[1]=true;
    	    		for(int i=2;i<=n;i++){
    	    			if(!isComposite[i]){
    	    				for(int j=2*i;j<=n;j=j+i){
    	    					isComposite[j]=true;
    	    				}
    	    				primes.add(i);
    	    			}
    	    			
    	    		}
    	    		
    	    	}
    	    	public static void primefactors(long n){
    	    		 factors=new ArrayList<Pair>();
    	    		for(int x:primes){
    	    			if(x*x*1l>n){
    	    				break;
    	    			}
    	    		
    	    			
    	    			if(n%x==0){
    	    				
    	    					Pair p=new Pair(x,0);
    	    					 factors.add(p);
    	    				while(n%x==0){
    	    				n/=x;
    	    				p.b++;}
    	    				
    	    			}
    	    		}
    	    		if(n!=1){
    	    			factors.add(new Pair((int)n,1));
    	    		}
    	    		
    	    	}
    	    	public static long powfact(long n,long p){
    	    		int res=0;
    	    		for(long i=p;i*1l<=n;i=i*p*1l){
    	    			res+=(n/i);
    	    		}
    	    		return res;
    	    	}
    	    	
    	    	public static long GCD(long i, long j){
    	    	if (i==0){
    	    		return j;
    	    	}
    	    	return GCD(j%i,i);
    	    	}
    	    	public static long LCM(long i, long j){
    	    		return(i*j)/GCD(i,j);
    	    	}
    	    
 	static class Scanner {
    		StringTokenizer st;
    		BufferedReader br;
     
    		public Scanner(InputStream s) {
    			br = new BufferedReader(new InputStreamReader(s));
    		}
     
    		public boolean hasNext() {
    			// TODO Auto-generated method stub
    			return false;
    		}
     
    		public String next() throws IOException {
    			while (st == null || !st.hasMoreTokens())
    				st = new StringTokenizer(br.readLine());
    			return st.nextToken();
    		}
     
    		public int nextInt() throws IOException {
    			return Integer.parseInt(next());
    		}
     
    		public long nextLong() throws IOException {
    			return Long.parseLong(next());
    		}
     
    		public String nextLine() throws IOException {
    			return br.readLine();
    		}
     
    		public double nextDouble() throws IOException {
    			String x = next();
    			StringBuilder sb = new StringBuilder("0");
    			double res = 0, f = 1;
    			boolean dec = false, neg = false;
    			int start = 0;
    			if (x.charAt(0) == '-') {
    				neg = true;
    				start++;
    			}
    			for (int i = start; i < x.length(); i++)
    				if (x.charAt(i) == '.') {
    					res = Long.parseLong(sb.toString());
    					sb = new StringBuilder("0");
    					dec = true;
    				} else {
    					sb.append(x.charAt(i));
    					if (dec)
    						f *= 10;
    				}
    			res += Long.parseLong(sb.toString()) / f;
    			return res * (neg ? -1 : 1);
    		}
     
    		public boolean ready() throws IOException {
    			return br.ready();
    		}
     
    	}}
