#include using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() using ll = long long; constexpr int INF = 0x3f3f3f3f; constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr double EPS = 1e-8; constexpr int MOD = 998244353; // constexpr int MOD = 1000000007; constexpr int DY4[]{1, 0, -1, 0}, DX4[]{0, -1, 0, 1}; constexpr int DY8[]{1, 1, 0, -1, -1, -1, 0, 1}; constexpr int DX8[]{0, -1, -1, -1, 0, 1, 1, 1}; template inline bool chmax(T& a, U b) { return a < b ? (a = b, true) : false; } template inline bool chmin(T& a, U b) { return a > b ? (a = b, true) : false; } struct IOSetup { IOSetup() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << fixed << setprecision(20); } } iosetup; int main() { int n; cin >> n; if (n == 1) { cout << "-1\n"; return 0; } vector> a{ {7, 14, 0, 8}, {4, 12, 2, 11}, {15, 9, 6, 1}, {13, 10, 5, 3} }; FOR(m, 2, n) { vector b(2 << m, vector(2 << m, 0)); REP(i, 1 << m) copy(ALL(a[i]), b[i].begin()); REP(i, 1 << m) REP(j, 1 << m) b[(1 << m) + i][(1 << m) + j] = a[i][j] + (1 << (m * 2)); REP(i, 1 << m) iota(next(b[i].begin(), 1 << m), b[i].end(), (2 << (m * 2)) + (1 << m) * i); REP(i, 1 << m) iota(b[(1 << m) + i].begin(), next(b[(1 << m) + i].begin(), 1 << m), (3 << (m * 2)) + (1 << m) * i); a.swap(b); } REP(i, 1 << n) REP(j, 1 << n) cout << a[i][j] << " \n"[j + 1 == (1 << n)]; return 0; }