import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static class Square { int row; int col; Square(int r, int c) { row = r; col = c; } } static class SquareLevelPair { Square sq; int level; SquareLevelPair(Square sq, int level) { this.sq = sq; this.level = level; } } static class Direction { int rPlus; int cPlus; String dirStr; Direction(int rPlus, int cPlus, String dirStr) { this.rPlus = rPlus; this.cPlus = cPlus; this.dirStr = dirStr; } } static boolean validSquare(Square sq, int n) { return 0 <= sq.row && sq.row < n && 0 <= sq.col && sq.col < n; } static boolean same(Square sq1, Square sq2) { return sq1.row == sq2.row && sq1.col == sq2.col; } static void printShortestPath(int n, int rStart, int cStart, int rEnd, int cEnd) { Direction[] dirs = {new Direction(-2, -1, "UL"), new Direction(-2, 1, "UR"), new Direction(0, 2, "R"), new Direction(2, 1, "LR"), new Direction(2, -1, "LL"), new Direction(0, -2, "L")}; int[][] v = new int[n][]; Square[][] prev = new Square[n][]; String[][] fromDir = new String[n][]; for (int r = 0; r < n; r++) { v[r] = new int[n]; prev[r] = new Square[n]; fromDir[r] = new String[n]; for (int c = 0; c < n; c++) { v[r][c] = -1; } } Square start = new Square(rStart, cStart); Square end = new Square(rEnd, cEnd); Queue q = new LinkedList<>(); q.add(new SquareLevelPair(start, 0)); SquareLevelPair cur = q.poll(); boolean found = false; v[rStart][cStart] = 0; while (!found && cur != null) { Square sqCur = cur.sq; int level = cur.level; for (int i = 0; i < dirs.length; i++) { Direction dir = dirs[i]; Square next = new Square(sqCur.row + dir.rPlus, sqCur.col + dir.cPlus); if (validSquare(next, n) && v[next.row][next.col] == -1) { v[next.row][next.col] = level + 1; prev[next.row][next.col] = sqCur; fromDir[next.row][next.col] = dir.dirStr; if (same(end, next)) { found = true; break; } q.add(new SquareLevelPair(next, level + 1)); } } cur = q.poll(); } if (!found) { System.out.println("Impossible"); } else { int level = v[end.row][end.col]; System.out.println(level); Square sq = end; String[] path = new String[level]; while (level > 0) { level--; path[level] = fromDir[sq.row][sq.col]; sq = prev[sq.row][sq.col]; } System.out.print(path[0]); for (int i = 1; i < path.length; i++) { System.out.print(" " + path[i]); } 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(); } }