#include typedef int integer; #define int long long #define pb push_back #define mp make_pair #define sz(x) (int) (x).size() using namespace std; int vis[30][30]; vector x; vector y; int n; int solve(int posX, int posY, int steps){ if (vis[posX][posY] != -1 && steps >= vis[posX][posY]) return 1e15; vis[posX][posY] = steps; if (posX == n-1 && posY == n-1) { return steps; } int ans = 1e15; for (int j = 0; j < 8; j++){ int xx = posX, yy = posY; xx += x[j]; yy += y[j]; if (xx < 0 || xx >= n || yy < 0 || yy >= n)continue; ans = min(ans, solve(xx, yy, steps+1)); } return ans; } integer main(){ ios_base::sync_with_stdio(false); cin >> n; for (int i = 1; i <= n-1; i++){ for (int j = 1; j <= n-1; j++){ memset(vis, -1, sizeof vis); x = {i, i, -i, -i, j, j, -j, -j}; y = {j, -j, j, -j, i, -i, i, -i}; int ans = solve(0, 0, 0); if (ans > 1e12){ cout << -1; } else { cout << ans; } if (j < n-1){ cout << ' '; } } cout << endl; } }