#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define ll long long int #define pb push_back #define rep(i,n) for(int i=0;i<(n);i++) #define REP(i,n) for(int i=1;i<=(n);i++) using namespace std; int mx8[] = {0,0,1,-1,-1,1,-1,1}; int my8[] = {-1,1,0,0,-1,-1,1,1}; int mx4[] = {1,-1,0,0}; int my4[] = {0,0,-1,1}; const int MOD = 1000000007; int main() { int n; cin >> n; int a[n][n]; rep(i,n){ a[i][i] = i+1; rep(j,4){ a[i][(j+i+1)%(n+1)] = (i+j+2)%(n+1); } } rep(i,n){ rep(j,n){ if(a[i][j] == 0) a[i][j] = i; cout << a[i][j] << " "; } cout << endl; } }