using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static int n; int[,] steps, prevY, prevX; string[,] how; List curr; bool valid(int y, int x) { return (x >= 0) && (x < n) && (y >= 0) && (y < n); } void check(int stepsNow, string howName, int y, int x, int orgY, int orgX) { if (!valid(y, x) || (steps[y, x] != -1)) return; steps[y, x] = stepsNow + 1; how[y, x] = howName; curr.Add(y); curr.Add(x); prevY[y, x] = orgY; prevX[y, x] = orgX; } void printShortestPath(int n, int y1, int x1, int y2, int x2) { steps = new int[n, n]; prevY = new int[n, n]; prevX = new int[n, n]; how = new string[n, n]; for (int bx = 0; bx < n; bx++) for (int by = 0; by < n; by++) steps[by, bx] = -1; steps[y1, x1] = 0; curr = new List(); curr.Add(y1); curr.Add(x1); while ((curr.Count > 0) && (steps[y2, x2] == -1)) { int y = curr[0]; int x = curr[1]; curr.RemoveAt(0); curr.RemoveAt(0); int currSteps = steps[y, x]; check(currSteps, "UL", y - 2, x - 1, y, x); check(currSteps, "UR", y - 2, x + 1, y, x); check(currSteps, "R", y, x + 2, y, x); check(currSteps, "LR", y + 2, x + 1, y, x); check(currSteps, "LL", y + 2, x - 1, y, x); check(currSteps, "L", y, x - 2, y, x); } if (steps[y2, x2] == -1) Console.WriteLine("Impossible"); else { Console.WriteLine(steps[y2, x2]); int y = y2; int x = x2; string res = ""; while ((x != x1) || (y != y1)) { res = " " + how[y, x] + res; int yn = prevY[y, x]; int xn = prevX[y, x]; x = xn; y = yn; } Console.WriteLine(res.Substring(1)); } } static void Main(String[] args) { 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]); new Solution().printShortestPath(n, i_start, j_start, i_end, j_end); } }