#include #define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i)) #define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i)) #define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i)) #define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i)) #define ALL(x) begin(x), end(x) #define dump(x) cerr << #x " = " << x << endl using ll = long long; using namespace std; template using reversed_priority_queue = priority_queue, greater >; template inline void chmax(T & a, U const & b) { a = max(a, b); } template inline void chmin(T & a, U const & b) { a = min(a, b); } template auto make_vectors(X x, T a) { return vector(x, a); } template auto make_vectors(X x, Y y, Z z, Zs... zs) { auto cont = make_vectors(y, z, zs...); return vector(x, cont); } template ostream & operator << (ostream & out, vector const & xs) { REP (i, (int)xs.size() - 1) out << xs[i] << ' '; if (not xs.empty()) out << xs.back(); return out; } int main() { int n; cin >> n; auto f = make_vectors(n, n, int()); int next = 1; REP (y, n / 2) { REP (x, n / 2) { f[y][x] = next ++; f[n / 2 + y][n / 2 + x] = next ++; } } REP (y, n / 2) { REP (x, n / 2) { f[y][n / 2 + x] = next ++; f[n / 2 + y][x] = next ++; } } REP (y, n) { cout << f[y] << endl; } return 0; }