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. int[][] grid = new int[n][n]; int[][][] prev = new int[n][n][2]; String[][] gridMoves = new String[n][n]; for (int i = 0; i < n; i++) { Arrays.fill(grid[i], -1); } String[] moveNames = { "UL", "UR", "R", "LR", "LL", "L"}; int[][] moves = {{-2, -1}, {-2, 1}, {0, 2}, {2, 1}, {2, -1}, {0, -2}}; Queue queue = new LinkedList<>(); grid[i_start][j_start] = 0; queue.add(new int[] {i_start, j_start}); queue.add(null); boolean endFound = false; int moveCount = 1; while (!queue.isEmpty() && !endFound) { int[] current = queue.poll(); if (current == null) { moveCount++; if (!queue.isEmpty()) { queue.add(null); } continue; } for (int i = 0; i < moves.length; i++) { int newX = current[0] + moves[i][0]; int newY = current[1] + moves[i][1]; if (newX < 0 || newX >= n || newY < 0 || newY >= n || grid[newX][newY] >= 0) continue; grid[newX][newY] = moveCount; prev[newX][newY][0] = current[0]; prev[newX][newY][1] = current[1]; gridMoves[newX][newY] = moveNames[i]; if (newX == i_end && newY == j_end) { endFound = true; break; } queue.add(new int[] {newX, newY}); } } if (!endFound) { System.out.println("Impossible"); return; } System.out.println(moveCount); int x = i_end; int y = j_end; Stack stack = new Stack<>(); while (!(x == i_start && y == j_start)) { stack.push(gridMoves[x][y]); int newX = prev[x][y][0]; int newY = prev[x][y][1]; x = newX; y = newY; } while (!stack.isEmpty()) { System.out.print(stack.pop() + " "); } System.out.println(); } 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(); } }