#include using namespace std; using ll = long long; int main() { int n; cin >> n; vector> a(n, vector(n)); vector id(n); for(int i = 0; i < n; i++)id[(i + i) % n] = i; for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { int rem = (i + j) % n; a[i][j] = id[rem]; } } for(int i = 0; i < n; i++){for(int j = 0; j < n; j++)cout << a[i][j] +1 << " ";cout << endl;} }