using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static Dictionary Moves(int n, int i_start, int j_start, int i_end, int j_end) { var d = new Dictionary { { "UL", 0 }, { "UR", 0 }, { "R", 0 }, { "LR", 0 }, { "LL", 0 }, { "L", 0 } }; while (i_start > i_end) { if (j_start >= j_end && j_start > 0) { d["UL"]++; j_start--; i_start -= 2; } else { d["UR"]++; j_start++; i_start -= 2; } } while (i_start < i_end) { if (j_start <= j_end && j_start < n - 1) { d["LR"]++; j_start++; i_start += 2; } else { d["LL"]++; j_start--; i_start += 2; } } if (j_start < j_end) d["R"] += (j_end - j_start) / 2; else d["L"] += (j_start - j_end) / 2; return d; } static void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { if (Math.Abs(i_start - i_end) % 2 == 1) { Console.Write("Impossible"); return; } var verDif = (Math.Abs(i_start - i_end) / 2) % 2; var horzDif = Math.Abs(j_start - j_end) % 2; if ((horzDif == 1 && verDif == 0) || horzDif == 0 && verDif == 1) { Console.Write("Impossible"); return; } //UL, UR, R, LR, LL, L var d = Moves(n, i_start, j_start, i_end, j_end); Console.WriteLine(d.Sum(x => x.Value)); while (d["UL"] > 0 || d["UR"] > 0 || d["R"] > 0 || d["LR"] > 0 || d["LL"] > 0 || d["L"] > 0) { if (d["UL"] > 0 && i_start >= 2 && j_start > 0) { i_start -= 2; j_start--; Console.Write("UL "); d["UL"]--; continue; } if (d["UR"] > 0 && i_start >= 2 && j_start < n - 1) { i_start -= 2; j_start++; Console.Write("UR "); d["UR"]--; continue; } if (d["R"] > 0 && j_start < n - 2) { j_start += 2; Console.Write("R "); d["R"]--; continue; } if (d["LR"] > 0 && i_start < n - 2 && j_start < n - 1) { i_start += 2; j_start++; Console.Write("LR "); d["LR"]--; continue; } if (d["LL"] > 0 && i_start < n - 2 && j_start > 0) { i_start += 2; j_start--; Console.Write("LL "); d["LL"]--; continue; } if (d["L"] > 0 && j_start >= 2) { j_start -= 2; Console.Write("L "); d["L"]--; continue; } } } 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); } }