#include using namespace std; vector> solve0(int N){ vector> ans(1 << N, vector(1 << N)); for (int i = 0; i < (1 << N); i++){ for (int j = 0; j < (1 << N); j++){ ans[i][j] = (i << N) | j; } } return ans; } vector> solve1(int N){ if (N == 2){ return {{7, 14, 0, 8}, {4, 12, 2, 11}, {15, 9, 6, 1}, {13, 10, 5, 3}}; } else { vector> A = solve0(N - 1); vector> B = solve1(N - 1); vector> ans(1 << N, vector(1 << N)); for (int i = 0; i < (1 << (N - 1)); i++){ for (int j = 0; j < (1 << (N - 1)); j++){ ans[i][j] = B[i][j]; ans[i][(1 << (N - 1)) + j] = A[i][j] + (1 << (N * 2 - 2)); ans[(1 << (N - 1)) + i][j] = A[i][j] + (1 << (N * 2 - 1)); ans[(1 << (N - 1)) + i][(1 << (N - 1)) + j] = B[i][j] + (1 << (N * 2 - 2)) + (1 << (N * 2 - 2)); } } return ans; } } int main(){ int N; cin >> N; if (N == 1){ cout << -1 << endl; } else { vector> ans = solve1(N); for (int i = 0; i < (1 << N); i++){ for (int j = 0; j < (1 << N); j++){ cout << ans[i][j]; if (j < (1 << N) - 1){ cout << ' '; } } cout << endl; } } }