using System; using System.Collections.Generic; using System.Text; using System.Linq; public class Helper{ public int x, y; public long moves; public StringBuilder sb; public Helper(int x, int y, long moves){ this.x = x; this.y = y; this.moves = moves; sb = new StringBuilder(""); } } class Solution { static bool[][] isVisited; static bool isValid(int x, int y, int n){ if(x<0 || x>=n || y<0 || y>=n){ return false; } if(isVisited[x][y]){ return false; } return true; } static void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { isVisited = new bool[n][]; int[] x = {-2, -2, 0, 2, 2, 0}; int[] y = {-1, 1, 2, 1, -1, -2}; string[] movename = {"UL", "UR", "R", "LR", "LL", "L"}; for(int i=0;i q = new Queue(); Helper temp, trav; temp = new Helper(i_start, j_start, 0); q.Enqueue(temp); isVisited[temp.x][temp.y] = true; while(q.Count>0){ trav = q.Dequeue(); for(int i=0;i<6;i++){ if(isValid(trav.x + x[i], trav.y + y[i], n)){ temp = new Helper(trav.x + x[i], trav.y + y[i], trav.moves+1); temp.sb.Append(trav.sb).Append(" ").Append(movename[i]); q.Enqueue(temp); isVisited[temp.x][temp.y] = true; } if(temp.x == i_end && temp.y == j_end){ Console.WriteLine(temp.moves); Console.WriteLine(temp.sb.ToString().Trim()); return; } } } Console.WriteLine("Impossible"); } 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); } }