#include #include #include #include #include #include #include using namespace std; string ss[] = {"UL", "UR", "R", "LR", "LL", "L"}; int xx[] = {-2, -2, 0, 2, 2, 0}; int yy[] = {-1, 1, 2, 1, -1, -2}; bool vis[222][222]; int path[40005], cnt; bool flag; int sx, sy, ex, ey, n; int prex[222][222], prey[222][222], prez[222][222]; struct Q { int x, y; Q() {} Q(int _x, int _y){ x = _x; y = _y;} }; queue q; void gao() { Q tmp(sx, sy); vis[sx][sy] = 1; q.push(tmp); while (!q.empty()) { Q f = q.front(); q.pop(); if (f.x == ex && f.y == ey) { flag = true; break; } for (int i = 0; i < 6; i++) { int tx = f.x + xx[i]; int ty = f.y + yy[i]; if (tx >= 0 && ty >= 0 && tx < n && ty < n) { if (!vis[tx][ty]) { Q next(tx, ty); q.push(next); vis[tx][ty] = 1; prex[tx][ty] = f.x; prey[tx][ty] = f.y; prez[tx][ty] = i; } } } } if (flag) { int nx = ex, ny = ey; while (nx != sx || ny != sy) { path[cnt++] = prez[nx][ny]; int tx = prex[nx][ny]; int ty = prey[nx][ny]; nx = tx; ny = ty; } printf("%d\n", cnt); for (int i = cnt - 1; i >= 0; i--) { printf("%s", ss[path[i]].c_str()); if (i) printf(" "); } printf("\n"); } else { printf("Impossible\n"); } } int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ cin >> n; cin >> sx >> sy >> ex >> ey; memset(prex, -1, sizeof(prex)); memset(prey, -1, sizeof(prey)); memset(prez, -1, sizeof(prez)); gao(); return 0; }