import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author Nehal Kalnad */ class sell { int x , y; int dist; String path; sell() { path = ""; } } class redKnight { static boolean valid(int n , int i , int j) { if(i < 0 || j < 0 || i > n-1 || j > n-1) return false; return true; } static String getS(int i) { switch(i) { case 0:return "UL "; case 1:return "UR "; case 2:return "R "; case 3:return "LR "; case 4:return "LL "; case 5:return "L "; } return "fcl"; } public static String ans; static int bfs(sell src, sell des, int n) { int[] xd = {-1 , 1 , 2 , 1 , -1 , -2 }; int[] yd = {-2 , -2 , 0 , 2 , 2 , 0 }; Queue q = new LinkedList<>(); boolean[][] vis = new boolean[n][n]; q.add(src); while(!q.isEmpty()) { sell shit = q.remove(); int x = shit.x; int y = shit.y; int dis = shit.dist; if(x == des.x && y == des.y) { ans = shit.path; return dis; } if(!vis[x][y]) { vis[x][y] = true; for(int i = 0 ; i < 6 ; i++) { int a = x + xd[i]; int b =y + yd[i]; if(valid(n , a , b)) { sell s = new sell(); s.x = a; s.y = b; s.dist = dis+1; s.path= shit.path + getS(i); q.add(s); } } } } return -1; } static void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { int[][] vis = new int[n][n]; sell src = new sell(); sell des = new sell(); src.y = i_start; src.x = j_start; des.y = i_end; des.x = j_end; int c = bfs(src , des , n); if(c == -1) System.out.println("Impossible"); else System.out.println(c + "\n" + ans); } 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(); } }