#include using namespace std; const int N = 228; int dist[N][N]; int p[N][N]; int px[N][N]; int py[N][N]; string names[6] = {"L", "LL", "LR", "R", "UR", "UL"}; int dx[6] = {0, 2, 2, 0, -2, -2}; int dy[6] = {-2, -1, 1, 2, 1, -1}; void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { memset(dist, 255, sizeof(dist)); vector > q; int qi = 0; q.push_back(make_pair(i_start, j_start)); dist[i_start][j_start] = 0; p[i_start][j_start] = -1; while(qi < q.size()) { int cx = q[qi].first; int cy = q[qi].second; qi++; int cd = dist[cx][cy]; for (int dir = 5; dir >= 0; dir--) { int nextx = cx + dx[dir]; int nexty = cy + dy[dir]; if (nextx >= 0 && nextx < n && nexty >= 0 && nexty < n) { if (dist[nextx][nexty] == -1) { q.push_back(make_pair(nextx, nexty)); dist[nextx][nexty] = cd+1; p[nextx][nexty] = dir; px[nextx][nexty] = cx; py[nextx][nexty] = cy; } } } } if (dist[i_end][j_end] == -1) { cout << "Impossible" << endl; } else { cout << dist[i_end][j_end] << endl; vector res; int cx = i_end; int cy = j_end; while (true) { int t = p[cx][cy]; // cout << cx << " " << cy << " " << dist[cx][cy] << endl; if (t == -1) { break; } res.push_back(t); int tx = px[cx][cy]; int ty = py[cx][cy]; cx = tx; cy = ty; } for (int i = res.size() - 1; i >= 0; i--) { cout << names[res[i]] << " "; } cout << endl; } } 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; }