#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
int main() {
  int n, x = 0;
  scanf("%d", &n);
  for (int i = 1; i <= (n * n) >> 1; ++i) {
    printf("%d ", x);
    x += 2;
    if (i % n == 0) puts("");
  }
  x = 1;
  for (int i = 1; i <= (n * n) >> 1; ++i) {
    printf("%d ", x);
    x += 2;
    if (i % n == 0) puts("");
  }
  return 0;
}
