#include using namespace std; int main() { int N; cin >> N; vector> a( N, vector( N ) ); for( int i = 0; i < N; i++ ) a[0][i] = i; for( int i = 1; i < N; i++ ) { for( int j = 0; j < N; j++ ) { a[i][j] = (a[i - 1][j] + 1) % N; } } for( int i = 0; i < N; i++ ) { for ( int j = 0; j < N; j++ ) { if( j ) cout << " "; cout << a[i][j] + 1; } cout << endl; } }