#include #define fi first #define se second using namespace std; const int maxN = 1e3+10; typedef pair ii; int N, xa, ya, xb, yb, dd[maxN][maxN]; ii trace[maxN][maxN]; int u[6] = {-2, -2, 0, 2, 2, 0}; int v[6] = {-1, 1, 2, 1, -1, -2}; string s[6] = {"UL", "UR", "R", "LR", "LL", "L"}; queue que; vector ans; bool check(int x, int y) { return (x >= 0 && y >= 0 && x < N && y < N); } void BFS() { que.push(ii(xa, ya)); dd[xa][ya] = 1; while (!que.empty()) { int x = que.front().fi, y = que.front().se; que.pop(); for (int i=0; i < 6; i++) { int xx = x + u[i], yy = y + v[i]; if (check(xx, yy) && dd[xx][yy] == 0) { dd[xx][yy] = dd[x][y] + 1; que.push(ii(xx, yy)); trace[xx][yy] = ii(x, y); } } } } int main() { cin >> N >> xa >> ya >> xb >> yb; BFS(); if (dd[xb][yb] == 0) cout << "Impossible"; else { cout << dd[xb][yb] - 1 << "\n"; while (xb != xa || yb != ya) { int x = trace[xb][yb].fi, y = trace[xb][yb].se; for (int i=0; i < 6; i++) if (x + u[i] == xb && y + v[i] == yb) { ans.push_back(s[i]); break; } xb = x; yb = y; } reverse(ans.begin(), ans.end()); for (int i=0; i < ans.size(); i++) cout << ans[i] << " "; } }