Problem: Find an n × n matrix with different numbers from 1 to n2, so the sum in each row, column and both main diagonals are odd.

Input

The only line contains odd integer n (1 ≤ n ≤ 49).

Output

Print n lines with n integers. All the integers should be different and from 1 to n2. The sum in each row, column and both main diagonals should be odd.

Examples

Input

1


Output

1


Input

3


Output

2 1 4
3 5 7
6 9 8

Solution (in JAVA):

Solution:
import java.io.*;
import java.util.*;

public class magicOddSquare
{
	public static void main(String args[])throws IOException
	{
		Scanner sc = new Scanner (System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		
		
		
		
		{
			int n = sc.nextInt();
			int mid = (n+1)/2;
			if (n == 1)
				out.println(1);
			
			
			else
			{
				Stack<Integer> even = new Stack<Integer>();
				Stack<Integer> odd =  new Stack<Integer>();
				for (int numbers = 1; numbers <= n*n; numbers++)
				{
					if (numbers%2 == 0)		even.push(numbers);
					else					odd.push(numbers);
				}
				int [][] grid = new int [n+1][n+1];
				
				// fill odds 
				int toFill = 1;
					
				// filling the upper half first 
				
				for (int row = 1; row<= mid-1; row++)
				{
					int fill = toFill;
					int fillLeft = mid-1;
					int fillRight = mid+1;
					grid[row][mid] = odd.pop();
					fill--;
					while (fill != 0)
					{
						grid[row][fillLeft] = odd.pop();
						grid[row][fillRight] = odd.pop();
						fillLeft--;
						fillRight++;
						fill-=2;
					}
					toFill += 2;
							
				}
				
				// fill lower half
				toFill = 1;
				for (int row = n; row >=  mid+1; row--)
				{
					int fill = toFill;
					int fillLeft = mid-1;
					int fillRight = mid+1;
					grid[row][mid] = odd.pop();
					fill--;
					while (fill != 0)
					{
						grid[row][fillLeft] = odd.pop();
						grid[row][fillRight] = odd.pop();
						fillLeft--;
						fillRight++;
						fill-=2;
					}
					toFill += 2;
							
				}
				
				// fill the middle row 
				for (int i = 1; i<= n; i++)
					grid[mid][i] = odd.pop();
				
			/*	for (int i = 1; i<= n; i++)
				{
					for (int j = 1; j<=n; j++)
						System.out.print(grid[i][j]+" ");
					System.out.println();
				}*/
				
				
				// fill the even s
				for (int i = 1; i<=n; i++)
				{
					for (int j = 1; j<=n; j++)
					{
						if (grid[i][j] == 0)
							grid[i][j] = even.pop();
					}
				}
				
				
				int rowSum = 0;
				int colSum = 0;
				int mainDiag = 0;
				int otherDiag = 0;
				for (int i = 1; i <= n; i++)
				{
					for (int j = 1; j <= n; j++)
						{rowSum += grid[i][j]; colSum += grid[j][i]; mainDiag += grid[j][j]; otherDiag += grid[j][n+1-j];}
					
					if (rowSum % 2 == 0 )
						{out.println("Warning Row Sum "+i); break;}
					if ( colSum % 2 == 0 )
						{out.println("Warning Col Sum"); break;}
					if ( mainDiag % 2 == 0 )
						{out.println("Warning mainDiag Sum"); break;}
					if ( otherDiag % 2 == 0)
						{out.println("Warning otherDiag Sum"); break;}
					rowSum = 0; colSum = 0; mainDiag = 0; otherDiag = 0;
				}
				for (int i = 1; i<= n; i++)
				{
					for (int  j = 1; j<=n; j++)
						out.print(grid[i][j]+" ");
					out.println();
				}
			}
			
		}
		
		out.close();
	}

}