#include #include #include #include #include using namespace std; int valid(int i0, int j0, int i1, int j1) { if (abs(i1 - i0) % 2) return 0; if (((abs(i1 - i0) / 2) % 2) && (abs(j1 - j0) % 2 == 0)) return 0; if (((abs(i1 - i0) / 2) % 2 == 0) && (abs(j1 - j0) % 2)) return 0; return 1; } int metric(int i0, int j0, int i1, int j1) { return abs(i1 - i0) + abs(j1 - j0); } string printStep(int i) { switch(i) { case 0: return "UL"; case 1: return "UR"; case 2: return "R"; case 3: return "LR"; case 4: return "LL"; case 5: return "L"; } return ""; } int main() { int n; cin >> n; int i0, j0, i1, j1; cin >> i0 >> j0; cin >> i1 >> j1; if (!valid(i0, j0, i1, j1)) { cout << "Impossible" << endl; return 0; } pair pairs[6] = {{-2, -1}, {-2, 1}, {0, 2}, {2, 1}, {2, -1}, {0, -2}}; int iTemp = i0, jTemp = j0; vector steps; while (metric(iTemp, jTemp, i1, j1) > 0) { int maxMetric = metric(iTemp, jTemp, i1, j1); int k = 0; for (int i = 0; i < 6; ++i) { pair x = pairs[i]; if ((iTemp + x.first >= 0 && iTemp + x.first < n) && (jTemp + x.second >= 0 && jTemp + x.second < n)) { int mtr = metric(iTemp + x.first, jTemp + x.second, i1, j1); if (mtr < maxMetric) { maxMetric = mtr; k = i; } } } steps.push_back(k); iTemp += pairs[k].first; jTemp += pairs[k].second; } sort(steps.begin(), steps.end()); cout << steps.size() << endl; for (auto s: steps) cout << printStep(s) << " "; return 0; }