#include using namespace std; typedef pair ii; const int MAXN = (int)(205); ii go[6] = {{2, 1}, {2, -1}, {0, -2}, {-2, -1}, {-2, 1}, {0, 2}}; string trace[6] = {"UL", "UR", "R", "LR", "LL", "L"}; int d[MAXN][MAXN]; ii t_ii[MAXN][MAXN]; int t[MAXN][MAXN]; ii operator +(ii a, ii b) { return {a.first + b.first, a.second + b.second}; } void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { // Print the distance along with the sequence of moves. reverse(go, go + 6); reverse(trace, trace + 6); queue q; q.push({i_end, j_end}); memset(d, -1, sizeof(d)); d[i_end][j_end] = 0; while (!q.empty()) { ii u = q.front(); q.pop(); if (u == ii(i_start, j_start)) { break; } for(int i = 0; i < 6; ++i) { ii v = u + go[i]; if (0 <= v.first && v.first < n && 0 <= v.second && v.second < n) if (d[v.first][v.second] == -1) { q.push(v); d[v.first][v.second] = d[u.first][u.second] + 1; t_ii[v.first][v.second] = u; t[v.first][v.second] = i; } } } if (d[i_start][j_start] == -1) { cout << "Impossible"; } else { cout << d[i_start][j_start] << '\n'; while (ii(i_start, j_start) != ii(i_end, j_end)) { cout << trace[t[i_start][j_start]] << ' '; ii u = t_ii[i_start][j_start]; i_start = u.first; j_start = u.second; } } } int main() { int n; cin >> n; int i_start; int j_start; int i_end; int j_end; cin >> i_start >> j_start >> i_end >> j_end; printShortestPath(n, i_start, j_start, i_end, j_end); return 0; }