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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
void fre() {
  freopen("input.in", "r", stdin);
  freopen("output.out", "w", stdout);
}
template <class T1, class T2>
inline void gmax(T1 &a, T2 b) {
  if (b > a) a = b;
}
template <class T1, class T2>
inline void gmin(T1 &a, T2 b) {
  if (b < a) a = b;
}
int mp[50][50];
const int maxn = 210;
const int MAXM = 40010;
int head[maxn], tot, cur[maxn];
struct Edge {
  int to, next, cap, flow;
} e[MAXM];
int d[maxn], gap[maxn], N, S[MAXM];
void init(int n) {
  memset(head, -1, sizeof(head));
  tot = 0;
  N = n;
}
void addedge(int from, int to, int w) {
  e[tot].to = to, e[tot].next = head[from];
  e[tot].cap = w, e[tot].flow = 0;
  head[from] = tot++;
  e[tot].to = from, e[tot].next = head[to];
  e[tot].cap = 0, e[tot].flow = 0;
  head[to] = tot++;
}
void bfs(int st) {
  memset(d, -1, sizeof(d));
  memset(gap, 0, sizeof(gap));
  d[st] = 0, gap[0] = 1;
  queue<int> Q;
  Q.push(st);
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    for (int i = head[u]; i != -1; i = e[i].next) {
      int v = e[i].to;
      if (d[v] != -1) continue;
      d[v] = d[u] + 1;
      gap[d[v]]++;
      Q.push(v);
    }
  }
}
int sap(int st, int ed) {
  memcpy(cur, head, sizeof(head));
  bfs(ed);
  int u = st, top = 0, ans = 0;
  while (d[st] < N) {
    if (u == ed) {
      int Min = 0x3f3f3f3f, ind;
      for (int i = 0; i < top; i++) {
        if (Min > e[S[i]].cap - e[S[i]].flow) {
          Min = e[S[i]].cap - e[S[i]].flow;
          ind = i;
        }
      }
      for (int i = 0; i < top; i++) {
        e[S[i]].flow += Min;
        e[S[i] ^ 1].flow -= Min;
      }
      top = ind;
      u = e[S[top] ^ 1].to;
      ans += Min;
    }
    bool flag = false;
    int v;
    for (int i = cur[u]; i != -1; i = e[i].next) {
      v = e[i].to;
      if (e[i].cap > e[i].flow && d[v] + 1 == d[u]) {
        flag = true;
        cur[u] = i;
        break;
      }
    }
    if (flag) {
      S[top++] = cur[u];
      u = v;
      continue;
    }
    int Min = N;
    for (int i = head[u]; i != -1; i = e[i].next) {
      v = e[i].to;
      if (e[i].cap > e[i].flow && d[v] < Min) {
        Min = d[v];
        cur[u] = i;
      }
    }
    gap[d[u]]--;
    if (gap[d[u]] == 0) return ans;
    d[u] = Min + 1;
    gap[d[u]]++;
    if (u != st) u = e[S[--top] ^ 1].to;
  }
  return ans;
}
int main() {
  int n;
  scanf("%d", &n);
  int odd = 0, even = 0;
  if (n % 4 == 3) {
    for (int i = 1; i <= n; i++) {
      if (i == n / 2 + 1) {
        for (int j = 1; j <= n; j++) {
          printf("%d", (++odd) * 2 - 1);
          if (j != n)
            printf(" ");
          else
            printf("\n");
        }
        continue;
      }
      for (int j = 1; j <= n; j++) {
        if (j & 1)
          printf("%d", (++even) * 2);
        else
          printf("%d", (++odd) * 2 - 1);
        if (j != n)
          printf(" ");
        else
          printf("\n");
      }
    }
  } else {
    for (int i = 1; i <= n - 1; i++) mp[i][i] = 1;
    int s = 0, t = n + n + 1;
    init(t + 1);
    for (int i = 1; i <= n - 1; i++)
      addedge(s, i, n / 2), addedge(i + n, t, n / 2);
    for (int i = 1; i <= n - 1; i++)
      for (int j = 1; j <= n - 1; j++)
        if (i != j && i + j != n + 1) addedge(i, j + n, 1);
    sap(s, t);
    for (int i = 1; i <= n - 1; i++) {
      int cnt = 0;
      for (int j = head[i]; j != -1; j = e[j].next)
        if (e[j].cap > 0 && e[j].cap == e[j].flow)
          mp[e[j].to - n][i] = 1, cnt++;
    }
    mp[n][n] = 1;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (mp[i][j] == 1)
          printf("%d", (++odd) * 2 - 1);
        else
          printf("%d", (++even) * 2);
        if (j != n)
          printf(" ");
        else
          printf("\n");
      }
    }
  }
  return 0;
}