import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static Map steps; static Map history; static boolean isVisited[][]; static int i_end; static int j_end; static void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { // Print the distance along with the sequence of moves. history = new HashMap(); steps = new LinkedHashMap(); steps.put("UL",new Pair(-2,-1)); steps.put("UR",new Pair(-2,1)); steps.put("R",new Pair(0,2)); steps.put("LR",new Pair(2,1)); steps.put("LL",new Pair(2,-1)); steps.put("L",new Pair(0,-2)); isVisited = new boolean[n][n]; Queue q = new ArrayDeque(); //Impossible check if(!(Math.abs(i_end-i_start)%4==0 && Math.abs(j_end-j_start)%2==0) && !(Math.abs(i_end-i_start)%4==2 && Math.abs(j_end-j_start)%2==1)){ System.out.println("Impossible"); return; } q.add(new Pair(i_start,j_start)); history.put(i_start +"-"+j_start,""); while(!q.isEmpty()){ Pair p = q.poll(); //System.out.println(p.i+"-"+p.j); Pair sp = null; if(p.i==i_end&&p.j==j_end){ break; } for(String npkey:steps.keySet()){ sp = steps.get(npkey); Pair np = new Pair(p.i+sp.i,p.j+sp.j); if(np.i>=0 && np.i=0 && np.j