import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { //UL, UR, R, LR, LL, L private static Move[] moves = {new Move(-1, -2, "UL"), new Move(1, -2, "UR"), new Move(2, 0, "R"), new Move(1, 2, "LR"), new Move(-1, 2, "LL"), new Move(-2, 0, "L")}; static void printShortestPath(int n, int x_start, int y_start, int x_end, int y_end) { boolean[][] visited = new boolean[n][n]; Path start = new Path(x_start, y_start); Queue queue = new LinkedList<>(); visited[start.x][start.y] = true; queue.add(start); while(!queue.isEmpty()) { Path current = queue.poll(); visited[current.x][current.y] = true; // printAll(current); if (current.x == x_end && current.y == y_end) { print(current); return; } for (Move move : moves) { Path next = current.move(move, n); if (next != null && !visited[next.x][next.y]) { queue.add(next); visited[next.x][next.y] = true; } } } System.out.println("Impossible"); } private static void printAll(Path p) { System.out.println(p.x + "," + p.y); for (Move m: p.moves) System.out.print(m.name + " "); System.out.println(); } private static void print(Path p) { System.out.println(p.moves.size()); for (Move m: p.moves) System.out.print(m.name + " "); System.out.println(); } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int y_start = in.nextInt(); int x_start = in.nextInt(); int y_end = in.nextInt(); int x_end = in.nextInt(); printShortestPath(n, x_start, y_start, x_end, y_end); in.close(); } private static class Path { List moves = new ArrayList<>(); int x; int y; public Path(int x, int y) { this.x = x; this.y = y; } public Path move(Move m, int n) { int nx = x + m.dx; int ny = y + m.dy; // System.out.println("CHECK (" + nx + "," + ny + ")"); if (nx >= n || ny >= n || nx < 0 || ny < 0) return null; Path result = new Path(nx, ny); result.moves.addAll(this.moves); result.moves.add(m); return result; } } private static class Move { int dx; int dy; String name; Move(int x, int y, String name) { this.dx = x; this.dy = y; this.name = name; } } }