import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { 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. if (Math.abs(i_end-i_start) % 2 > 0) { System.out.println("Impossible"); return; } if ( (Math.abs(j_end-j_start) - Math.abs(i_end-i_start)/2) % 2 > 0 ) { System.out.println("Impossible"); return; } Map map = new HashMap<>(); map.put(1, "UL"); map.put(2, "UR"); map.put(3, "R"); map.put(4, "LR"); map.put(5, "LL"); map.put(6, "L"); ArrayList stepArr = new ArrayList<>(); int stepsI = Math.abs(i_end-i_start) / 2; int stepsJ = (stepsI < Math.abs(j_end-j_start)) ? (Math.abs(j_end-j_start)-stepsI)/2 : 0; System.out.println(stepsI+stepsJ); // print total number of steps int i = 0; for ( ; i < Math.abs(j_end-j_start) && i < stepsI; i++) { if (i_end > i_start) { // go down stepArr.add(j_end > j_start ? 4 : 5); } else { // go up stepArr.add(j_end > j_start ? 2 : 1); } } if (i < stepsI) { for (int j = 0; j < (stepsI-i)/2; j++) { if (i_end > i_start) { // go down stepArr.add(4); stepArr.add(5); } else { // go up stepArr.add(2); stepArr.add(1); } } } if (stepsJ > 0) { for (int j=0; j j_start ? 3 : 6); } } Collections.sort(stepArr); for (Integer value : stepArr) { System.out.print(map.get(value)+" "); } } 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(); } }