import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public class Point { float id = 0; public int x; public int y; public String move; public ArrayList moves = new ArrayList(); public Point(int x, int y, String move){ this.x = x; this.y = y; this.move = move; moves.add(move); } public Point(int x, int y, String move, ArrayList m){ this.x = x; this.y = y; this.move = move; moves.add(move); for(String s : m){ this.moves.add(s); } } public Point clone(Point p){ Point point = p; point.id += 0.00001f; return point; } } public ArrayList clone(ArrayList s){ ArrayList al = new ArrayList(); for(String str : s){ al.add(str + ""); } return al; } public ArrayList clonee(ArrayList s){ ArrayList al = new ArrayList(); for(Point str : s){ str.x += 0; al.add(str); } return al; } public void printShortestPath(int n, int j_start, int i_start, int j_end, int i_end) { if(Math.abs(j_start - j_end) % 2 != 0){ System.out.println("Impossible"); return; }else if(Math.abs(j_start - j_end) / 2 % 2 == 1 && Math.abs(i_start - i_end) % 2 == 0){ System.out.println("Impossible"); return; }else if(Math.abs(j_start - j_end) / 2 % 2 == 0 && Math.abs(i_start - i_end) % 2 == 1){ System.out.println("Impossible"); return; } int[] movesX = new int[]{-1, 1, 2, 1, -1, -2}; int[] movesY = new int[]{-2, -2, 0, 2, 2, 0}; String[] names = new String[]{"UL", "UR", "R", "LR", "LL", "L"}; int moves = 0; boolean found = false; boolean impossible = false; ArrayList> checkedSpaces = new ArrayList>(); ArrayList currentSpaces = new ArrayList(); currentSpaces.add(new Point(i_start, j_start, "none")); whileloop: while(!found && !impossible){ moves++; ArrayList newPoints = new ArrayList(); for(int i = 0; i < currentSpaces.size(); i++){ Point p = currentSpaces.get(i); for(int j = 0; j < 6; j++){ if(i_end - p.x > 0){ if(j == 0 || j == 4 || j == 5) continue; }else if(i_end - p.x < 0){ if(j == 1 || j == 2 || j == 3) continue; } if(j_end - p.y > 0){ if(j == 0 || j == 1) continue; }else if(j_end - p.x < 0){ if(j == 3 || j == 4) continue; } if(j_end != p.y){ if(j == 2 || j == 5) continue; } Point newPoint = new Point(p.x + movesX[j], p.y + movesY[j], names[j], clone(p.moves)); if(newPoint.x < 0 || newPoint.x >= n || newPoint.y < 0 || newPoint.y >= n) continue; if(newPoint.x == i_end && newPoint.y == j_end){ printOutput(newPoint); found = true; break whileloop; }else{ ArrayList l = new ArrayList(); l.add(newPoint.x); l.add(newPoint.y); if(!checkedSpaces.contains(l)) newPoints.add(newPoint); } } ArrayList l = new ArrayList(); l.add(p.x); l.add(p.y); checkedSpaces.add(l); } if(newPoints.size() == 0 && !found){ System.out.println("Impossible"); impossible = true; break; } currentSpaces.clear(); for(Point p : newPoints){ currentSpaces.add(p); } newPoints.clear(); } } public void printOutput(Point p){ System.out.println(p.moves.size() - 1); for(int i = p.moves.size() - 1; i >= 0; i--){ if(!p.moves.get(i).equals("none")) { System.out.print(p.moves.get(i)); if(i != 0) System.out.print(" "); } } } 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(); Solution s = new Solution(); s.printShortestPath(n, i_start, j_start, i_end, j_end); in.close(); } }