#include using namespace std; #define NRDIR 6 int dl[NRDIR] = {-2, -2, 0, 2, 2, 0}; int dc[NRDIR] = {-1, 1, 2, 1, -1, -2}; string sol[NRDIR] = {"UL", "UR", "R", "LR", "LL", "L"}; int d[200][200]; bool viz[200][200]; struct myc {int x, y;} q[200 * 200]; 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. for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) d[i][j] = 10000000; int st = 0, dr = 1; q[0] = {i_end, j_end}; d[i_end][j_end] = 0; viz[i_end][j_end] = 1; while (st < dr) { int x = q[st].x, y = q[st].y; st++; for (int i = 0; i < NRDIR; i++) { int a = x + dl[i], b = y + dc[i]; if (0 <= a & a < n && 0 <= b && b < n && d[x][y] + 1 < d[a][b]) { d[a][b] = d[x][y] + 1; if (viz[a][b] == 0) { viz[a][b] = 1; q[dr++] = {a, b}; } } } } if (viz[i_start][j_start] == 0) { cout << "Impossible"; return ; } int ans = d[i_start][j_start]; printf("%d\n", ans); while (ans) { ans--; int r = NRDIR; for (int i = 0; i < NRDIR; i++) { int a = i_start + dl[i], b = j_start + dc[i]; if (0 <= a && a < n && 0 <= b && b < n && d[a][b] == ans) r = min(i, r); } if (r == NRDIR) exit(1); cout << sol[r] << " "; i_start += dl[r]; j_start += dc[r]; } } 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; }