import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static int no,i_start,j_start,i_end,j_end;static int count=0; static int track=0; static LinkedHashMap hm1= new LinkedHashMap(); static LinkedHashMap hm2= new LinkedHashMap(); static void printAllKLength(String prefix, String set[], int nowi , int nowj ) { printAllKLengthRec(set, prefix,nowi, nowj); } static void printAllKLengthRec(String set[], String prefix, int nowi,int nowj ) { for (int i = 0; i < 6; ++i) { // {"UL", "UR", "R", "LR", "LL", "L"}; // Next character of input added int checki=nowi; int checkj=nowj; if(i==0) { checki=nowi-2; checkj= nowj-1; } else if(i==1) { checkj=nowj+1; checki=nowi-2; } else if(i==2) { checkj= nowj+2; } else if(i==3) { checkj=nowj+1; checki=nowi+2; } else if(i==4) { checkj=nowj-1; checki=nowi+2; } else if(i==5) { checkj=nowj-2; } // System.out.println("whoohere" + nowi +" "+nowj ); if(checki>=0 && checki<=no-1 && checkj>=0 && checkj<=no-1) { String nowPrefix = prefix+set[i]+" "; if(checki==i_end && checkj==j_end) { System.out.println(count); System.out.println(nowPrefix); System.exit(0); } if(track%2==0) hm2.put(nowPrefix,checki+"_"+checkj); else hm1.put(nowPrefix,checki+"_"+checkj); } } } static void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { String[] set1 = {"UL", "UR", "R", "LR", "LL", "L"}; hm1.clear(); hm2.clear(); count=1; printAllKLength("",set1,i_start,j_start); track++; for(int sth=0;sth<=5;sth++) { count++; if(track%2==1) { Set set = hm2.entrySet(); Iterator iterator = set.iterator(); while(iterator.hasNext()) { Map.Entry mentry = (Map.Entry)iterator.next(); String prefix= (String)mentry.getKey(); String indices=(String)mentry.getValue(); String[] ic= indices.split("_"); i_start=Integer.parseInt(ic[0]); j_start=Integer.parseInt(ic[1]); printAllKLength(prefix, set1,i_start,j_start); } hm2.clear(); } else{ Set set = hm1.entrySet(); Iterator iterator = set.iterator(); while(iterator.hasNext()) { Map.Entry mentry = (Map.Entry)iterator.next(); String prefix= (String)mentry.getKey(); String indices=(String)mentry.getValue(); String[] ic= indices.split("_"); i_start=Integer.parseInt(ic[0]); j_start=Integer.parseInt(ic[1]); printAllKLength(prefix, set1,i_start,j_start); } hm1.clear(); } track++; } System.out.println("Impossible"); } // public static void main(String[] args) { Scanner in = new Scanner(System.in); no = in.nextInt(); i_start = in.nextInt(); j_start = in.nextInt(); i_end = in.nextInt(); j_end = in.nextInt(); printShortestPath(no, i_start, j_start, i_end, j_end); in.close(); } }