//In The Name Of The GOD #pragma comment (linker, "/stack:20000000") #pragma GCC optimize ("Ofast") #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") #include /*#include #include #include */ #define sz(s) (int)(s.size ()) #define all(s) s.begin (), s.end () #define Time clock () * 1.0 / CLOCKS_PER_SEC #define sqr(x) ((x) * 1ll * (x)) #define modfix(a,b) ((a % b + b) % b) #define bit(x) __builtin_popcountll (x) using namespace std; //using namespace __gnu_pbds; typedef unsigned long long ull; typedef long long ll; typedef long double ld; /*typedef tree, null_type, less>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;*/ //find_by_order() order_of_key() const double PI = (double)(acos (-1.0)), EPS = (double)(1e-17); const int PR = 997, MOD = 1e9 + 7, INF = 1 << 30, MXN = 3e2 + 17; const int dx[] = {-2, -2, 0, 2, 2, 0}, dy[] = {-1, 1, 2, 1, -1, -2}; //const char nxtl = '\n'; templateinline bool updmin (T &a, const T &b) { return a > b ? a = b, 1 : 0; } templateinline bool updmax (T &a, const T &b) { return a < b ? a = b, 1 : 0; } int T = 1; int n, x_1, y_1, x_2, y_2; map, int>dist; queue>q; map, bool>used; map, pair>pr; inline bool check (int x, int y) { return (x >= 0 && y >= 0 && x < n && y < n); } inline void Solve_It_Fast () { scanf ("%d%d%d%d%d", &n, &x_1, &y_1, &x_2, &y_2); for (int i = 0; i <= n; ++i) { for (int j = 0; j <= n; ++j) { dist[{i, j}] = INF; } } dist[{x_1, y_1}] = 0; q.push ({x_1, y_1}); used[{x_1, y_1}] = 1; pr[{x_1, y_1}] = {-1, -1}; while (!q.empty ()) { pairv = q.front (); q.pop (); for (int i = 0; i < 6; ++i) { if (check (v.first + dx[i], v.second + dy[i])) { paircur = {v.first + dx[i], v.second + dy[i]}; if (updmin (dist[cur], dist[v] + 1)) { q.push (cur); pr[cur] = v; } } } } //printf ("%d\n", dist[{x_2, y_2}]); if (dist[{x_2, y_2}] >= INF) { printf ("Impossible\n"); } else { printf ("%d\n", dist[{x_2, y_2}]); paircur = {x_2, y_2}; vector>v; pairres = {-1, -1}; while (pr[cur] != res) { v.push_back (cur); cur = pr[cur]; } reverse (all (v)); pairprv = {x_1, y_1}; //printf ("%d\n", sz (v)); for (auto &to : v) { //printf ("%d %d\n" ,to.first, to.second); if (prv.first == to.first) { if (prv.second - to.second > 0) { printf ("L "); } else { printf ("R "); } } else if (prv.first - to.first == 2) { printf ("U"); if (prv.second - to.second == 1) { printf ("L "); } else { printf ("R "); } } else { printf ("L"); if (prv.second - to.second == 1) { printf ("L "); } else { printf ("R "); } } prv = to; } } } int main () { //freopen ("DeBuG.in", "r", stdin); //freopen ("OutputMain.out", "w", stdout); //scanf ("%d", &T); for (int i = 1; i <= T; ++i) { //printf ("Case %d: ", i); Solve_It_Fast (); } //printf ("\n%lf\n", Time); return 0; }