#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector> red(n, vector(n)); vector> blue(n, vector(n)); vector used(2 * n + 1, 0); for (int row = 0; row < n; row++) { for (int col = 0; col < n; col++) { int sum = (row + 1) + (col + 1) - (n + 1); int diff = ((row + col) % 2 == 0) ? sum : -sum; int index = used[diff + n]++; if (diff >= 0) { red[row][col] = diff + 1 + index; blue[row][col] = 1 + index; } else { red[row][col] = 1 + index; blue[row][col] = 1 - diff + index; } } } for (int row = 0; row < n; row++) { for (int col = 0; col < n; col++) { if (col > 0) { cout << ' '; } cout << red[row][col]; } cout << '\n'; } for (int row = 0; row < n; row++) { for (int col = 0; col < n; col++) { if (col > 0) { cout << ' '; } cout << blue[row][col]; } cout << '\n'; } return 0; }