#include <bits/stdc++.h>
using namespace std;
const int MN = 8000;
int n, pri[1001], cnt, vis[MN + 5], id[501][501][2];
unsigned __int128 a[501][501];
inline bool border(int i) { return (i == 1 || i == n); }
int main() {
  scanf("%d", &n);
  for (register int i = 2; i <= MN; i++) {
    if (!vis[i]) pri[++cnt] = i;
    if (cnt == 1000) break;
    for (register int j = 1; j <= cnt && pri[j] * i <= MN; j++) {
      vis[pri[j] * i] = 1;
      if (!(i % pri[j])) break;
    }
  }
  for (register int i = 1; i <= n; i++)
    for (register int j = 1; j <= n; j++)
      if ((~(i + j)) & 1) {
        id[i][j][0] = (i + j) >> 1;
        id[i][j][1] = n + (abs(i - j) >> 1) + 1;
      }
  for (register int i = 1; i <= n; i++)
    for (register int j = 1; j <= n; j++)
      if ((~(i + j)) & 1) {
        a[i][j] = 1ll * pri[id[i][j][0]] * pri[id[i][j][1]];
      } else {
        if (border(i) && border(j))
          if (i == 1)
            a[i][j] = 1ll * pri[id[2][n][0]] * pri[id[1][n - 1][0]] *
                      pri[id[1][n - 1][1]];
          else
            a[i][j] = 1ll * pri[id[n][2][0]] * pri[id[n - 1][1][0]] *
                      pri[id[n - 1][1][1]];
        else if (border(i))
          a[i][j] = 1ll * pri[id[i][j - 1][0]] * pri[id[i][j + 1][0]] *
                    pri[id[i][j - 1][1]] * pri[id[i][j + 1][1]];
        else
          a[i][j] = 1ll * pri[id[i - 1][j][0]] * pri[id[i + 1][j][0]] *
                    pri[id[i - 1][j][1]] * pri[id[i + 1][j][1]];
        a[i][j]++;
      }
  for (register int i = 1; i <= n; i++, puts(""))
    for (register int j = 1; j <= n; j++) printf("%d ", a[i][j]);
  return 0;
}
