import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static class pos{ int x; int y; int move; pos(int x,int y,int move){ this.x=x; this.y=y; this.move=move; } } static void printShortestPath(int n1, int i_start, int j_start, int i_end, int j_end) { // Print the distance along with the sequence of moves. int[][] moves=new int[n1][n1]; pos[][] parent=new pos[n1][n1]; for(int i=0;i bfs=new LinkedList<>(); pos p=new pos(i_start,j_start,0); moves[i_start][j_start]=0; parent[i_start][j_start]=new pos(-1,-1,-1); bfs.add(p); boolean find = false; pos p2=new pos(-1,-1,-1); while(!bfs.isEmpty()){ pos temp= bfs.remove(); pos p3=parent[temp.x][temp.y]; //System.out.println(temp.x+" "+temp.y+" "+temp.move+" "+p3.x+" "+p3.y+" "+p3.move); if(check(temp,i_end,j_end)){ find=true; p2=temp; break; } else{ pos n=new pos(temp.x-2,temp.y-1,1); if(valid(n,moves)) { bfs.add(n); moves[n.x][n.y]=moves[temp.x][temp.y]+1; parent[n.x][n.y]=temp; } n=new pos(temp.x-2,temp.y+1,2); if(valid(n,moves)) { bfs.add(n); moves[n.x][n.y]=moves[temp.x][temp.y]+1; parent[n.x][n.y]=temp; } n=new pos(temp.x,temp.y+2,3); if(valid(n,moves)) { bfs.add(n); moves[n.x][n.y]=moves[temp.x][temp.y]+1; parent[n.x][n.y]=temp; } n=new pos(temp.x+2,temp.y+1,4); if(valid(n,moves)) { bfs.add(n); moves[n.x][n.y]=moves[temp.x][temp.y]+1; parent[n.x][n.y]=temp; } n=new pos(temp.x+2,temp.y-1,5); if(valid(n,moves)) { bfs.add(n); moves[n.x][n.y]=moves[temp.x][temp.y]+1; parent[n.x][n.y]=temp; } n=new pos(temp.x,temp.y-2,6); if(valid(n,moves)) { bfs.add(n); moves[n.x][n.y]=moves[temp.x][temp.y]+1; parent[n.x][n.y]=temp; } } } if(find){ //System.out.println(p2.x+" "+p2.y+" "+moves[p2.x][p2.y]); print(p2,parent,moves); } else System.out.println("Impossible"); } public static void print(pos p,pos[][] parent,int[][] moves){ System.out.println(moves[p.x][p.y]); Stack path=new Stack<>(); while(!check(parent[p.x][p.y],-1,-1)){ path.push(p.move); p=parent[p.x][p.y]; } while(!path.isEmpty()){ print2(path.pop()); } } public static void print2(int value){ if(value==1) System.out.print("UL "); else if(value==2) System.out.print("UR "); else if(value==3) System.out.print("R "); else if(value==4) System.out.print("LR "); else if(value==5) System.out.print("LL "); else System.out.print("L "); } public static boolean valid(pos p,int[][] moves){ if(p.x<0||p.y<0||p.x>=moves.length||p.y>=moves.length) return false; else if(moves[p.x][p.y]!=-1) return false; else return true; } public static boolean check(pos p,int i,int j){ if(p.x==i&&p.y==j) return true; else return false; } 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(); printShortestPath(n, i_start, j_start, i_end, j_end); in.close(); } }