#include using namespace std; void printShortestPath(int n, int j_start, int i_start, int j_end, int i_end) { // Print the distance along with the sequence of moves. int yDist = abs (j_end - j_start); bool possible = true; if (yDist % 2 == 1) { possible = false; } else { int xDist = abs(i_end - i_start); yDist /= 2; if (yDist % 2 == 1) { if (xDist % 2 == 0) { possible = false; } } else { if (xDist % 2 == 1) { possible = false; } } } if (!possible) { cout << "Impossible"; return; } vector operations; int x = i_start, y = j_start; while (x != i_end && y != j_end) { if (i_end < x) { if (j_end < y) { operations.push_back("UL"); y -= 2; } else { operations.push_back("L"); y += 2; } x -= 1; } else { if (j_end < y) { operations.push_back("UR"); y -= 2; } else { operations.push_back("LR"); y += 2; } x += 1; } } if (x == i_end) { if (j_end < y) { int height = abs(y - j_end) / 2; for (int i = 0; i < height / 2; ++i) { operations.push_back("UL"); operations.push_back("UR"); } } else { int height = abs(y - j_end) / 2; for (int i = 0; i < height / 2; ++i) { operations.push_back("LR"); operations.push_back("LL"); } } } else if (y == j_end) { if (i_end < x) { int length = abs(x - i_end) / 2; for (int i = 0; i < length; ++i) { operations.push_back("L"); } } else { int length = abs(x - i_end) / 2; for (int i = 0; i < length; ++i) { operations.push_back("R"); } } } cout << operations.size() << endl; for (int i = 0; i < operations.size(); ++i) { cout << operations[i] << ' '; } } 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; }