import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static class Cell { int x; int y; int dist; String moves; public Cell() {} public Cell(int x, int y, int dist, String moves) { this.x = x; this.y = y; this.dist = dist; this.moves = moves; } } static boolean isInBoard(int x, int y, int n) { return x >= 0 && x < n && y >= 0 && y < n; } static String getMoveString(int i) { String[] arr = {"L", "R", "LR", "LL", "UR", "UL"}; return arr[i]; } static String sortMoves(String old) { String[] moveArray = old.split(" "); StringBuilder newMoveSB = new StringBuilder(); int[] moveCounts = new int[6]; for (String m : moveArray) { if (m.equals("L")) { moveCounts[0]++; } else if (m.equals("R")) { moveCounts[1]++; } else if (m.equals("LR")) { moveCounts[2]++; } else if (m.equals("LL")) { moveCounts[3]++; } else if (m.equals("UR")) { moveCounts[4]++; } else if (m.equals("UL")) { moveCounts[5]++; } } int[] priority = {5, 4, 1, 2, 3, 0}; String[] moveStrings = {" L", " R", " LR", " LL", " UR", " UL"}; for (int i = 0; i < priority.length; i++) { int p = priority[i]; for (int j = 0; j < moveCounts[p]; j++) { newMoveSB.append(moveStrings[p]); } } return newMoveSB.toString().trim(); } static void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { int[] dy = {-2, 2, 1, -1, 1, -1}; int[] dx = {0, 0, 2, 2, -2, -2}; LinkedList queue = new LinkedList<>(); queue.add(new Cell(i_start, j_start, 0, new String(""))); boolean[][] visited = new boolean[n+1][n+1]; visited[i_start][j_start] = true; while (!queue.isEmpty()) { Cell t = queue.pop(); visited[t.x][t.y] = true; if (t.x == i_end && t.y == j_end) { System.out.println(t.dist); String newMoveString = sortMoves(t.moves); System.out.println(newMoveString); return; } for (int i = 0; i < dx.length; i++) { int x = t.x + dx[i]; int y = t.y + dy[i]; int dist = t.dist + 1; String moves = t.moves + " " + getMoveString(i); moves = moves.trim(); if (isInBoard(x, y, n) && !visited[x][y]) { visited[x][y] = true; queue.add(new Cell(x, y, dist, moves)); } } } 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(); } }