using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static void FindPath(ref Queue q, ref int i_start, ref int j_start, ref int i_end, ref int j_end) { if ((i_end < i_start) && (j_end <= j_start)) { q.Enqueue("UL"); i_start -= 2; j_start -= 1; } else if ((i_end < i_start) && (j_end >= j_start)) { q.Enqueue("UR"); i_start -= 2; j_start += 1; } else if (((i_end == i_start) && (j_end > j_start)) || ((j_start - j_end > 3) && (j_end > j_start))) { q.Enqueue("R"); j_start += 2; } else if ((i_end > i_start) && (j_end >= j_start)) { q.Enqueue("LR"); i_start += 2; j_start += 1; } else if ((i_end > i_start) && (j_end <= j_start)) { q.Enqueue("LL"); i_start += 2; j_start -= 1; } else if ((i_end == i_start) && (j_end < j_start)) { q.Enqueue("L"); j_start -= 2; } } static void WriteHasil(Queue q) { Console.WriteLine(q.Count); do { string s = ""; if (q.Count == 0) { s = q.Dequeue(); } else { s = q.Dequeue() + " "; } Console.Write(s); } while (q.Count != 0); } 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. Queue q = new Queue(); bool cek = false; while ((i_start != i_end) || (j_start != j_end)) { if ((Math.Abs(i_start - i_end) % 2 != 0) || ((Math.Abs(j_start - j_end) % 2 != 0) && (i_start == i_end))) { cek = true; Console.WriteLine("Impossible"); break; } else { if (((Math.Abs(i_start - i_end) % 2 == 0) && (Math.Abs(j_start - j_end) % 2 == 0)) || ((Math.Abs(i_start - i_end) % 2 == 0) && (j_start == j_end))) { if ((((Math.Abs(i_start - i_end) % 4 == 0) && (Math.Abs(j_start - j_end) % 4 == 0)) || ((Math.Abs(i_start - i_end) % 4 == 0) && (j_start == j_end))) || (Math.Abs(i_start - i_end) >= 4) || (Math.Abs(j_start - j_end) >= 4)) { FindPath(ref q, ref i_start, ref j_start, ref i_end, ref j_end); } else if ((Math.Abs(j_start - j_end) % 2 == 0) && (i_start == i_end)) { FindPath(ref q, ref i_start, ref j_start, ref i_end, ref j_end); } else { cek = true; Console.WriteLine("Impossible"); break; } } else { FindPath(ref q, ref i_start, ref j_start, ref i_end, ref j_end); } } } if (!cek) { WriteHasil(q); } } 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); Console.ReadKey(); } }