#include using namespace std; #define all(v) (v).begin(),(v).end() #define pb emplace_back #define rep(i, n) for(int i=0;i<(n);i++) #define foa(e, v) for(auto& e : v) #define dout(a) cout< using pqr = priority_queue, greater>; template inline bool chmax(T1 &a, T2 b) { bool compare = a < b; if(compare) a = b; return compare; } template inline bool chmin(T1 &a, T2 b) { bool compare = a > b; if(compare) a = b; return compare; } template inline T back(std::set &s) { return *s.rbegin(); } template inline T back(std::multiset &s) { return *s.rbegin(); } template inline T pop_back(std::set &s) { auto it = prev(s.end()); T val = *it; s.erase(it); return val; } template inline T pop_back(std::multiset &s) { auto it = prev(s.end()); T val = *it; s.erase(it); return val; } const int dy[8] = {-1, 0, 0, 1, 1, -1, 1, -1}; const int dx[8] = {0, -1, 1, 0, -1, -1, 1, 1}; const ll MOD7 = 1000000007, MOD998 = 998244353, INF = (3LL << 59); const int inf = 1 << 30; const char br = '\n'; void solve() { int n; cin >> n; vector>> v(n + n); int m = n - 1; for(int i = 1; i <= n; i ++) { for(int j = 1; j <= n; j ++) { v[i - j + m].pb(i, j); } } vector a(n, vector(n, 0)), b(n, vector(n, 0)); vector c(n, vector(n, 0)); c[0][0] = -n + 1; c[n - 1][n - 1] = n - 1; rep(i, n) rep(j, n) { if(i + j < n - 1) { int num = c[i][j]; if(num > 0) num --; else num ++; num = -num; c[i + 1][j] = c[i][j + 1] = num; } } for(int i = n - 1; i >= 0; i --) { for(int j = n - 1; j >= 0; j --) { if(i + j > n) { int num = c[i][j]; if(num > 0) num --; else num ++; num = -num; c[i - 1][j] = c[i][j - 1] = num; } } } rep(i, n) rep(j, n) { auto [x, y] = v[c[i][j] + m].back(); v[c[i][j] + m].pop_back(); a[i][j] = x; b[i][j] = y; } rep(i, n) { foa(e, a[i]) cout << e << " "; cout << endl; }rep(i, n) { foa(e, b[i]) cout << e << " "; cout << endl; } } int main() { cin.tie(0); ios::sync_with_stdio(false); int testcase = 1; // cin >> testcase; while(testcase --) solve(); return 0; }