using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static Dictionary bfs = new Dictionary(); static Dictionary route = new Dictionary(); static Dictionary move = new Dictionary(); static Queue q = new Queue(); static int nn; static int dd; static string ss; static void Add(int i, int j, string m) { if (i >= 0 && j >= 0 && i < nn && j < nn) { string k = "" + i + " " + j; if (!route.ContainsKey(k)) { bfs[k] = dd+1; route[k] = ss; move[k] = m; q.Enqueue(k); } } } static void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { nn = n; int row_diff = (200 + i_start - i_end) % 4; int col_diff = (200 + j_start - j_end) % 2; if ((row_diff == 1) || (row_diff == 3) || (row_diff == 0 && col_diff == 1) || (row_diff == 2 && col_diff == 2)) { Console.WriteLine("Impossible"); return; } bfs["" + i_start + " " + j_start] = 0; route["" + i_start + " " + j_start] = "MAGIC"; move["" + i_start + " " + j_start] = "START"; q.Enqueue("" + i_start + " " + j_start); while(q.Count > 0) { string s = q.Dequeue(); int d = bfs[s]; int i = int.Parse(s.Split()[0]); int j = int.Parse(s.Split()[1]); if (i == i_end && j == j_end) { Console.WriteLine(d); Stack st = new Stack(); while (route[s] != "MAGIC") { st.Push(move[s]); s = route[s]; } while (st.Count > 0) { Console.Write(st.Pop()); if (st.Count > 0) Console.Write(" "); } return; } dd = d; ss = s; Add(i-2, j-1, "UL"); Add(i-2, j+1, "UR"); Add(i, j+2, "R"); Add(i+2, j+1, "LR"); Add(i+2, j-1, "LL"); Add(i, j-2, "L"); } } 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); } }