import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static class Node { public int x = 0, y = 0; public boolean opened = false; public Node parent = null; public Node(){} public Node(int x, int y){this.x=x;this.y=y;} } static void open(Node parent, int a, int b) { try { Node n = map[a][b]; if (n.opened) return; n.opened = true; n.parent = parent; opening.add(n); } catch (Exception e) {} } static int n = 0; static Node[][] map; static ArrayList opening; static void solve(int a, int b) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { map[i][j] = new Node(i, j); } } Node start = map[0][0]; start.opened = true; opening = new ArrayList(); opening.add(start); boolean found = false; while (opening.size() > 0) { Node cur = opening.get(0); opening.remove(0); if (cur == map[n-1][n-1]) { found = true; break; } open(cur, cur.x + a, cur.y + b); open(cur, cur.x - a, cur.y + b); open(cur, cur.x + a, cur.y - b); open(cur, cur.x - a, cur.y - b); open(cur, cur.x + b, cur.y + a); open(cur, cur.x - b, cur.y + a); open(cur, cur.x + b, cur.y - a); open(cur, cur.x - b, cur.y - a); } if (!found) { System.out.print("-1 "); return; } int count = 0; Node end = map[n-1][n-1]; while (end.parent != null) { count++; end = end.parent; } System.out.print(count + " "); } public static void main(String[] args) { Scanner in = new Scanner(System.in); n = in.nextInt(); // your code goes here map = new Node[n][n]; for (int i = 1; i < n; i++) { for (int j = 1; j < n; j++) { solve(i,j); } System.out.println(); } } }