#include using namespace std; int main() { int n; cin >> n; int A[n+1][n+1], x = 1; for (int i = 1; i <= n/2; i++) { for (int j = 1; j <= n; j += 2) { A[i][j] = x++; A[i+n/2][j+1] = x++; } for (int j = 1; j <= n; j += 2) { A[i+n/2][j] = x++; A[i][j+1] = x++; } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) cout << A[i][j] << ' '; cout << endl; } }