#include using i64 = long long; constexpr int pattern[4][4] = { {7, 14, 0, 8}, {4, 12, 2, 11}, {15, 9, 6, 1}, {13, 10, 5, 3} }; int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; std::cin >> n; if (n == 1) { std::cout << -1 << "\n"; return 0; } std::vector a(1 << n, std::vector(1 << n)); int cur = 0; for (int i = 0; i < (1 << n); i += 4) { for (int j = 0; j < (1 << n); j += 4) { for (int x = 0; x < 4; x++) { for (int y = 0; y < 4; y++) { if (i == j) { a[i + x][j + y] = cur + pattern[x][y]; } else { a[i + x][j + y] = cur + x * 4 + y; } } } cur += 16; } } for (int i = 0; i < (1 << n); i++) { for (int j = 0; j < (1 << n); j++) { std::cout << a[i][j] << " \n"[j == (1 << n) - 1]; } } return 0; }