import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { int row = i_start; int col = j_start; int endRow = i_end; int endCol = j_end; StringBuilder sb = new StringBuilder(); /*if(!isValid(n, row, col, endRow, endCol)){ System.out.println("Impossible"); return; }*/ int counter = 0; while(row != endRow || col != endCol){ String bestMove = bestMove(n, row, col, endRow, endCol); if(bestMove.equals("WTF") || counter > n*n){ System.out.println("Impossible"); return; } sb.append(bestMove + " "); if(bestMove.equals("UL")){ row -= 2; col--; } if(bestMove.equals("UR")){ row -= 2; col++; } if(bestMove.equals("R")){ col += 2; } if(bestMove.equals("LR")){ row += 2; col++; } if(bestMove.equals("LL")){ row += 2; col--; } if(bestMove.equals("L")){ col -= 2; } counter++; //System.out.println(sb.toString()); //System.out.println("ROW: " + row + "COL: " + col); //String s = new Scanner(System.in).nextLine(); } System.out.println(counter); System.out.println(sb.toString().substring(0,sb.toString().length() - 1)); } static boolean isValid(int n, int row, int col, int endRow, int endCol){ return true; } static String bestMove(int n, int row, int col, int endRow, int endCol){ //System.out.println("BESTMOVE"); int distUL = distance(row - 2, col - 1, endRow, endCol); int distUR = distance(row - 2, col + 1, endRow, endCol); int distR = distance(row, col + 2, endRow, endCol); int distLR = distance(row + 2, col + 1, endRow, endCol); int distLL = distance(row + 2, col - 1, endRow, endCol); int distL = distance(row, col - 2, endRow, endCol); int min = distUL; if(distUR < min) min = distUR; if(distR < min) min = distR; if(distLR < min) min = distLR; if(distLL < min) min = distLL; if(distL < min) min = distL; //System.out.println("Min prima del while: " + min); //System.out.println("UPPERLEFT: " + distUL); while(min < n * n) { // magari il salto migliore va fuori dalla scacchiera if (min >= distUL && row - 2 >= 0 && col - 1 >= 0) return "UL"; if (min >= distUR && row - 2 >= 0 && col + 1 < n) return "UR"; if (min >= distR && col + 2 < n) return "R"; if (min >= distLR && row + 2 < n && col + 1 < n) return "LR"; if (min >= distLL && row + 2 < n && col - 1 >= 0) return "LL"; if (min >= distL && col - 2 >= 0) return "L"; min++; // I salti migliori sono fuori dalla schacchiera //System.out.println("Nessuna mossa trovata. Min aumentato a " + min); //String x = new Scanner(System.in).nextLine(); } return "WTF"; } static int distance(int x1, int y1, int x2, int y2){ return Math.abs(x1 - x2) + Math.abs(y1 - y2); } 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(); } }