#include #define FOR(x, a, b) for (int x = a; x <= b; ++x) #define FOD(x, a, b) for (int x = a; x >= b; --x) #define REP(x, a, b) for (int x = a; x < b; ++x) #define DEBUG(X) { cout << #X << " = " << X << endl; } #define PR(A, n) { cout << #A << " = "; FOR(_, 1, n) cout << A[_] << " "; cout << endl; } #define PR0(A, n) { cout << #A << " = "; REP(_, 0, n) cout << A[_] << " "; cout << endl; } using namespace std; typedef long long LL; typedef pair II; const int N = 2e2 + 10; const int INF = 0x3f3f3f3f; int dx[] = {-2, -2, +0, +2, +2, +0}; int dy[] = {-1, +1, +2, +1, -1, -2}; int n, sx, sy, tx, ty; int d[N][N], tr[N][N]; string S[] = {"LU ", "RU ", "R ", "RL ", "LL ", "L "}; queue Q; bool Inside(int x, int y) { return 1 <= x && x <= n && 1 <= y && y <= n; } int main() { #ifdef LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif // LOCAL scanf("%d", &n); scanf("%d%d%d%d", &sx, &sy, &tx, &ty); ++sx; ++sy; ++tx; ++ty; memset(d, INF, sizeof d); Q.push(II(sx, sy)); d[sx][sy] = 0; memset(tr, -1, sizeof tr); while (Q.size()) { int ux = Q.front().first, uy = Q.front().second; Q.pop(); FOR(k, 0, 5) { int vx = ux + dx[k], vy = uy + dy[k]; if (Inside(vx, vy) && d[vx][vy] > d[ux][uy] + 1) { d[vx][vy] = d[ux][uy] + 1; tr[vx][vy] = k; Q.push(II(vx, vy)); } } } if (d[tx][ty] >= INF) puts("Impossible"); else { printf("%d\n", d[tx][ty]); string ans; while (tr[tx][ty] != -1) { int k = tr[tx][ty]; ans += S[k]; tx = tx - dx[k]; ty = ty - dy[k]; } reverse(ans.begin(), ans.end()); REP(i, 1, ans.size()) putchar(ans[i]); } return 0; }