/*input 7 6 6 0 1 */ #include using namespace std; int main () { int n, x0, y0, x1, y1; cin >> n >> y0 >> x0 >> y1 >> x1; vector, string>> ej = {{{ -1, -2}, "UL"}, {{ +1, -2}, "UR"}, {{ +2, 0}, "R"}, {{ +1, +2}, "LR"}, {{ -1, +2}, "LL"}, {{ -2, 0}, "L"}}; int from[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) from[i][j] = -1; } queue >a; a.push(make_pair(x0, y0)); from[x0][y0] = -2; while (!a.empty()) { int x = a.front().first; int y = a.front().second; //cout << x << " " << y << endl; a.pop(); for (int typ = 0; typ < ej.size(); typ++) { pair del = ej[typ].first; int xn = x + del.first; int yn = y + del.second; //cout << "T" << xn << " " << yn << endl; if (xn >= 0 and xn < n and yn >= 0 and yn < n and from[xn][yn] == -1) { from[xn][yn] = typ; a.push(make_pair(xn, yn)); } } } if (from[x1][y1] == -1) cout << "Impossible"; else { vector kel; while (x1 != x0 or y1 != y0) { kel.push_back(from[x1][y1]); pair del = ej[from[x1][y1]].first; x1 -= del.first; y1 -= del.second; } cout << kel.size() << "\n"; reverse(kel.begin(), kel.end()); for (auto && x : kel) cout << ej[x].second << " "; } return 0; }