fn main () { use std::io; // use std::mem; let mut input = String::new(); io::stdin().read_line(&mut input).expect(""); let n: usize = input.trim().parse::().unwrap(); let mut ans: Vec> = vec![vec![-1; n-1]; n-1]; fn bfs(x: usize, y: usize, a: i32, b: i32, m: &mut Vec>, n: usize) { for (dx, dy) in vec![(a, b), (a, -b), (b, a), (b, -a), (-a, -b), (-a, b), (-b, -a), (-b, a)] { let px = x as i32 + dx; let py = y as i32 + dy; if px < 0 || px >= n as i32 || py < 0 || py >= n as i32 { continue; } let i = px as usize; let j = py as usize; if m[ i ][ j ] == -1 || m[ i ][ j ] > m[ x ][ y ] + 1 { m[ i ][ j ] = m[ x ][ y ] + 1; bfs(i, j, a, b, m, n); } } } for a in 1..n { for b in 1..n { let mut m: Vec> = vec![vec![-1; n]; n]; m[ 0 ][ 0 ] = 0; bfs(0, 0, a as i32, b as i32, &mut m, n); ans[ a - 1][ b - 1] = m[ n - 1 ][ n - 1 ]; } } for i in 0..n-1 { for j in 0..n-1 { print!("{} ", ans[ i ][ j ]); } println!(""); } }