import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static class Node { int i, j; List movesSoFar = new LinkedList<>(); Node(int i, int j) { this.i = i; this.j = j; } Node(int i, int j, Node a, String moveTo) { this.i = i; this.j = j; this.movesSoFar.addAll(a.movesSoFar); this.movesSoFar.add(moveTo); } } static void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { boolean[][] visited = new boolean[n][n]; Queue queue = new LinkedList<>(); Node start = new Node(i_start, j_start); queue.add(start); visited[start.i][start.j] = true; List path = null; while (!queue.isEmpty()) { Node current = queue.poll(); if (current.i == i_end && current.j == j_end) { path = current.movesSoFar; break; } if (current.j - 1 >= 0 && current.i - 2 >= 0 && !visited[current.i-2][current.j-1]) { // UL queue.offer(new Node(current.i-2, current.j-1, current, "UL")); visited[current.i-2][current.j-1] = true; } if (current.j + 1 < n && current.i - 2 >= 0 && !visited[current.i-2][current.j+1]) { queue.offer(new Node(current.i-2, current.j+1, current, "UR")); visited[current.i-2][current.j+1] = true; } if (current.j + 2 < n && !visited[current.i][current.j+2]) { queue.offer(new Node(current.i, current.j+2, current, "R")); visited[current.i][current.j+2] = true; } if (current.i+2 < n && current.j+1 < n && !visited[current.i+2][current.j+1]) { queue.offer(new Node(current.i+2, current.j+1, current, "LR")); visited[current.i+2][current.j+1] = true; } if (current.i+2 < n && current.j-1 >= 0 && !visited[current.i+2][current.j-1]) { queue.offer(new Node(current.i+2, current.j-1, current, "LL")); visited[current.i+2][current.j-1] = true; } if (current.j-2 >= 0 && !visited[current.i][current.j-2]) { queue.offer(new Node(current.i, current.j-2, current, "L")); visited[current.i][current.j-2] = true; } } if (path != null) { System.out.println(path.size()); boolean first = true; for (String item : path) { if (!first) { System.out.print(" "); } System.out.print(item); first = false; } System.out.println(); } else { 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(); } }