#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (!b) return a;
  return gcd(b, a % b);
}
int n;
map<long long, bool> mp;
long long a[510][510];
bool used[250050];
int p[250050], cnt;
long long calc(int i, int j) {
  long long res = 1, s;
  if (i > 1) res = res / gcd(res, a[i - 1][j]) * a[i - 1][j];
  if (i < 500) res = res / gcd(res, a[i + 1][j]) * a[i + 1][j];
  if (j > 1) res = res / gcd(res, a[i][j - 1]) * a[i][j - 1];
  if (j < 500) res = res / gcd(res, a[i][j + 1]) * a[i][j + 1];
  s = res;
  while (mp[s]) s += res;
  mp[s] = 1;
  if (s > 1e15) assert(0);
  return s;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= 62500; ++i) {
    p[++cnt] = 2 * i + 1;
    p[++cnt] = 4 * i + 2;
    mp[2 * i + 1] = 1, mp[4 * i + 2] = 1;
  }
  int st = 1, ed = 125000;
  for (int i = 1; i <= 499; i += 2)
    for (int j = 1; j <= 499; j += 2) {
      if ((i + j) & 3)
        a[i][j + 1] = p[st++], a[i + 1][j] = p[st++];
      else
        a[i][j + 1] = p[ed--], a[i + 1][j] = p[ed--];
    }
  for (int i = 1; i <= 500; ++i)
    for (int j = 2 - (i & 1); j <= 500; j += 2) a[i][j] = calc(i, j);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) printf("%lld ", a[i][j]);
    printf("\n");
  }
  return 0;
}
