import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static boolean visited[][]; //static node parent[][]; static ArrayList al; static Queuequ; ///////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// static void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { node ans=bfs(n,i_start,j_start,i_end,j_end); if(ans.row==-1 && ans.col==-1 && ans.data=="" && ans.parent==null){ System.out.println("Impossible"); } else{ al=new ArrayList<>(); while(ans.parent!=null){ al.add(ans.data); ans=ans.parent; } System.out.println(al.size()); Collections.reverse(al); for (String el:al) { System.out.print(el+" "); } System.out.println(); } } /////////////////////////////////////////////////////////////////////////////////////// private static node bfs(int n, int i, int j, int i2, int j2) { node source=new node(i,j,null,""); qu.add(source); visited[source.row][source.col]=true; while(!qu.isEmpty()){ node t=qu.poll(); if(t.row==i2 && t.col==j2){ return t; } if(t.row-2<=n-1 && t.col-1<=n-1 && t.row-2>=0 && t.col-1>=0&&visited[t.row-2][t.col-1]==false){ qu.add(new node(t.row-2,t.col-1,t,"UL")); visited[t.row-2][t.col-1]=true; } if(t.row-2<=n-1 && t.col+1<=n-1 && t.row-2>=0 && t.col+1>=0 && visited[t.row-2][t.col+1]==false ){ qu.add(new node(t.row-2,t.col+1,t,"UR")); visited[t.row-2][t.col+1]=true; } if(t.row<=n-1 && t.col+2<=n-1 && t.row>=0 && t.col+2>=0&&visited[t.row][t.col+2]==false ){ qu.add(new node(t.row,t.col+2,t,"R")); visited[t.row][t.col+2]=true; } if(t.row+2<=n-1 && t.col+1<=n-1 && t.row+2>=0 && t.col+1>=0&& visited[t.row+2][t.col+1]==false ){ qu.add(new node(t.row+2,t.col+1,t,"LR")); visited[t.row+2][t.col+1]=true; } if(t.row+2<=n-1 && t.col-1<=n-1 && t.row+2>=0 && t.col-1>=0 &&visited[t.row+2][t.col-1]==false){ qu.add(new node(t.row+2,t.col-1,t,"LL")); visited[t.row+2][t.col-1]=true; } if(t.row<=n-1 && t.col-2<=n-1 && t.row>=0 && t.col-2>=0 && visited[t.row][t.col-2]==false){ qu.add(new node(t.row,t.col-2,t,"L")); visited[t.row][t.col-2]=true; } } return new node(-1,-1,null,""); } ////////////////////////////////////////////////////////////////////////////////// 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(); visited=new boolean[n+1][n+1]; qu=new LinkedList<>(); printShortestPath(n, i_start, j_start, i_end, j_end); in.close(); } } class node{ int row,col; node parent; String data; node(int r,int c,node n,String st){ row=r; col=c; parent=n; data=st; } }