import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; class Node{ int i; int j; String move; } public class Solution { static boolean visited[][] ; static ArrayList finalPath; 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. ArrayList path = new ArrayList(); printShortestPath(n, i_start, j_start, i_end, j_end , path , ""); if(finalPath==null){ System.out.print("Impossible"); return; } System.out.println(finalPath.size()-1); for(int i = 1 ; i < finalPath.size() ; i++){ System.out.print(finalPath.get(i)+" "); } } static void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end, ArrayList path , String toAppend){ if(i_start<0 || i_end<0 || i_start>=n || i_end>=n ) { return; } // System.out.println("n = "+n+" "+"i_start = "+ i_start+ " j_start= "+ j_start+" "+" i_end = " + // i_end+" "+" j_end = " + j_end +" "+ path +" "+ toAppend+" visited = " + visited[i_start][i_end]); if(visited[i_start][i_end]==true){ if(!(i_start==i_end && j_start==j_end)) return; } visited[i_start][i_end] = true; path.add(toAppend); if(i_start==i_end && j_start==j_end){ if(path.size()>0 &&(finalPath == null || finalPath.size() > path.size())){ finalPath = new ArrayList(); for(int i = 0 ; i < path.size() ; i++){ finalPath.add(path.get(i)); } // System.out.println(finalPath); } } else{ printShortestPath(n, i_start-2, j_start-1, i_end, j_end , path , "UL"); printShortestPath(n, i_start-2, j_start+1, i_end, j_end , path , "UR"); printShortestPath(n, i_start, j_start+2, i_end, j_end , path , "R"); printShortestPath(n, i_start+2, j_start+1, i_end, j_end , path , "LR"); printShortestPath(n, i_start+2, j_start-1, i_end, j_end , path , "LL"); printShortestPath(n, i_start, j_start-2, i_end, j_end , path , "L"); } path.remove(path.size()-1); visited[i_start][i_end] = 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(); visited = new boolean[n][n]; printShortestPath(n, i_start, j_start, i_end, j_end); in.close(); } }