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. ArrayList path = new ArrayList(); if(startMoving(n, j_start, i_start, j_end, i_end, path)) { System.out.println(path.size()); for(String pathStep: path ) System.out.print(pathStep); } else { System.out.print("Impossible"); } } static boolean startMoving(int n, int i_start, int j_start, int i_end, int j_end, ArrayList path) { if( i_start > n || j_start > n || i_start < 0 || j_start < 0 || ((i_end == i_start-1 || i_end == i_start + 1) && (j_end == j_start-1 || j_end == j_start+1))) return false; if(i_start == i_end && j_start == j_end) return true; int[] nextDest = null; ArrayList currentLevelPath = new ArrayList(); ArrayList nextPath; if(i_end >= i_start+1 && i_start+1 < n && j_end <= j_start-1 && j_start-2 >=0) { nextDest = applyUpperRight(i_start,j_start); nextPath = new ArrayList(); nextPath.add("UR"); if(startMoving(n, nextDest[0], nextDest[1], i_end, j_end, nextPath)) currentLevelPath.add(nextPath); } if(i_end <= i_start+1 && i_start-1 >=0 && j_end <= j_start-1 && j_start-2 >=0) { nextDest = applyUpperLeft(i_start,j_start); nextPath = new ArrayList(); nextPath.add("UL "); if(startMoving(n, nextDest[0], nextDest[1], i_end, j_end, nextPath)) currentLevelPath.add(nextPath); } if(i_end >= i_start+1 && i_start + 1 < n && j_end >= j_start+1 && j_start+2 < n) { nextDest = applyLowerRight(i_start,j_start); nextPath = new ArrayList(); nextPath.add("LR "); startMoving(n, nextDest[0], nextDest[1], i_end, j_end, nextPath); currentLevelPath.add(nextPath); } if(i_end <= i_start+1 && i_start - 1 >=0 && j_end >= j_start+1 && j_start+2 < n) { nextDest = applyLowerLeft(i_start,j_start); nextPath = new ArrayList(); nextPath.add("LL "); if(startMoving(n, nextDest[0], nextDest[1], i_end, j_end, nextPath)) currentLevelPath.add(nextPath); } if(i_end >= i_start+2 && j_end == j_start && i_start+2 < n) { nextDest = applyRight(i_start,j_start); nextPath = new ArrayList(); nextPath.add("R "); if(startMoving(n, nextDest[0], nextDest[1], i_end, j_end, nextPath)) currentLevelPath.add(nextPath); } if(i_end <= i_start-2 && j_end == j_start && i_start-2 >=0) { nextDest = applyLeft(i_start,j_start); nextPath = new ArrayList(); nextPath.add("L "); if(startMoving(n, nextDest[0], nextDest[1], i_end, j_end, nextPath)) currentLevelPath.add(nextPath); } // find smallest int smallestLength = 500; ArrayList selectedPath = null; for(ArrayList levelList : currentLevelPath) { if(levelList.size() > 0 && levelList.size() < smallestLength) { smallestLength = levelList.size(); selectedPath = levelList; } } if(null != selectedPath) { path.addAll(selectedPath); return true; } return false; } static int[] applyUpperLeft(int i_start, int j_start) { int istart = i_start - 1; int jstart = j_start - 2; return new int[]{ istart, jstart }; } static int[] applyUpperRight(int i_start, int j_start) { int istart = i_start + 1; int jstart = j_start - 2; return new int[]{ istart, jstart }; } static int[] applyLowerLeft(int i_start, int j_start) { int istart = i_start - 1; int jstart = j_start + 2; return new int[]{ istart, jstart }; } static int[] applyLowerRight(int i_start, int j_start) { int istart = i_start + 1; int jstart = j_start + 2; return new int[]{ istart, jstart }; } static int[] applyRight(int i_start, int j_start) { int istart = i_start + 2; int jstart = j_start; return new int[]{ istart, jstart }; } static int[] applyLeft(int i_start, int j_start) { int istart = i_start - 2; int jstart = j_start; return new int[]{ istart, jstart }; } 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(); } }