import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.io.Writer; import java.io.OutputStreamWriter; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Egor Kulikov (egor@egork.net) */ public class Solution { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); OutputWriter out = new OutputWriter(outputStream); RedKnightsShortestPath solver = new RedKnightsShortestPath(); solver.solve(1, in, out); out.close(); } static class RedKnightsShortestPath { int[] dRow = {-2, -2, 0, 2, 2, 0}; int[] dCol = {-1, 1, 2, 1, -1, -2}; String[] label = {"UL", "UR", "R", "LR", "LL", "L"}; public void solve(int testNumber, InputReader in, OutputWriter out) { int n = in.readInt(); int sRow = in.readInt(); int sCol = in.readInt(); int fRow = in.readInt(); int fCol = in.readInt(); int[][] dst = new int[n][n]; ArrayUtils.fill(dst, -1); SimpleMapVisitor visitor = new SimpleMapVisitor(n, n, dRow, dCol) { protected void process(int row, int column, int fromRow, int fromColumn) { add(row, column); if (fromRow == -1) { dst[row][column] = 0; } else { dst[row][column] = dst[fromRow][fromColumn] + 1; } } }; visitor.process(fRow, fCol); if (dst[sRow][sCol] == -1) { out.printLine("Impossible"); } else { out.printLine(dst[sRow][sCol]); List path = new ArrayList<>(); while (sRow != fRow || sCol != fCol) { for (int i = 0; i < 6; i++) { int nRow = sRow + dRow[i]; int nCol = sCol + dCol[i]; if (MiscUtils.isValidCell(nRow, nCol, n, n) && dst[nRow][nCol] == dst[sRow][sCol] - 1) { path.add(label[i]); sRow = nRow; sCol = nCol; break; } } } out.printLine(path.toArray()); } } } static abstract class SimpleMapVisitor extends MapVisitor { protected final boolean[][] processed; public SimpleMapVisitor(int rowCount, int columnCount) { this(rowCount, columnCount, MiscUtils.DX4, MiscUtils.DY4); } public SimpleMapVisitor(int rowCount, int columnCount, int[] dRow, int[] dColumn) { super(rowCount, columnCount, dRow, dColumn); processed = new boolean[rowCount][columnCount]; } protected void internalProcess(int row, int column, int fromRow, int fromColumn) { if (processed[row][column]) { return; } processed[row][column] = true; process(row, column, fromRow, fromColumn); } } static class ArrayUtils { public static void fill(int[][] array, int value) { for (int[] row : array) { Arrays.fill(row, value); } } } static class MiscUtils { public static final int[] DX4 = {1, 0, -1, 0}; public static final int[] DY4 = {0, -1, 0, 1}; public static boolean isValidCell(int row, int column, int rowCount, int columnCount) { return row >= 0 && row < rowCount && column >= 0 && column < columnCount; } } static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private InputReader.SpaceCharFilter filter; public InputReader(InputStream stream) { this.stream = stream; } public int read() { if (numChars == -1) { throw new InputMismatchException(); } if (curChar >= numChars) { curChar = 0; try { numChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (numChars <= 0) { return -1; } } return buf[curChar++]; } public int readInt() { int c = read(); while (isSpaceChar(c)) { c = read(); } int sgn = 1; if (c == '-') { sgn = -1; c = read(); } int res = 0; do { if (c < '0' || c > '9') { throw new InputMismatchException(); } res *= 10; res += c - '0'; c = read(); } while (!isSpaceChar(c)); return res * sgn; } public boolean isSpaceChar(int c) { if (filter != null) { return filter.isSpaceChar(c); } return isWhitespace(c); } public static boolean isWhitespace(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } public interface SpaceCharFilter { public boolean isSpaceChar(int ch); } } static abstract class MapVisitor { protected final int rowCount; protected final int columnCount; protected final int[] dRow; protected final int[] dColumn; protected int[] rowQueue; protected int[] columnQueue; protected int start; protected int end; public MapVisitor(int rowCount, int columnCount) { this(rowCount, columnCount, MiscUtils.DX4, MiscUtils.DY4); } public MapVisitor(int rowCount, int columnCount, int[] dRow, int[] dColumn, int queueCapacity) { this.rowCount = rowCount; this.columnCount = columnCount; this.dRow = dRow; this.dColumn = dColumn; rowQueue = new int[queueCapacity]; columnQueue = new int[queueCapacity]; } public MapVisitor(int rowCount, int columnCount, int[] dRow, int[] dColumn) { this(rowCount, columnCount, dRow, dColumn, rowCount * columnCount); } protected abstract void process(int row, int column, int fromRow, int fromColumn); public void process(int startRow, int startColumn) { start = 0; end = 0; internalProcess(startRow, startColumn, -1, -1); while (start != end) { int row = rowQueue[start]; int column = columnQueue[start++]; if (start == rowQueue.length) { start = 0; } for (int i = 0; i < dRow.length; i++) { int nextRow = row + dRow[i]; int nextColumn = column + dColumn[i]; if (nextRow >= 0 && nextRow < rowCount && nextColumn >= 0 && nextColumn < columnCount) { internalProcess(nextRow, nextColumn, row, column); } } } } protected void internalProcess(int row, int column, int fromRow, int fromColumn) { process(row, column, fromRow, fromColumn); } protected void add(int row, int column) { rowQueue[end] = row; columnQueue[end++] = column; if (end == rowQueue.length) { end = 0; } } } static class OutputWriter { private final PrintWriter writer; public OutputWriter(OutputStream outputStream) { writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter(Writer writer) { this.writer = new PrintWriter(writer); } public void print(Object... objects) { for (int i = 0; i < objects.length; i++) { if (i != 0) { writer.print(' '); } writer.print(objects[i]); } } public void printLine(Object... objects) { print(objects); writer.println(); } public void close() { writer.close(); } public void printLine(int i) { writer.println(i); } } }