process.stdin.resume(); process.stdin.setEncoding('ascii'); var input_stdin = ""; var input_stdin_array = ""; var input_currentline = 0; process.stdin.on('data', function (data) { input_stdin += data; }); process.stdin.on('end', function () { input_stdin_array = input_stdin.split("\n"); main(); }); function readLine() { return input_stdin_array[input_currentline++]; } /////////////// ignore above this line //////////////////// function main() { var n = parseInt(readLine()); // your code goes here let graph = new Array(n).fill(99999) for(let i = 0;i < n; i++) { graph[i] = new Array(n).fill(99999) } let originalGraph = JSON.stringify(graph) function isValidPos(x, y) { return x >= 0 && x < n && y>= 0 && y < n } let superAns = [] for(let i = 1;i < n; i++) { let ans = [] for(let z = 1; z < i; z++) { ans.push(superAns[z-1][i-1]) } for(let j = i;j < n; j++) { let positions = [{x: 0, y: 0}] graph[0][0] = 1 for(let moves = 1; positions.length; moves++) { let newPositions = [] for(let k = 0;k < positions.length; k++) { if(isValidPos(positions[k].x + i, positions[k].y + j)) { if(graph[positions[k].x + i][positions[k].y + j] > moves) { graph[positions[k].x + i][positions[k].y + j] = moves newPositions.push({x: positions[k].x + i, y: positions[k].y + j}) } if(positions[k].x + i === n - 1 && positions[k].y + j === n - 1) { newPositions = [] break } } if(isValidPos(positions[k].x + i, positions[k].y - j)) { if(graph[positions[k].x + i][positions[k].y - j] > moves) { graph[positions[k].x + i][positions[k].y - j] = moves newPositions.push({x: positions[k].x + i, y: positions[k].y - j}) } if(positions[k].x + i === n - 1 && positions[k].y - j === n - 1) { newPositions = [] break } } if(isValidPos(positions[k].x - i, positions[k].y + j)) { if(graph[positions[k].x - i][positions[k].y + j] > moves) { graph[positions[k].x - i][positions[k].y + j] = moves newPositions.push({x: positions[k].x - i, y: positions[k].y + j}) } if(positions[k].x - i === n - 1 && positions[k].y + j === n - 1) { newPositions = [] break } } if(isValidPos(positions[k].x - i, positions[k].y - j)) { if(graph[positions[k].x - i][positions[k].y - j] > moves) { graph[positions[k].x - i][positions[k].y - j] = moves newPositions.push({x: positions[k].x - i, y: positions[k].y - j}) } if(positions[k].x - i === n - 1 && positions[k].y - j === n - 1) { newPositions = [] break } } if(isValidPos(positions[k].x + j, positions[k].y + i)) { if(graph[positions[k].x + j][positions[k].y + i] > moves) { graph[positions[k].x + j][positions[k].y + i] = moves newPositions.push({x: positions[k].x + j, y: positions[k].y + i}) } if(positions[k].x + j === n - 1 && positions[k].y + i === n - 1) { newPositions = [] break } } if(isValidPos(positions[k].x + j, positions[k].y - i)) { if(graph[positions[k].x + j][positions[k].y - i] > moves) { graph[positions[k].x + j][positions[k].y - i] = moves newPositions.push({x: positions[k].x + j, y: positions[k].y - i}) } if(positions[k].x + j === n - 1 && positions[k].y - i === n - 1) { newPositions = [] break } } if(isValidPos(positions[k].x - j, positions[k].y + i)) { if(graph[positions[k].x - j][positions[k].y + i] > moves) { graph[positions[k].x - j][positions[k].y + i] = moves newPositions.push({x: positions[k].x - j, y: positions[k].y + i}) } if(positions[k].x - j === n - 1 && positions[k].y + i === n - 1) { newPositions = [] break } } if(isValidPos(positions[k].x - j, positions[k].y - i)) { if(graph[positions[k].x - j][positions[k].y - i] > moves) { graph[positions[k].x - j][positions[k].y - i] = moves newPositions.push({x: positions[k].x - j, y: positions[k].y - i}) } if(positions[k].x - j === n - 1 && positions[k].y - i === n - 1) { newPositions = [] break } } } positions = newPositions } if(graph[n - 1][n - 1] === 99999) { ans.push(-1) } else { ans.push(graph[n - 1][n - 1]) } graph = JSON.parse(originalGraph) } console.log(ans.join(' ')) superAns.push(ans) ans = [] } }