using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { var paths = GetPaths(new List(), n, i_start, j_start, i_end, j_end); if (paths.Count==0) { Console.WriteLine("0"); Console.WriteLine(); return; } if (paths[paths.Count()-1]=="Impossible") { Console.WriteLine("Impossible"); } else { Console.WriteLine(paths.Count()); Console.WriteLine(string.Join(" ", paths)); } } static List GetPaths(List paths, int n, int i_start, int j_start, int i_end, int j_end) { Console.WriteLine($"i={i_start} j={j_start}"); if (i_start == i_end && (j_end == j_start)) { Console.WriteLine($"I'm here"); return paths; } if (Math.Abs(j_end - j_start) == 1 && Math.Abs(i_end - i_start) == 1) { // Impossible paths.Add("Impossible"); Console.WriteLine($"Impossible"); return paths; } if (i_start == i_end) { if (j_end < j_start) { // move L j_start-= 2; paths.Add("L"); } else { // move R j_start+= 2; paths.Add("R"); } return GetPaths(paths, n, i_start, j_start, i_end, j_end); } if(i_end > i_start) { if (j_end > j_start) { // move LR i_start+=2; j_start+=1; paths.Add("LR"); } else { // move LL i_start+=2; j_start-=1; paths.Add("LL"); } } else { if (j_end > j_start) { // move UR i_start-=2; j_start+=1; paths.Add("UR"); } else { // move UL i_start-=2; j_start-=1; paths.Add("UL"); } } return GetPaths(paths, n, i_start, j_start, i_end, j_end); } 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); } }