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) { // Print the distance along with the sequence of moves. math(i_start, j_start, i_end, j_end, n); } 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(); } public static void math(int startPosI, int startPosJ, int endPosI, int endPosJ, int n){ int icg = Math.abs(startPosI - endPosI); int jcg = Math.abs(startPosJ - endPosJ); ArrayList moves = new ArrayList(); int movesI = 0; int movesJ = 0; //we can only reach cells (i-2x, j), (i+2x, j), (i+2x-1, j +/- 2y), (i-2x+1, j +/- 2y) if (jcg == 0 || jcg%2 == 0){ //j must be =, or +/- multiple of 4 if (icg == 0 || icg%4 == 0){ //can get to it movesI = (int)Math.floor(icg/2); movesJ = (int)Math.floor(jcg/2); } } if (jcg%2 == 1){ if ((icg+2)%4==0){ //can get to it movesJ = (int)Math.floor(jcg/2); movesI = (int)Math.floor(icg/2); } } int curPosJ = startPosJ; if (jcg == 0){ //favor UL -> UR //favor LR -> LL for (int i=0; i<(movesI/2); i++){ if (startPosI > endPosI){ if (startPosJ == 0){ //cant move left first moves.add("UR"); moves.add("UL"); }else{ moves.add("UL"); moves.add("UR"); } }else{ if (startPosJ == n){ //cant move right first moves.add("LL"); moves.add("LR"); }else{ moves.add("LR"); moves.add("LL"); } } } }else if (startPosI > endPosI){ //favor UL, UR movesJ = movesJ - movesI/2; for (int i=0; i endPosJ){ curPosJ -= 1; moves.add("UL"); }else{ curPosJ += 1; moves.add("UR"); } } for (int i=0; i endPosJ){ curPosJ -= 2; moves.add("L"); }else{ curPosJ += 2; moves.add("R"); } } }else{ //favor R-> LR, LL if (startPosJ < endPosJ){ for (int i=0; i