#define taskname "data" #include #define FOR(i, a, b) for(int i = (a) ; i <= (b) ; ++i) #define FOD(i, a, b) for(int i = (a) ; i >= (b) ; --i) #define RP(i, a, b) for(int i = (a) ; i < (b) ; ++i) #define FORE(i, a) for(__typeof((a).begin()) i = (v).begin() ; i != (v).end() ; ++i) #define FRSZ(i, a) for(int i = 0 ; i < (a).size() ; ++i) #define FPSZ(i, a) for(int i = 0 ; i < (a).size() - 1 ; ++i) #define RPSZ(i, a) for(int i = 1 ; i < (a).size() ; ++i) #define FDSZ(i, a) for(int i = (a).size() - 1 ; i >= 0 ; --i) #define ALL(x) (x).begin(),(x).end() #define SET(x) memset(x, -1, sizeof x) #define CLR(x) memset(x, 0, sizeof x) #define BIG(x) memset(x, 0x3f3f3f3f, sizeof x); #define debugarr(a, n) {FOR(_, 1, n) printf("%d ", (a)[_]); cout << endl;} #define debugvi(x) {FRSZ(_, x) cout << (x)[_] << " " ; cout << endl;} #define debug(x) cout << #x << " = " << x << endl; #define fi first #define se second using namespace std; template void Read(T &x){ char ch; bool neg = 0; x = 0; while(!isdigit(ch = getchar()) && ch != '-'); if (ch == '-') {neg = 1; ch = getchar();} do{x = x * 10 + ch - 48;} while(isdigit(ch = getchar())); if (neg) x = -x; return;} template void Write(T x){ char ch[32]; int cnt = 0; bool neg = 0; if (x < 0) {neg = 1; x = -x;} do{ch[++cnt] = x % 10 + 48 ; x /= 10;} while(x); if (neg) putchar('-'); FOD(i, cnt, 1) putchar(ch[i]);} template void Writeln(T x){ Write(x); putchar('\n');} template void Writesp(T x){ Write(x); putchar(' ');} typedef pair ii; typedef pair III; const int dx[6] = {-2 , -2, 0, 2, 2, 0}; const int dy[6] = {-1, 1, 2, 1, -1, -2}; const int MAX = 205; const int INF = 0x3f3f3f3f; int n; int d[MAX][MAX], trace[MAX][MAX]; ii s, t; vector st(6); void Enter(){ Read(n); scanf("%d%d%d%d", &s.fi, &s.se, &t.fi, &t.se); ++s.fi; ++s.se; ++t.fi; ++t.se; } void Init(){ st[0] = "UL"; st[1] = "UR"; st[2] = "R"; st[3] = "LR"; st[4] = "LL"; st[5] = "L"; } void Solve(){ priority_queue, greater > pq; BIG(d); pq.push(III(0, s)); d[s.fi][s.se] = 0; while(pq.size()){ ii u = pq.top().se; int t = pq.top().fi; pq.pop(); if (t != d[u.fi][u.se]) continue; FOR(i, 0, 5){ int x = u.fi + dx[i]; int y = u.se + dy[i]; if (x < 1 || x > n) continue; if (y < 1 || y > n) continue; if (d[x][y] == d[u.fi][u.se] + 1) if (trace[x][y] < i) trace[x][y] = i; if (d[x][y] > d[u.fi][u.se] + 1){ d[x][y] = d[u.fi][u.se] + 1; trace[x][y] = i; pq.push(III(d[x][y], ii(x, y))); } } } /*FOR(i, 1, n) { FOR(j, 1, n) cout << trace[i][j] << " "; cout << endl; }*/ if (d[t.fi][t.se] >= INF){ cout << "Impossible"; return; } ii u = t; vector res; Writeln(d[t.fi][t.se]); while(u != s){ res.push_back(st[trace[u.fi][u.se]]); ii tmp; tmp.fi = u.fi - dx[trace[u.fi][u.se]]; tmp.se = u.se - dy[trace[u.fi][u.se]]; u = tmp; } reverse(ALL(res)); FRSZ(i, res) cout << res[i] << " "; } int main(int argc, char const *argv[]) { Enter(); Init(); Solve(); return 0; }