#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include //#include //#include #include //#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define forn(i, n) for(int i = 0; i < int(n); i++) #define forn1(i, n) for(int i = 1; i <= int(n); i++) #define sz(a) int((a).size()) #define all(a) (a).begin(), (a).end() #define mp make_pair #define pb push_back #define x first #define y second typedef long long li; typedef long double ld; typedef pair pt; const int INF = int(1e9); const li INF64 = li(1e18); const ld PI = acosl(ld(-1)); const ld EPS = 1e-9; template inline T sqr(const T& x) { return x * x; } template inline T abs(const T& x) { return x > 0 ? x : -x; } inline bool inside(int x, int y, int n, int m) { return x >= 0 && x < n && y >= 0 && y < m; } inline int rnd() { return abs(rand() ^ (rand() << 15)); } inline int rnd(int n) { assert(n > 0); return rnd() % n; } inline int rnd(int lf, int rg) { return lf + rnd(rg - lf + 1); } inline li rndLL() { return rnd() * 1LL * rnd() + rnd(); } const int dx[4] = { -1, 0, +1, 0 }; const int dy[4] = { 0, +1, 0, -1 }; const int dx8[8] = { -1, -1, 0, +1, +1, +1, 0, -1 }; const int dy8[8] = { 0, +1, +1, +1, 0, -1, -1, -1 }; const int N = int(555); int n, x, y, x2, y2; void gen() { } bool read() { if (!(cin >> n >> x >> y >> x2 >> y2)) return false; return true; } int d[N][N]; void solve() { vector > v = { { { -2, -1 }, "UL" }, { { -2, +1 }, "UR" }, { { 0, +2 }, "R" }, { { +2, +1 }, "LR" }, { { +2, -1 }, "LL" }, { { 0, -2 }, "L" } }; forn(i, N) forn(j, N) d[i][j] = INF; d[x2][y2] = 0; queue q; q.push(pt(x2, y2)); while (!q.empty()) { int i = q.front().x; int j = q.front().y; q.pop(); forn(k, sz(v)) { int ni = i + v[k].x.x; int nj = j + v[k].x.y; if (inside(ni, nj, n, n) && d[ni][nj] == INF) { d[ni][nj] = d[i][j] + 1; q.push(pt(ni, nj)); } } } if (d[x][y] == INF) { puts("Impossible"); return; } cout << d[x][y] << endl; int mn = d[x][y]; int curd = 0; while (x != x2 || y != y2) { //cerr << x << ' ' << y << endl; //cerr << "???" << endl; bool has = false; forn(i, sz(v)) { int nx = x + v[i].x.x; int ny = y + v[i].x.y; if (inside(nx, ny, n, n) && curd + 1 + d[nx][ny] == mn) { if (curd) putchar(' '); printf(v[i].y.c_str()); x = nx; y = ny; has = true; break; } } assert(has); curd++; } puts(""); } //#undef _DEBUG int main() { #ifdef _DEBUG assert(freopen("777.txt", "rt", stdin)); assert(freopen("output.txt", "wt", stdout)); #endif cout << setprecision(10) << fixed; cerr << setprecision(10) << fixed; int T = 1; srand(int(time(NULL))); //assert(scanf("%d", &T) == 1); forn(i, T) { #ifdef _DEBUG cerr << "TEST == " << i << endl; #endif assert(read()); //cout << "Case #" << i + 1 << ": "; solve(); //if(i == 1) break; #ifdef _DEBUG cerr << "curTime == " << clock() << " ms" << endl; #endif } #ifdef _DEBUG cerr << "TIME == " << clock() << " ms" << endl; #endif return 0; }