import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { private static int numMoves(int a, int b, int n){ int moves = 0; int[][] grid = new int[n][n]; for(int i=0; in-1 || y>n-1){return;} if(grid[x][y]!=-1 && grid[x][y]<=count){return;} grid[x][y]=count; subNumMoves(a, b, n, grid, x+a, y+b, count+1); subNumMoves(a, b, n, grid, x+a, y-b, count+1); subNumMoves(a, b, n, grid, x-a, y+b, count+1); subNumMoves(a, b, n, grid, x-a, y-b, count+1); subNumMoves(a, b, n, grid, x+b, y+a, count+1); subNumMoves(a, b, n, grid, x+b, y-a, count+1); subNumMoves(a, b, n, grid, x-b, y+a, count+1); subNumMoves(a, b, n, grid, x-b, y-a, count+1); } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); in.close(); // your code goes here int[][] arr = new int[n-1][n-1]; for(int a=1; a((n-1)/2) && b>((n-1)/2)){ moves = -1; } else if(a==1 && b==(n-1)){ if((n-1)%2==0){moves = 2*(n-1);} else{moves = n-1;} } else if(a==2 && b==(n-1) && (n-1)%2==1){moves = -1;} else{ moves = numMoves(a,b,n);//recursion here } if(b>a){ arr[a-1][b-1] = moves; } System.out.print(moves + " "); } System.out.println(); } //System.out.println("test"); } }