#include #include #include #include #include #include using namespace std; typedef unsigned int ui; typedef unsigned long long ul; typedef long long sl; ui v[200][200]; bool u[200][200]; ui pp[1000], np; int main(int argc, char* argv[]) { ios_base::sync_with_stdio(false); int n; cin >> n; int cs, rs, ce, re; cin >> rs >> cs >> re >> ce; queue q; q.push(rs); q.push(cs); u[rs][cs] = true; int sr[] = { 2, 2, 0, -2, -2, 0 }, sc[] = { 1, -1, -2, -1, 1, 2 }; char* p[] = { "UL", "UR", "R", "LR", "LL", "L" }; while (!q.empty()) { int qr = q.front(); q.pop(); int qc = q.front(); q.pop(); for (int i = 0; i < 6; ++i) { int vr = qr + sr[i], vc = qc + sc[i]; if (vr >= 0 && vr < n && vc >= 0 && vc < n && !u[vr][vc]) { u[vr][vc] = true; v[vr][vc] = v[qr][qc] + 1; q.push(vr), q.push(vc); } } } if (!u[re][ce]) cout << "Impossible\n"; else { cout << v[re][ce] << '\n'; int cq = v[re][ce], e = cq; for (int i = 0; i < e; ++i) { --cq; for (int i = 0; i < 6; ++i) { int vr = re + sr[i], vc = ce + sc[i]; if (vr >= 0 && vr < n && vc >= 0 && vc < n && v[vr][vc] == cq) { pp[np++] = i; re = vr; ce = vc; break; } } } sort(pp, pp + np); for (int i = 0; i < np; ++i) cout << p[pp[i]] << ' '; cout << '\n'; } return 0; }