import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static class Cell{ private int i; private int j; private int level; private Cell parent; public Cell(int i, int j){ this.i = i; this.j = j; this.level = -1; } public int i() { return this.i; } public int j() { return this.j; } public int level() { return this.level; } public void setLevel(int level) { this.level = level; } public Cell parent() { return this.parent; } public void setParent(Cell parent) { this.parent = parent; } } static void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { // Print the distance along with the sequence of moves. boolean hasResult = false; Cell[][] board = new Cell[n][n]; for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { board[i][j] = new Cell(i, j); } } int[][] dir = {{-2, -1}, {-2, 1}, {0, 2}, {2, 1}, {2, -1}, {0, -2}}; Queue queue = new LinkedList(); queue.add(board[i_start][j_start]); board[i_start][j_start].setLevel(0); while(!queue.isEmpty() && !hasResult){ Cell tmp = queue.remove(); for(int d = 0; d < 6; d++){ int i = tmp.i + dir[d][0]; int j = tmp.j + dir[d][1]; if(i == i_end && j == j_end){ //System.out.println(i + " " + j); hasResult = true; board[i][j].setLevel(tmp.level() + 1); board[i][j].setParent(tmp); break; } if(i >= 0 && i < n && j >= 0 && j < n && board[i][j].level() < 0){ //System.out.println(i + " " + j); queue.add(board[i][j]); board[i][j].setLevel(tmp.level() + 1); board[i][j].setParent(tmp); } } } if(hasResult){ System.out.println(board[i_end][j_end].level()); String result = ""; LinkedList path = new LinkedList(); Cell tmp = board[i_end][j_end]; path.push(tmp); while(tmp.level() != 0) { tmp = tmp.parent(); path.push(tmp); } Cell t1 = path.pop(); while(!path.isEmpty()){ Cell t2 = path.pop(); int iDiv = t2.i() - t1.i(); int jDiv = t2.j() - t1.j(); if(iDiv == dir[0][0] && jDiv == dir[0][1]){ result += "UL "; }else if(iDiv == dir[1][0] && jDiv == dir[1][1]){ result += "UR "; }else if(iDiv == dir[2][0] && jDiv == dir[2][1]){ result += "R "; }else if(iDiv == dir[3][0] && jDiv == dir[3][1]){ result += "LR "; }else if(iDiv == dir[4][0] && jDiv == dir[4][1]){ result += "LL "; }else if(iDiv == dir[5][0] && jDiv == dir[5][1]){ result += "L "; } t1 = t2; } System.out.println(result); }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(); } }