import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { /* Solve Knight Problem with BFS */ public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); in.close(); // 2D DP int T[][] = new int[n-1][n-1]; for(int a=1;a edge = new LinkedList(); Node[][] graph = new Node[n][n]; for(int i=0;i=n||y>=n) continue; else if(graph[x][y].distance!=0) continue; else if(x==n-1&&y==n-1) return node.distance+1; else{ graph[x][y].distance=node.distance+1; edge.add(graph[x][y]); } } } return -1; } /* * print the solution */ static void printSolution(int[][] T) { int n=T.length; for(int i=0;i