mod = 998244353 def main(): import sys input = sys.stdin.readline N = int(input()) if N == 1: print(-1) exit() NN = 2 ans = [ [7, 14, 0, 8], [4, 12, 2, 11], [15, 9, 6, 1], [13, 10, 5, 3] ] while NN < N: L = len(ans) LL = L * L ans_new = [[0] * (L * 2) for _ in range(L * 2)] for i in range(L): for j in range(L): ans_new[i][j] = ans[i][j] ans_new[i+L][j+L] = ans[i][j] + LL ans_new[i][j+L] = LL * 2 + i * L + j ans_new[i+L][j] = LL * 3 + i * L + j ans = ans_new NN += 1 for line in ans: print(*line) L = len(ans) for i in range(L): x = 0 for j in range(L): x ^= ans[i][j] assert x == 1 for j in range(L): x = 0 for i in range(L): x ^= ans[i][j] assert x == 1 if __name__ == '__main__': main()