#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define len(x) (int)x.size()
#define all(x) x.begin(), x.end()

using namespace std;

//#define mtask

void solve(){
    int n;
    cin >> n;
    if (n == 2){
        cout << "-1\n";
        return;
    }
    if (n % 2 == 1){
        vector<vector<int>> ans(n, vector<int>(n));
        for(int x = 1; x <= n; ++x){
            int i = x - 1, j = x - 1;
            for(int t = 0; t < n; ++t){
                ans[i][j] = x;
                --i;
                ++j;
                if(i < 0){
                    i += n;
                }
                if(j == n) j -= n;
            }
        }
        for(auto x : ans){
            for(auto y : x){
                cout << y << ' ';
            }
            cout << '\n';
        }
    }
    else{
        for (int i = 0; i < n; ++i){
            if (i == 0 || i == n - 1) {
                for (int j = 0; j < n / 2; ++j) {
                    if ((j == n / 2 - 1) != (i == 0)) {
                        cout << j + 1 << ' ' << j + n / 2 + 1 << ' ';
                    } else {
                        cout << j + n / 2 + 1 << ' ' << j + 1 << ' ';
                    }
                }
                cout << '\n';
                continue;
            }
            vector<int> a(n);
            a[i] = i + 1;
            for (int j = 0; j < n - 1; ++j){
                a[(i + j + 1) % n] = j + (j >= i) + 1;
            }
            for (int j = 0; j < n; ++j){
                cout << a[j] << ' ';
            }
            cout << '\n';
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cout.precision(40);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
#ifdef mtask
    int t;
    cin >> t;
    while(t--)
#endif
    solve();
}