import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static int [][] moves = {{-2, -1}, {-2,1}, {0, 2}, {2, 1}, {2, -1}, {0, -2}}; static String [] movesL = {"UL", "UR", "R", "LR", "LL", "L"}; /* static boolean moveOK(int i_crnt, int j_crnt, int n, int iDif, int jDif) { if (i_crnt >= 0 && i_crnt <= n && j_crnt >= 0 && j_crnt <= n) { } }*/ static int determineMove(int i_crnt, int j_crnt, int i_end, int j_end, int n) { if (i_crnt > i_end && j_crnt >= j_end && i_crnt + moves[0][0] >= 0 && i_crnt + moves[0][0] <= n && j_crnt + moves[0][1] >= 0 && j_crnt + moves[0][1] <= n) { return 0; } else if (i_crnt > i_end && j_crnt <= j_end && i_crnt + moves[1][0] >= 0 && i_crnt + moves[1][0] <= n && j_crnt + moves[1][1] >= 0 && j_crnt + moves[1][1] <= n) { return 1; } else if (i_crnt == i_end && j_crnt < j_end && i_crnt + moves[2][0] >= 0 && i_crnt + moves[2][0] <= n && j_crnt + moves[2][1] >= 0 && j_crnt + moves[2][1] <= n) { return 2; } else if (i_crnt < i_end && j_crnt <= j_end && i_crnt + moves[3][0] >= 0 && i_crnt + moves[3][0] <= n && j_crnt + moves[3][1] >= 0 && j_crnt + moves[3][1] <= n) { return 3; } else if (i_crnt < i_end && j_crnt >= j_end && i_crnt + moves[4][0] >= 0 && i_crnt + moves[4][0] <= n && j_crnt + moves[4][1] >= 0 && j_crnt + moves[4][1] <= n) { return 4; } else if (i_crnt == i_end && j_crnt > j_end && i_crnt + moves[5][0] >= 0 && i_crnt + moves[5][0] <= n && j_crnt + moves[5][1] >= 0 && j_crnt + moves[5][1] <= n) { return 5; } return -1; } static void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { //int [][] moves = {{-2, -1}, {-2,1}, {0, 2}, {2, 1}, {2, -1}, {0, -2}}; //String [] movesL = {"UL", "UR", "R", "LR", "LL", "L"}; int i_crnt = i_start, j_crnt = j_start, iDif = i_start - i_end, jDif = j_start - j_end, numMoves = 0; // boolean moveOK = false; String solution = ""; int movesCount = 0; if (i_start % 2 == i_end % 2) { if(i_start % 4 == i_end % 4 && j_start % 2 == j_end % 2 || i_start % 4 != i_end % 4 && j_start % 2 != j_end %2) { while (i_crnt != i_end || j_crnt != j_end) { int move = determineMove(i_crnt, j_crnt, i_end, j_end, n); i_crnt += moves[move][0]; j_crnt += moves[move][1]; solution += movesL[move] + " "; numMoves++; //System.out.println(numMoves + " " + (i_crnt != i_end && j_crnt != j_end)); } System.out.println(numMoves); System.out.println(solution); return; } if(i_start % 4 != i_end % 4 && j_start % 2 != j_end %2) { // compute move 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(); } }