#include using namespace std; vector mv = {"UL", "UR", "R", "LR", "LL", "L"}; bool cmp(string a, string b) { return find(mv.begin(), mv.end(), a) < find(mv.begin(), mv.end(), b); } 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 dist = 0; vector path; if (i_start < i_end) { while (i_start < i_end && i_start < n && j_start >= 0 && j_start < n) { if (j_start <= j_end) { j_start++; path.push_back("LR"); } else { j_start--; path.push_back("LL"); } i_start += 2; dist++; } } else { while (i_start > i_end && i_start > -1 && j_start >= 0 && j_start < n) { if (j_start >= j_end) { j_start--; path.push_back("UL"); } else { j_start++; path.push_back("UR"); } i_start -= 2; dist++; } } if (i_start == i_end && i_start < n && j_start >= 0 && j_start < n) { if (j_start < j_end) { while (j_start < j_end) { path.push_back("R"); j_start += 2; dist++; } } else { while (j_start > j_end) { path.push_back("L"); j_start -= 2; dist++; } } if (j_start == j_end) { cout << dist << endl; sort(path.begin(), path.end(), cmp); for (int i = 0; i < dist; i++) cout << path[i] << " "; } else { cout << "Impossible"; } return; } cout << "Impossible"; } 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; }