#include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef unsigned int ui; typedef long double ld; typedef pair ii; typedef pair iii; int MOD = 10; const ld E = 1e-9; #define null NULL #define ms(x) memset(x, 0, sizeof(x)) #ifndef LOCAL #define endl "\n" #endif #ifndef LONG_LONG_MAX #define LONG_LONG_MAX LLONG_MAX #endif #define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define _read(x) freopen(x, "r", stdin) #define _write(x) freopen(x, "w", stdout) #define files(x) _read(x ".in"); _write(x ".out") #define filesdatsol(x) _read(x ".DAT"); _write(x ".SOL") #define output _write("output.txt") #define input _read("input.txt") #define prev time_prev #ifndef M_PI #define M_PI acos(-1) #endif #define remove tipa_remove #define next tipa_next #define left tipa_left #define right tipa_right #define mod % MOD #define y1 hello_world unsigned char ccc; bool _minus = false; template inline T sqr(T t) { return (t * t); } inline void read(ll &n) { n = 0; _minus = false; while (true) { ccc = getchar(); if (ccc == ' ' || ccc == '\n') break; if (ccc == '-') { _minus = true; continue; } n = n * 10 + ccc - '0'; } if (_minus) n *= -1; } inline bool read(int &n) { n = 0; _minus = false; while (true) { ccc = getchar(); if (ccc == ' ' || ccc == '\n') { if (ccc == '\n') return true; break; } if (ccc == '-') { _minus = true; continue; } n = n * 10 + ccc - '0'; } if (_minus) n *= -1; return false; } char wwww[19]; int kkkk; inline void write(ll y) { long long x = y; kkkk = 0; if (x < 0) { putchar('-'); x *= -1; } if (!x) wwww[++kkkk] = '0'; else while (x) { ++kkkk; wwww[kkkk] = char(x % 10 + '0'); x /= 10; } for (int i = kkkk; i >= 1; --i) putchar(wwww[i]); } #ifdef LOCAL #define __DEBUG #endif #ifdef __DEBUG #define dbg if(1) #else #define dbg if(0) #endif bool used[200][200]; string ty[6] = {"UL", "UR", "R", "LR", "LL", "L"}; int X[6] = {-2, -2, 0, 2, 2, 0}; int Y[6] = {-1, 1, 2, 1, -1, -2}; int type[200][200]; int main() { sync; srand((unsigned int) time(NULL)); cout.precision(10); cout << fixed; #ifdef LOCAL input; output; #else #endif int n; cin >> n; int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; used[x1][y1] = true; queue > q; q.push(make_pair(x1, y1)); while(!q.empty()){ int x = q.front().first; int y = q.front().second; q.pop(); if(x == x2 && y == y2){ vector vec; while(x != x1 || y != y1){ vec.push_back(ty[type[x][y]]); int ind = type[x][y]; x -= X[ind], y -= Y[ind]; } reverse(vec.begin(), vec.end()); cout << vec.size() << endl; for(string a : vec){ cout << a << " "; } cout << endl; return 0; } for(int i = 0; i < 6; i++){ int x1 = x + X[i]; int y1 = y + Y[i]; if(0 <= x1 && x1 < n && 0 <= y1 && y1 < n && !used[x1][y1]){ used[x1][y1] = true; type[x1][y1] = i; q.push(make_pair(x1, y1)); } } } cout << "Impossible" << endl; }