#include #include #include #include #include #include using namespace std; int main() { int n; cin >> n; vector> ans (n-1, vector (n-1)); for(int a = 1; a < n; ++a) { for(int b = a; b < n; ++b) { vector steps {-a, a, -b, b}; vector> board(n, vector(n, -1)); board[n-1][n-1] = 0; queue> positions; positions.push(vector {n - 1 , n - 1}); bool flag = false; while(!positions.empty()) { vector currPos = positions.front(); positions.pop(); int x = currPos[0]; int y = currPos[1]; int val = board[x][y]; for(int i = 0; i < 4; ++i) { int xstep = steps[i]; for(int j = -1; j < 2; j+= 2) { int ystep; if (i < 2) ystep = j * b; else ystep = j * a; int xpos = x + xstep; int ypos = y + ystep; if(!(xpos < 0 || xpos >= n || ypos < 0 || ypos >= n)) { if(board[xpos][ypos] == -1) { board[xpos][ypos] = val + 1; positions.push(vector {xpos, ypos}); } if (xpos == 0 && ypos == 0) { flag = true; break; } } } if (flag) break; } if(flag) break; } ans[a-1][b-1] = board[0][0]; ans[b-1][a-1] = board[0][0]; } } for(int i = 0; i < n-1; ++i) { for(int j = 0; j < n-1; ++j) cout << ans[i][j] << " "; cout << endl; } return 0; }