using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static string _p = ""; static int _i_end; static int _j_end; static void solve(bool[,] m, int i, int j, string p, int n) { if(i == _i_end && j == _j_end) { if(_p == "" || p.Length < _p.Length || (p.Length == _p.Length && string.Compare(p, _p) < 0)) { _p = p; //Console.Write("{0},", p); return; } } //UL, UR, R, LR, LL, L. if(j>=1 && i >=2 && m[i-2,j-1] == false && (_i_end-3 < i && _j_end-3 < j) ) { m[i-2,j-1] = true; solve( m, i-2, j-1, p + "A", n); m[i-2,j-1] = false; } if(j=2 && m[i-2, j+1] == false && (_i_end-3 < i && _j_end+3 > j)) { m[i-2, j+1] = true; solve( m, i-2, j+1, p + "B", n); m[i-2, j+1] = false; } if(j j)) { m[i, j+2] = true; solve( m, i, j+2, p + "C", n); m[i, j+2] = false; } //UL, UR, R, LR, LL, L. if(j i && _j_end+3 > j)) { m[i+2,j+1] = true; solve( m, i+2,j+1, p + "D", n); m[i+2,j+1] = false; } if(j>=1 && i i && _j_end-3 < j)) { m[i+2, j-1] = true; solve( m, i+2, j-1, p + "E", n); m[i+2, j-1] = false; } if(j>=2 && m[i, j-2] == false && ( _j_end-3 < j)) { m[i, j-2] = true; solve( m, i, j-2, p + "F", n); m[i, j-2] = false; } } 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. bool [,] m = new bool[n,n]; m[i_start, j_start] = true; _i_end = i_end; _j_end = j_end; solve( m, i_start, j_start, "", n); if(_p == "") { Console.Write("Impossible"); } else { Console.WriteLine(_p.Length); string [] str = new string[] {"UL", "UR", "R", "LR", "LL", "L"}; for(int i = 0; i < _p.Length; i++) { Console.Write(str[_p[i]-'A']); if(i < _p.Length-1) Console.Write(" "); else Console.Write("\n"); } } } 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); } }