import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static class Point { private int x; private int y; public Point(int xg, int yg){ x = xg; y = yg; } } public static int x[] = {-2,-2,0,2,2,0}; public static int y[] = {-1,1,2,1,-1,-2}; public static String printPostion(int n){ if(n==0){ return "UL"; } if(n==1){ return "UR"; } if(n==2){ return "R"; } if(n==3){ return "LR"; } if(n==4){ return "LL"; } if(n==5){ return "L"; } return ""; } public static boolean isValid(int i, int j, int n){ if(i=0 && j>=0 && j queue = new LinkedList(); boolean visited[][] = new boolean[n][n]; int distance[][] = new int[n][n]; Point parent[][] = new Point[n][n]; int position[][] = new int[n][n]; int i; position[iStart][jStart] = -1; parent[iStart][jStart] = new Point(-1,-1); distance[iStart][jStart] = 0; visited[iStart][jStart] = true; queue.add(new Point(iStart,jStart)); while(queue.size() != 0){ Point s = queue.poll(); for (i = 0; i<6; ++i) { int xc = s.x + x[i]; int yc = s.y + y[i]; if(isValid(xc, yc, n) && visited[xc][yc] == false){ queue.add(new Point(xc,yc)); position[xc][yc] = i; parent[xc][yc] = new Point(s.x,s.y); distance[xc][yc] = distance[s.x][s.y] + 1; visited[xc][yc] = true; } if(s.x == iEnd && s.y == jEnd){ System.out.println(distance[iEnd][jEnd]); int xcoo = s.x; int ycoo = s.y; Stack stack = new Stack(); while(parent[xcoo][ycoo].x != -1 && parent[xcoo][ycoo].y != -1){ stack.push(printPostion(position[xcoo][ycoo])); int temp = xcoo; xcoo = parent[xcoo][ycoo].x; ycoo = parent[temp][ycoo].y; } while(!stack.empty()){ System.out.print(stack.pop()+" "); } System.out.println(); return; } } } System.out.println("Impossible"); } 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(); } }