import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; class Node implements Comparable { Stack al ; int path_length; Node(Stack all,int count){ al = (Stack)all.clone(); //while(all.) path_length = count; } int getQuantity(){ return path_length; } public int compareTo(Node compareFruit) { int compareQuantity = ((Node) compareFruit).getQuantity(); //ascending order return (this.path_length - compareQuantity); //descending order //return compareQuantity - this.quantity; } } public class Solution { static ArrayList list ; static int minn =0; //static Stack st ; static boolean issafe(int x,int y, int n){ if((x=0)&&(y=0)) return true; return false; } static void dfs1(int n,int i_start,int j_start,int i_end,int j_end,String str,int count,boolean[][] visited,Stack al){ if(count>=minn) return; if(!issafe(i_start,j_start,n)) return ; if(visited[i_start][j_start]) return ; visited[i_start][j_start] = true; al.push(str); if(i_start==i_end&&j_start==j_end) {list.add(new Node(al,count)); if(count()); dfs1(n,i_start-2,j_start+1,i_end,j_end,"UR",1,visited,new Stack()); dfs1(n,i_start,j_start+2,i_end,j_end,"R",1,visited,new Stack()); dfs1(n,i_start+2,j_start+1,i_end,j_end,"LR",1,visited,new Stack()); dfs1(n,i_start+2,j_start-1,i_end,j_end,"LL",1,visited,new Stack()); dfs1(n,i_start,j_start-2,i_end,j_end,"L",1,visited,new Stack()); return; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int i_start = in.nextInt(); int j_start = in.nextInt(); int i_end = in.nextInt(); int j_end = in.nextInt(); list = new ArrayList(); minn = Integer.MAX_VALUE; printShortestPath(n, i_start, j_start, i_end, j_end); //Collections.sort(list); int tt = list.size(); // System.out.println(tt+" hehehehe"); //int ii=0; int min = Integer.MAX_VALUE; int min_ind = 0; for(int i=0;i0) { Node nn = list.get(min_ind); int num = nn.path_length; Stack st = nn.al; Stack st2 = new Stack(); System.out.println(num); while(st.size()>0){ st2.add(st.pop()); } while(st2.size()>0){ System.out.print(st2.pop()+" "); } System.out.println();} else System.out.println("Impossible"); //Syste in.close(); } }