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) { // Print the distance along with the sequence of moves. if (isPossibleToReach(i_start, j_start, i_end, j_end)) { int i_act = i_start, j_act = j_start; int i_next, j_next; double d_act, d_next_min, d_next; string step = "", steps = ""; int num_of_steps = 0; d_act = calculateDistance(i_act, j_act, i_end, j_end); while (d_act != 0) { i_next = i_act-2; j_next = j_act-1; d_next_min = calculateDistance(i_next, j_next, i_end, j_end); step = "UL "; d_next = calculateDistance(i_act-2, j_act+1, i_end, j_end); if (d_next < d_next_min) { d_next_min = d_next; i_next = i_act-2; j_next = j_act+1; step = "UR "; } d_next = calculateDistance(i_act, j_act+2, i_end, j_end); if (d_next < d_next_min) { d_next_min = d_next; i_next = i_act; j_next = j_act+2; step = "R "; } d_next = calculateDistance(i_act+2, j_act+1, i_end, j_end); if (d_next < d_next_min) { d_next_min = d_next; i_next = i_act+2; j_next = j_act+1; step = "LR "; } d_next = calculateDistance(i_act+2, j_act-1, i_end, j_end); if (d_next < d_next_min) { d_next_min = d_next; i_next = i_act+2; j_next = j_act-1; step = "LL "; } d_next = calculateDistance(i_act, j_act-2, i_end, j_end); if (d_next < d_next_min) { d_next_min = d_next; i_next = i_act; j_next = j_act-2; step = "L "; } i_act = i_next; j_act = j_next; d_act = calculateDistance(i_act, j_act, i_end, j_end); steps += step; num_of_steps++; } Console.WriteLine(num_of_steps); Console.WriteLine(steps); } else { Console.WriteLine("Impossible"); } } static double calculateDistance(int i1, int j1, int i2, int j2) { return Math.Sqrt(Math.Pow(i1 - i2, 2) + Math.Pow(j1 - j2, 2)); } static bool isPossibleToReach(int i_start, int j_start, int i_end, int j_end) { if (Math.Abs(i_start-i_end) % 2 == 0) { if (Math.Abs(i_start-i_end) / 2 % 2 == 1) { if (Math.Abs(j_start-j_end) % 2 == 1) { return true; } else { return false; } } else { if (Math.Abs(j_start-j_end) % 2 == 0) { return true; } else { return false; } } } else { return false; } } 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); } }