import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; import java.util.*; import java.util.function.Predicate; import java.util.stream.Collectors; public class Solution { static final Pair start = new Pair(0, 0); static int GRID_SIZE; public static void main(String[] args) { Scanner in = new Scanner(System.in); GRID_SIZE = in.nextInt(); Pair end = new Pair(GRID_SIZE - 1, GRID_SIZE - 1); for (int i = 1; i < GRID_SIZE; i++) { for (int j = 1; j < GRID_SIZE; j++) { Pair jump = new Pair(i,j); canReach(end, jump); } System.out.println(); } } private static void canReach(Pair end, Pair jump) { Set positions = new HashSet<>(GRID_SIZE*GRID_SIZE); positions.add(start); Predicate valid = pair -> { return pair.a >= 0 && pair.a < GRID_SIZE && pair.b >= 0 && pair.b < GRID_SIZE; }; int turns = 0; Set visited = new HashSet<>(GRID_SIZE*GRID_SIZE); while (!positions.isEmpty()) { Set newPositions = new HashSet<>(positions.size() * positions.size()); positions.forEach(pair -> newPositions.addAll(pair.validJumps(jump, valid))); visited.addAll(positions); turns++; if (newPositions.contains(end)) { System.out.print(turns + " "); return; } newPositions.removeAll(visited); positions = newPositions; } System.out.print("-1 "); } static class Pair { int a, b; public Pair(int a, int b) { this.a = a; this.b = b; } @Override public String toString() { return String.format("(%d,%d)", a, b); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Pair pair = (Pair) o; if (a != pair.a) return false; return b == pair.b; } @Override public int hashCode() { int result = a; result = 31 * result + b; return result; } public Set validJumps(Pair jump, Predicate valid) { return Arrays.stream(new Pair[]{ new Pair(a + jump.a, b + jump.b), new Pair(a + jump.a, b - jump.b), new Pair(a - jump.a, b + jump.b), new Pair(a - jump.a, b - jump.b), new Pair(a + jump.b, b + jump.a), new Pair(a + jump.b, b - jump.a), new Pair(a - jump.b, b + jump.a), new Pair(a - jump.b, b - jump.a) }).filter(valid).collect(Collectors.toSet()); } } }