#include using namespace std; int df[6] = {-2,-2,0,2,2,0}; int dc[6] = {-1,1,2,1,-1,-2}; struct Pos{ int f, c; Pos(int a, int b){ f = a; c = b; } }; struct dm{ int d, m; }; const int N = 200; dm t[N][N]; 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. queue q; Pos p(i_start, j_start); q.push(p); t[p.f][p.c].d = 0; bool enc = false; while(!q.empty()){ Pos o = p = q.front(); int dst = t[p.f][p.c].d; q.pop(); if(o.f == i_end and o.c == j_end){ enc = true; cout << dst << endl; vector v(dst); string s[6] = {"UL", "UR", "R", "LR", "LL", "L"}; o.f = i_end; o.c = j_end; for(int i = dst - 1; i >= 0; --i){ int m = t[o.f][o.c].m; v[i] = s[m]; o.f -= df[m]; o.c -= dc[m]; } cout << v[0]; for(int i = 1; i < dst; ++i) cout << " " << v[i]; cout << endl; break; } for(int i = 0; i < 6; ++i){ p = o; p.f += df[i]; p.c += dc[i]; if(p.f >= 0 and p.f < n and p.c >= 0 and p.c < n and t[p.f][p.c].d < 0){ q.push(p); t[p.f][p.c].d = dst + 1; t[p.f][p.c].m = i; } } } if(!enc) cout << "Impossible" << endl; } int main() { for(int i = 0; i < N; ++i){ for(int j = 0; j < N; ++j){ t[i][j].d = t[i][j].m = -1; } } int n; cin >> n; int i_start; int j_start; int i_end; int j_end; cin >> i_start >> j_start >> i_end >> j_end; printShortestPath(n, i_start, j_start, i_end, j_end); return 0; }