#include <bits/stdc++.h>
using namespace std;
int a[3000][3000];
int sum;
int check(int n) {
  int i, j, sum1 = 0, sum2 = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) sum1 += a[i][j];
    if (sum1 != sum) return 0;
    sum1 = 0;
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) sum1 += a[i][j];
    if (sum1 != sum) return 0;
    sum1 = 0;
  }
  for (sum1 = 0, sum2 = 0, i = 0, j = 0; i < n; i++, j++) {
    sum1 += a[i][j];
    sum2 += a[i][n - j + 1];
  }
  if (sum1 != sum) return 0;
  if (sum2 != sum)
    return 0;
  else
    return 1;
}
void ins(int n) {
  int x, y, m;
  x = 0;
  y = n / 2;
  for (m = 1; m <= n * n; m++) {
    a[x][y] = m;
    if (m % n != 0) {
      x--;
      y++;
      if (x < 0) x = x + n;
      if (y == n) y = n - y;
    } else {
      x++;
      if (x == n) x = x - n;
    }
  }
}
int main() {
  int i, j, n, k, t, p, x;
  while (scanf("%d", &n) != EOF) {
    sum = (n * n + 1) * n / 2;
    if (n % 2 == 1) ins(n);
    if (n % 4 == 2) {
      k = n / 2;
      ins(k);
      for (i = 0; i < k; i++) {
        for (j = 0; j < k; j++) {
          a[i][j + k] = a[i][j] + 2 * k * k;
          a[i + k][j] = a[i][j] + 3 * k * k;
          a[i + k][j + k] = a[i][j] + k * k;
        }
      }
      t = (n - 2) / 4;
      for (i = 0; i < k; i++) {
        for (j = 0; j < k; j++) {
          if ((j < t) && (i < t)) {
            p = a[i][j];
            a[i][j] = a[i + k][j];
            a[i + k][j] = p;
          }
          if ((j < t) && (i > k - t - 1)) {
            p = a[i][j];
            a[i][j] = a[i + k][j];
            a[i + k][j] = p;
          }
          if ((i >= t && i <= k - t - 1) && (j >= t && j < t * 2)) {
            p = a[i][j];
            a[i][j] = a[i + k][j];
            a[i + k][j] = p;
          }
          if ((j > 1) && (j <= t)) {
            p = a[i][j];
            a[i][j] = a[i + k][j];
            a[i + k][j] = p;
          }
        }
      }
    }
    if (n % 4 == 0) {
      x = 1;
      for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
          a[i][j] = x++;
        }
      }
      for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
          if (i % 4 == 0 && abs(i - j) % 4 == 0) {
            for (k = 0; k < 4; k++) {
              a[i + k][j + k] = n * n - a[i + k][j + k] + 1;
            }
          } else if (i % 4 == 3 && (i + j) % 4 == 3) {
            for (k = 0; k < 4; k++) {
              a[i - k][j + k] = n * n - a[i - k][j + k] + 1;
            }
          }
        }
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (j == 0) {
          printf("%d", a[i][j]);
        } else
          printf(" %d", a[i][j]);
      }
      printf("\n");
    }
  }
  return 0;
}
