#include #include #include #include #include using namespace std; // UL, UR, R, LR, LL, L. void goUL(int& x1, int& y1, int& x2, int& y2, vector& steps) { while (x1 > x2 && y1 > y2) { steps.emplace_back("UL"); x1--; y1 -= 2; } } void goUR(int& x1, int& y1, int& x2, int& y2, vector& steps) { while (x1 < x2 && y1 > y2) { steps.emplace_back("UR"); x1++; y1 -= 2; } } void goR(int& x1, int& x2, vector& steps) { while (x1 < x2) { steps.emplace_back("R"); x1 += 2; } } void goLR(int& x1, int& y1, int& x2, int& y2, vector& steps) { while (x1 < x2 && y1 < y2) { steps.emplace_back("LR"); x1++; y1 += 2; } } void goLL(int& x1, int& y1, int& x2, int& y2, vector& steps) { while (x1 > x2 && y1 < y2) { steps.emplace_back("LL"); x1--; y1 += 2; } } void goL(int& x1, int& x2, vector& steps) { while (x1 > x2) { steps.emplace_back("L"); x1 -= 2; } } void goU(int& x1, int l, int& y1, int& y2, vector& steps) { while(y1 > y2) { if (x1 > l) { steps.emplace_back("UL"); steps.emplace_back("UR"); } else { steps.emplace_back("UR"); steps.emplace_back("UL"); } y1 -= 4; } } void goD(int& x1, int r, int& y1, int& y2, vector& steps) { while(y1 < y2) { if (x1 < r) { steps.emplace_back("LR"); steps.emplace_back("LL"); } else { steps.emplace_back("LL"); steps.emplace_back("LR"); } y1 += 4; } } int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int n, x1, y1, x2, y2; cin >> n >> y1 >> x1 >> y2 >> x2; int h = abs(y1 - y2), w = abs(x1 - x2); if (h % 2) { cout << "Impossible" << endl; return 0; } if ((h % 4 && w % 2 == 0) || (h % 4 == 0 && w % 2)) { cout << "Impossible" << endl; return 0; } vector steps; if (x1 < x2 && y1 < y2) goLR(x1, y1, x2, y2, steps); else if (x1 < x2 && y1 > y2) goUR(x1, y1, x2, y2, steps); else if (x1 > x2 && y1 > y2) goUL(x1, y1, x2, y2, steps); else if (x1 > x2 && y1 < y2) goLL(x1, y1, x2, y2, steps); // cout << endl << "----------------------------------------1" << endl; goL(x1, x2, steps); // cout << endl << "----------------------------------------2" << endl; goR(x1, x2, steps); // cout << endl << "----------------------------------------3" << endl; goU(x1, 0, y1, y2, steps); // cout << endl << "----------------------------------------4" << endl; goD(x1, n - 1, y1, y2, steps); // cout << endl << "----------------------------------------5" << endl; cout << steps.size() << endl; for (auto &s : steps) cout << s << " "; cout << endl; return 0; }