Problem: Let's call some square matrix with integer values in its cells palindromic if it doesn't change after the order of rows is reversed and it doesn't change after the order of columns is reversed.

For example, the following matrices are palindromic:

<image>

The following matrices are not palindromic because they change after the order of rows is reversed:

<image>

The following matrices are not palindromic because they change after the order of columns is reversed:

<image>

You are given n^2 integers. Put them into a matrix of n rows and n columns so that each number is used exactly once, each cell contains exactly one number and the resulting matrix is palindromic. If there are multiple answers, print any. If there is no solution, print "NO".

Input

The first line contains one integer n (1 ≤ n ≤ 20).

The second line contains n^2 integers a_1, a_2, ..., a_{n^2} (1 ≤ a_i ≤ 1000) — the numbers to put into a matrix of n rows and n columns.

Output

If it is possible to put all of the n^2 numbers into a matrix of n rows and n columns so that each number is used exactly once, each cell contains exactly one number and the resulting matrix is palindromic, then print "YES". Then print n lines with n space-separated numbers — the resulting matrix.

If it's impossible to construct any matrix, then print "NO".

You can print each letter in any case (upper or lower). For example, "YeS", "no" and "yES" are all acceptable.

Examples

Input


4
1 8 8 1 2 2 2 2 2 2 2 2 1 8 8 1


Output


YES
1 2 2 1
8 2 2 8
8 2 2 8
1 2 2 1


Input


3
1 1 1 1 1 3 3 3 3


Output


YES
1 3 1
3 1 3
1 3 1


Input


4
1 2 1 9 8 4 3 8 8 3 4 8 9 2 1 1


Output


NO


Input


1
10


Output


YES
10 

Note

Note that there exist multiple answers for the first two examples.

Solution (in JAVA):

Solution:

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;
import java.util.Set;

public class PalindromicMatrix {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		HashMap<Integer, Integer> hmap = new HashMap<>();
		int[] arr = new int[n * n];
		for (int i = 0; i < n * n; i++) {
			int x = scn.nextInt();
			if (hmap.containsKey(x)) {
				hmap.put(x, hmap.get(x) + 1);
			} else {
				hmap.put(x, 1);
			}
		}
		HashMap<Integer, ArrayList<Integer>> freq = new HashMap<>();
		Set<Integer> set = hmap.keySet();
		int flag = 0;
		for (int s : set) {
			int x = hmap.get(s);
			if (x >= 4) {
				if (freq.containsKey(4)) {
					ArrayList<Integer> al = freq.get(4);
					al.add(s);
					freq.put(4, al);
				} else {
					ArrayList<Integer> al = new ArrayList<>();
					al.add(s);
					freq.put(4, al);
				}
			} else if (x != 1) {
				if (freq.containsKey(2)) {
					ArrayList<Integer> al = freq.get(2);
					al.add(s);
					freq.put(2, al);
				} else {
					ArrayList<Integer> al = new ArrayList<>();
					al.add(s);
					freq.put(2, al);
				}
			} else {
				if (freq.containsKey(1)) {
					ArrayList<Integer> al = freq.get(1);
					al.add(s);
					freq.put(1, al);
				} else {
					ArrayList<Integer> al = new ArrayList<>();
					al.add(s);
					freq.put(1, al);
				}
			}
		}
		int mid = (n * n) / 2;
		if ((n * n) % 2 != 0) {
			mid += 1;
		}
	//	System.out.println(hmap);
	//	System.out.println(freq);
		for (int j = 0, start = 0; j < n && start < mid; j++) {
		//	System.out.println(start + " " + j + " " + (n / 2) + " " + mid + " " + freq+" "+hmap);
			if (freq.containsKey(4)) {
				if (n % 2 != 0 && j == n / 2 ) {
					//System.out.println("ddd");
					if (freq.containsKey(2)) {
						ArrayList<Integer> al = freq.get(2);

						int y = freq.get(2).get(al.size() - 1);
						arr[start + j] = y;
						arr[n * n - (start + j) - 1] = y;
						j = -1;
						start = n + start;
						int rem_freq = hmap.get(y) - 2;
						hmap.put(y, rem_freq);
						if (rem_freq == 1) {
							if (freq.containsKey(1)) {
								freq.get(1).add(freq.get(2).get(al.size() - 1));
							} else {
								ArrayList<Integer> a = new ArrayList<Integer>();
								a.add(freq.get(2).get(al.size() - 1));
								freq.put(1, a);
							}
							freq.get(2).remove(al.size() - 1);
							if(freq.get(2).size()==0) {
								freq.remove(2);
							}

						} else if (rem_freq == 0) {
							freq.get(2).remove(al.size() - 1);
							if(freq.get(2).size()==0) {
								freq.remove(2);
							}
						}
//						else if(rem_freq<4) {
//							if (freq.containsKey(2)) {
//								freq.get(2).add(freq.get(4).get(al.size() - 1));
//							} else {
//								ArrayList<Integer> a = new ArrayList<Integer>();
//								a.add(freq.get(4).get(al.size() - 1));
//								freq.put(2, a);
//							}
//							freq.get(4).remove(al.size() - 1);
//							if(freq.get(4).size()==0) {
//								freq.remove(4);
//							}	
//						}
					//	System.out.println("strat22 "+start);
					} else {
						ArrayList<Integer> al = freq.get(4);

						//System.out.println(al);
						int y = al.get(al.size() - 1);
						arr[start + j] = y;
						arr[n * n - (start + j) - 1] = y;
						j = -1;
						start = n + start;
						int rem_freq = hmap.get(y) - 2;
						hmap.put(y, rem_freq);
						//System.out.println(hmap.get(1)+" "+rem_freq);
						if (rem_freq == 0) {
							freq.get(4).remove(al.size() - 1);
							if(freq.get(4).size()==0) {
								freq.remove(4);
							}
						} else if (rem_freq == 1) {
							if (freq.containsKey(1)) {
								freq.get(1).add(freq.get(4).get(al.size() - 1));
							} else {
								ArrayList<Integer> a = new ArrayList<Integer>();
								a.add(freq.get(4).get(al.size() - 1));
								freq.put(1, a);
							}
							freq.get(4).remove(al.size() - 1);
							if(freq.get(4).size()==0) {
								freq.remove(4);
							}
						}
						else if(rem_freq<4) {
							if (freq.containsKey(2)) {
								freq.get(2).add(freq.get(4).get(al.size() - 1));
							} else {
								ArrayList<Integer> a = new ArrayList<Integer>();
								a.add(freq.get(4).get(al.size() - 1));
								freq.put(2, a);
							}
							freq.get(4).remove(al.size() - 1);
							if(freq.get(4).size()==0) {
								freq.remove(4);
							}	
						}
					}
				} else {
					ArrayList<Integer> al = freq.get(4);
					int y = al.get(al.size() - 1);
					arr[start + j] = y;
					arr[start+ n - j - 1] = y;
					int rem_freq = hmap.get(y) ;
					if(n * n - (start + j) - 1!=start+ n - j - 1)
					{
						arr[n * n - (start+ n - j - 1) - 1] = y;
						arr[n * n - (start + j) - 1] = y;
						rem_freq-=4;
					}else {
						rem_freq-=2;
					}
					
					hmap.put(y, rem_freq);
					if (rem_freq == 0) {
						freq.get(4).remove(al.size() - 1);
						if (freq.get(4).size() == 0)
							freq.remove(4);
					} else if (rem_freq == 1 ) {
						if (freq.containsKey(1)) {
							freq.get(1).add(freq.get(4).get(al.size() - 1));
						} else {
							ArrayList<Integer> a = new ArrayList<Integer>();
							a.add(freq.get(4).get(al.size() - 1));
							freq.put(1, a);
						}
						freq.get(4).remove(al.size() - 1);
						if(freq.get(4).size()==0) {
							freq.remove(4);
						}
					}else if (rem_freq < 4) {
						if (freq.containsKey(2)) {
							freq.get(2).add(freq.get(4).get(al.size() - 1));
						} else {
							ArrayList<Integer> a = new ArrayList<Integer>();
							a.add(freq.get(4).get(al.size() - 1));
							freq.put(2, a);
						}
						// System.out.println(al.size()+"kkkk");
						freq.get(4).remove(al.size() - 1);
						if(freq.get(4).size()==0) {
							freq.remove(4);
						}
					} 
					if (n%2==0&&j == n / 2 - 1) {
						j = -1;
						start = n + start;
					}
				}
				//System.out.println("start "+start);
			} else if (freq.containsKey(2)) {
				if(n%2!=0&&j!=n/2&&start+j>=(n/2)*n) {
					ArrayList<Integer> al=freq.get(2);
					int y=al.get(al.size()-1);
					arr[start+j]=y;
					arr[start+n-j-1]=y;
					int rem_freq = hmap.get(y) - 2;
					hmap.put(y, rem_freq);
					if (rem_freq == 0) {
						freq.get(2).remove(al.size() - 1);
						if (freq.get(2).size() == 0)
							freq.remove(2);
					} else if (rem_freq == 1) {
						if (freq.containsKey(1)) {
							freq.get(1).add(freq.get(2).get(al.size() - 1));
						} else {
							ArrayList<Integer> a = new ArrayList<Integer>();
							a.add(freq.get(2).get(al.size() - 1));
							freq.put(1, a);
						}
						freq.get(2).remove(al.size() - 1);
						if(freq.get(2).size()==0) {
							freq.remove(2);
						}
					}
				}else if(n%2!=0&&j==n/2) {
					ArrayList<Integer> al=freq.get(2);
					int y=al.get(al.size()-1);
					arr[start+j]=y;
					if (n * n - (start + j) - 1 > start + j)
						arr[n * n - (start + j) - 1] = y;
					int rem_freq = hmap.get(y) - 2;
					hmap.put(y, rem_freq);
						j = -1;
						start = n + start;
						
					//System.out.println("andar "+j+" "+hmap.get(1));
					if (rem_freq == 0) {
						freq.get(2).remove(al.size() - 1);
						if (freq.get(2).size() == 0)
							freq.remove(2);
					} else if (rem_freq == 1) {
						if (freq.containsKey(1)) {
							freq.get(1).add(freq.get(2).get(al.size() - 1));
						} else {
							ArrayList<Integer> a = new ArrayList<Integer>();
							a.add(freq.get(2).get(al.size() - 1));
							freq.put(1, a);
						}
						freq.get(2).remove(al.size() - 1);
						if(freq.get(2).size()==0) {
							freq.remove(2);
						}
					}
				}
				else {
					flag = 1;
					break;
				}
			} else {
				//System.out.println("jjj");
				if (freq.containsKey(1)) {
					if (n % 2 != 0) {
						//System.out.println("ooooooo");
						if (j + start == (n * n) / 2) {
							arr[j + start] = freq.get(1).get(freq.get(1).size() - 1);
							//System.out.println("11"+arr[j+start]);
						} else {
							flag = 1;
						}
					} else {
						flag = 1;
					}
					break;
				} else {
					//System.out.println(j + start);
					flag = 1;
					break;
				}
			}
		}
		if (flag == 1) {
			System.out.println("NO");
		
		} else {
			System.out.println("YES");
			int[][] a = new int[n][n];
			for (int i = 0, k = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					//System.out.println(j+" "+i +" "+k);
					a[j][i] = arr[k];
					k++;
				}
			}
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					System.out.print(a[i][j] + " ");
				}
				System.out.println();
			}
		}

	}
}