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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class q1 {

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());

        int dirs[][] = {
            {1, 0},
            {0, -1},
            {-1, 0},
            {0, 1}
        };

        for (int[] arr : printSpiralTillK(dirs, n)) {
            for (int num : arr) {
                System.out.print(num + " ");
            }
            System.out.println("");
        }
    }

    private static int[][] printSpiralTillK(int[][] dirs, int n) {
        int size = n * n;
        int[][] res = new int[n][n];
        int[] s = new int[2];
        setStart(s, n);
        int idx = 0, str = idx;
        for (int i = 0; i < n; i++) {
            res[0][i] = s[idx];
            s[idx] += 2;
            idx = (idx + 1) % 2;

        }
        int d = 0, r = n, c = n;
        int[] pos = {0, c - 1};
        int ele = (r - 1) * c;
        while (ele > 0) {
            for (int j = 1; j < r; j++) {
                ele--;
                pos[0] += dirs[d][0];
                pos[1] += dirs[d][1];
                if (pos[0] == n / 2 && pos[1] == n / 2) {
                    res[pos[0]][pos[1]] = s[idx];
                } else {
                    res[pos[0]][pos[1]] = s[idx];
                    s[idx] += 2;
                    idx = (idx + 1) % 2;
                }
            }
            r--;
            int temp = r;
            r = c;
            c = temp;
            if ((r + c - 3) % 4 == 0) {
                idx = (str + 1) % 2;
                str = idx;
            }
            d = (d + 1) % 4;
        }
        return res;
    }

    private static void setStart(int[] s, int n) {
        if ((n - 1) % 4 == 0) {
            s[0] = 1;
            s[1] = 2;
        } else if ((n - 3) % 4 == 0) {
            s[0] = 2;
            s[1] = 1;
        }
    }
}