#include #define ll long long #define mp make_pair #define sz(a) (int)(a.size()) #define pp pop_back #define pb push_back const int inf = (int)1e9 + 123; using namespace std; int n; int mn; int d[30][30]; void rec(int a, int b, int turn = 0, int i = 0, int j = 0) { if(i >= n || j >= n || i < 0 || j < 0) return; if(d[i][j] != -1 && d[i][j] <= turn) return; d[i][j] = turn; if(i == n - 1 && j == n - 1) { mn = min(mn, turn); return; } rec(a, b, turn + 1, i + a, j + b); rec(a, b, turn + 1, i + a, j - b); rec(a, b, turn + 1, i - a, j + b); rec(a, b, turn + 1, i - a, j - b); rec(a, b, turn + 1, i + b, j + a); rec(a, b, turn + 1, i + b, j - a); rec(a, b, turn + 1, i - b, j + a); rec(a, b, turn + 1, i - b, j - a); } int res[30][30]; int main() { cin >> n; for(int i = 1; i < n; i ++) { for(int j = 1; j < i; j ++) cout << res[i][j] << " "; for(int j = i; j < n; j ++) { memset(d, -1, sizeof d); mn = inf; rec(i, j); res[i][j] = res[j][i] = mn; if(mn == inf) { res[i][j] = res[j][i] = -1; cout << -1 << " "; } else cout << mn << " "; } cout << "\n"; } return 0; }