#include using namespace std; using Vi = vector; using VVi = std::vector> ; int main () { int N; cin >> N; if (N == 1) { cout << -1 << endl; return 0; } VVi ans1 = { { 7, 14, 0, 8}, { 4, 12, 2, 11}, {15, 9, 6, 1}, {13, 10, 5, 3} }; VVi ans0 = { { 7, 14, 1, 8}, { 4, 13, 2, 11}, {15, 9, 6, 0}, {12, 10, 5, 3} }; for (int i = 3; i <= N; i ++) { VVi A0((1 << i), Vi(1 << i)), A1((1 << i), Vi(1 << i)); for (int a = 0; a < 4; a ++) { int I = a / 2, J = a & 1; int s = a << (i * 2 - 2); int x = (1 << (i - 1)); for (int p = 0; p < x; p ++) { for (int q = 0; q < x; q ++) { A0[p + x * I][q + x * J] = s | ans0[p][q]; A1[p + x * I][q + x * J] = s | (I == J ? ans1 : ans0)[p][q]; } } } ans0 = A0; ans1 = A1; } for (auto& a : ans1) { for (auto& b : a) { cout << b << " "; } cout << endl; } }