import java.util.Scanner; public class KNightL { public static void main(String[] args) throws Exception { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); long a[][] = new long[n][n]; for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) { int xMoves = i; int yMoves = j; int currX = 0; int curry = 0; for (int q = 0; q < n; q++) { for (int r = 0; r < n; r++) { a[q][r] = Integer.MAX_VALUE; } } a[0][0] = 0; boolean x = true; while (x) { x = false; for (int k = 0; k < n; k++) { currX = k; for (int l = 0; l < n; l++) { curry = l; long value = a[currX][curry]; int x1; int y1; x1 = currX + xMoves; y1 = curry + yMoves; x = x || add(a, x1, y1, value); x1 = currX + xMoves; y1 = curry - yMoves; x = x || add(a, x1, y1, value); x1 = currX - xMoves; y1 = curry + yMoves; x = x || add(a, x1, y1, value); x1 = currX - xMoves; y1 = curry - yMoves; x = x || add(a, x1, y1, value); x1 = currX + yMoves; y1 = curry + xMoves; x = x || add(a, x1, y1, value); x1 = currX + yMoves; y1 = curry - xMoves; x = x || add(a, x1, y1, value); x1 = currX - yMoves; y1 = curry + xMoves; x = x || add(a, x1, y1, value); x1 = currX - yMoves; y1 = curry - xMoves; x = x || add(a, x1, y1, value); } } } if (a[n - 1][n - 1] >= Integer.MAX_VALUE) { System.out.print(-1 + " "); } else { System.out.print(a[n - 1][n - 1] + " "); } } System.out.println(); } } private static boolean add(long[][] a, int x, int y, long value) { if (x < a.length && y < a.length && x >= 0 && y >= 0) { if (value + 1 < a[x][y]) { a[x][y] = Math.min(value + 1, a[x][y]); return true; } } return false; } }