#include #define rep(i,n) for(int i=0;i<(n);++i) #define rrep(i,n) for(int i=1;i<(n);++i) #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(),(a).rend() #define maxs(a, b) a = max(a, b) #define mins(a, b) a = min(a, b) using namespace std; template inline istream& operator >> (istream & c, vector & A) {rep(i, A.size()) c >> A[i];return c;} typedef long long ll; typedef pair P; const ll linf = (1ll << 61); const int inf = 1001001001; const int mod = 1000000007; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector> a(n, vector(n)); rep(i, n) { a[i][i] = i + 1; vector tmp; map mp; rep(j, n) mp[a[i][j]] = 1; rep(j, n) if (!mp[j + 1]) tmp.push_back(j + 1); if(tmp.size() >= 2) rotate(tmp.begin(), tmp.begin() + tmp.size() - 1, tmp.end()); for (int j = i + 1, pos = 0; j < n; ++j, pos++) a[i][j] = tmp[pos]; for (int j = i + 1, pos = 0; j < n; ++j, pos++) a[j][i] = tmp[pos]; } rep(i, n)rep(j, n) cout << a[i][j] << (j == n - 1 ? "\n" : " "); return 0; }