#include using namespace std; struct point { int x, y; }; point s, d, p; int N; bool isValid(int x, int y) { if(0 <= x && x < N && 0 <= y && y < N) return true; return false; } int f = 0; 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. int v[n+1][n+1] = {0}; point prev[n+1][n+1] = {0}; int i, j; N = n; for(i = 0; i < n; i++) for(j = 0; j < n; j++) prev[i][j].x = -1; memset(v, 0, sizeof(v)); s.x = i_start, s.y = j_start; d.x = i_end, d.y = j_end; int steps = 0; int reached = 0; queue q; q.push(s); while(q.size() > 0) { int size = q.size(); while(size--) { p = q.front(); q.pop(); v[p.x][p.y] = 1; if(v[d.x][d.y] || p.x == d.x && p.y == d.y) { reached = 1; break; } int x = p.x, j = p.y; point t; // UL, UR, R, LR, LL, L t.x = x-2, t.y = j-1; if(isValid(x-2, j-1) && !v[t.x][t.y] && prev[t.x][t.y].x == -1) q.push(t), prev[t.x][t.y] = p; t.x = x-2, t.y = j+1; if(isValid(x-2, j+1) && !v[t.x][t.y] && prev[t.x][t.y].x == -1) q.push(t), prev[t.x][t.y] = p; t.x = x, t.y = j+2; if(isValid(x-2, j-1) && !v[t.x][t.y] && prev[t.x][t.y].x == -1) q.push(t), prev[t.x][t.y] = p; t.x = x+2, t.y = j+1; if(isValid(x+2, j+1) && !v[t.x][t.y] && prev[t.x][t.y].x == -1) q.push(t), prev[t.x][t.y] = p; t.x = x+2, t.y = j-1; if(isValid(x-2, j-1) && !v[t.x][t.y] && prev[t.x][t.y].x == -1) q.push(t), prev[t.x][t.y] = p; t.x = x, t.y = j-2; if(isValid(x, j-2) && !v[t.x][t.y] && prev[t.x][t.y].x == -1) q.push(t), prev[t.x][t.y] = p; } if(reached) break; steps++; } if(reached) { point r; vector path(steps, "hi"); i = steps-1; p = d; int cnt = 0; while(i >= 0) { r = prev[p.x][p.y]; if(p.x-r.x == -2 && p.y-r.y == -1) path[i] = ("UL"); else if(p.x-r.x == -2 && p.y-r.y == 1) path[i] = ("UR"); else if(p.x-r.x == 0 && p.y-r.y == 2) path[i] = ("R"); else if(p.x-r.x == 2 && p.y-r.y == 1) path[i] = ("LR"); else if(p.x-r.x == 2 && p.y-r.y == -1) path[i] = ("LL"); else if(p.x-r.x == 0 && p.y-r.y == -2) path[i] = ("L"); i--; p = r; } reverse(path.begin(), path.end()); printf("%d\n", path.size()); for(i = steps-1; i >= 0; i--) printf("%s ", path[i].c_str()); } else printf("Impossible\n"); } int main() { 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; }