using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static void printShortestPath(int n, int y_start, int x_start, int y_end, int x_end) { // Print the distance along with the sequence of moves. // Order of Priority: UL(-1,-2), UR(+1,+2), R(+2,0), LR(1,-2), LL(-1,-2), L(-2,0) int moves = 0; string list_of_moves = ""; bool keep_searching = true; int x = x_start; int y = y_start; n--; while (keep_searching) { if(((y > y_end && x > x_end) || (y - y_end >= 4 && x == x_end)) && (x - 1) >= 0 && (y - 2) <= n)//UL(x - 1, y - 2) { x -= 1; y -= 2; list_of_moves += "UL "; moves++; } else if(((y > y_end && x < x_end) || (y - y_end >= 4 && x == x_end)) && x + 1 <= n && y - 2 <= n)//UR(x + 1, y - 2) { x++; y -= 2; list_of_moves += "UR "; moves++; } else if (y == y_end && x < x_end && x + 2 <= n && x - x_end < -1)//R(x + 2, y + 0) { x += 2; list_of_moves += "R "; moves++; } else if(((y < y_end && x < x_end) || (y - y_end <= -4 && x == x_end)) && x + 1 <= n && y + 2 >= 0)//LR(x + 1, y + 2) { x++; y += 2; list_of_moves += "LR "; moves++; } else if (((y < y_end && x > x_end) || (y - y_end <= -4 && x == x_end)) && x - 1 >= 0 && y + 2 >= 0)//LL(x - 1, y + 2) { x--; y += 2; list_of_moves += "LL "; moves++; } else if (y == y_end && x > x_end && x - 2 >= 0 && x - x_end > 1)//L(x - 2, y + 0) { x -= 2; list_of_moves += "L "; moves++; } else { Console.WriteLine("Impossible"); break; } if (x == x_end && y == y_end) { list_of_moves = list_of_moves.Substring(0, list_of_moves.Length - 1); Console.WriteLine(moves); Console.WriteLine(list_of_moves); keep_searching = 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); } }