#include #include #include #include #include #include #define MP(a, b) std::make_pair(a, b) #define REP(i, n) for (int i = 0; i < (n); ++i) const int MX = 205, INF = 22025; int v[MX][MX], d[MX][MX], m[MX][MX], N, nx[6], ny[6]; std::pair f[MX][MX]; std::string s[] = { "UL", "UR", "R", "LR", "LL", "L" }; inline int chk(int a, int b) { return a >= 0 && b >= 0 && a < N && b < N && !v[a][b]; } void bfs(int a, int b) { std::queue> q; q.push(MP(a, b)); d[a][b] = 0; while (!q.empty()) { auto p = q.front(); q.pop(); int x = p.first, y = p.second; nx[0] = x-2, nx[1] = x-2, nx[2] = x, nx[3] = x+2, nx[4] = x+2, nx[5] = x; ny[0] = y-1, ny[1] = y+1, ny[2] = y+2, ny[3] = y+1, ny[4] = y-1, ny[5] = y-2; REP(i, 6) { if (chk(nx[i], ny[i])) { v[nx[i]][ny[i]] = 1; d[nx[i]][ny[i]] = d[x][y] + 1; m[nx[i]][ny[i]] = i; f[nx[i]][ny[i]] = MP(x, y); q.push(MP(nx[i], ny[i])); } } } } int main() { int a1, b1, a2, b2; std::vector moves; scanf("%d%d%d%d%d", &N, &a1, &b1, &a2, &b2); REP(i, N) REP(j, N) d[i][j] = INF; bfs(a1, b1); if (d[a2][b2] < INF) { printf("%d\n", d[a2][b2]); int x = a2, y = b2; while (x != a1 || y != b1) { moves.push_back(m[x][y]); auto p = f[x][y]; x = p.first, y = p.second; } std::reverse(moves.begin(), moves.end()); REP(i, moves.size()) printf("%s ", s[moves[i]].c_str()); printf("\n"); } else { printf("Impossible\n"); } return 0; }