using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static string output=null; enum Move{UpperLeft, UpperRight, Right, LowerRight, LowerLeft, Left}; static void MakeMove(Move move) { switch (move) { case Move.UpperLeft: output+= "UL "; break; case Move.UpperRight:output+= "UR "; break; case Move.Right: output+= "R "; break; case Move.LowerRight:output+= "LR "; break; case Move.LowerLeft: output+= "LL "; break; case Move.Left: output+= "L "; break; default: output = "Error in MakeMove(Move m)"; break; } } static void MakeMove(int n,int i_start,int j_start,int i_end, int j_end) { int i_s=i_start; int j_s=j_start; int n_r=n; if((((i_start==i_end)&&(j_start==j_end))&&n<5)) { Console.Out.WriteLine(n_r); Console.Out.WriteLine(output); } else { if((i_start>i_end) && (j_start>j_end)) { //Console.Out.Write("UpperLeft"); i_s-=2; j_s-=1; MakeMove(Move.UpperLeft); n_r++; MakeMove(n_r,i_s,j_s,i_end,j_end); } else if((i_start>i_end) && (j_startj_end)) { //Console.Out.Write("LowerLeft"); i_s+=2; j_s-=1; MakeMove(Move.LowerLeft ); n_r++; MakeMove(n_r,i_s,j_s,i_end,j_end); }else if((i_start==i_end) && (j_start>j_end)) { // Console.Out.Write("Left"); j_s-=2; MakeMove(Move.Left); n_r++; MakeMove(n_r,i_s,j_s,i_end,j_end); } else if((i_start>i_end) && (j_start==j_end)) { // Console.Out.Write("UpperLe"); i_s-=2; j_s-=1; MakeMove(Move.UpperLeft ); n_r++; MakeMove(n_r,i_s,j_s,i_end,j_end); } else if((i_starti_end) && (j_start==j_end)); Console.Out.WriteLine("Si="+i_start); Console.Out.WriteLine("Sj="+j_start); Console.Out.WriteLine("Ei="+i_end); Console.Out.WriteLine("Ej="+j_end); Console.Out.Write("Case not defined"); } } } static bool IsInSimilarRow(int intOne, int intTwo) { if(intOne%2==0) { return (intOne/2)%2==(intTwo/2)%2; }else { return ((intOne+1)/2)%2==((intTwo+1)/2)%2; } } static bool IsEven(int integer) { if((integer)%2==0) return true; else return false; } static bool IsEven(int integer1,int integer2) { return ((integer1%2)==(integer2%2)); } static bool PossibleToGetDestination(int n, int i_start, int j_start, int i_end, int j_end) { bool endJ_equal_startJ; endJ_equal_startJ = IsInSimilarRow(i_start,i_end); if(IsEven(i_start,i_end)) { if(IsEven(j_start,j_end)==endJ_equal_startJ) { return true; }else return false; } else return false; } 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.\ if(PossibleToGetDestination(n, i_start, j_start, i_end, j_end)) { output=null; MakeMove(0,i_start, j_start, i_end, j_end); } else Console.Out.WriteLine("Impossible"); } static void Main(String[] args) { int n = Convert.ToInt32(Console.ReadLine()); string[] tokens_i_start = Console.ReadLine().Split(' '); int i_start = Convert.ToInt32(tokens_i_start[0]); int j_start = Convert.ToInt32(tokens_i_start[1]); int i_end = Convert.ToInt32(tokens_i_start[2]); int j_end = Convert.ToInt32(tokens_i_start[3]); printShortestPath(n, i_start, j_start, i_end, j_end); } }