#include using namespace std; typedef long long ll; typedef pair l_l; typedef pair i_i; template inline bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } template inline bool chmin(T &a, T b) { if(a > b) { a = b; return true; } return false; } const long long INF = 1e18; //const ll mod = 1000000007; ll ans[500][500]; int main() { cin.tie(0); ios::sync_with_stdio(false); ll N; cin >> N; for(int i = 0; i < N; i++) { for(int j = 0; j < N; j++) { ans[(i+j)%N][j] = (2 * i + j)%N; } } for(int i = 0; i < N; i++) { for(int j = 0; j < N; j++) { if(j != 0) cout << " "; cout << ans[i][j] + 1; } cout << endl; } return 0; }