#include using namespace std; void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { int visit[n][n]; string move[n][n]; memset(visit, -1, sizeof visit); int dx[] = {-2, -2, 0, 2, 2, 0}; int dy[] = {-1, 1, 2, 1, -1, -2}; string s[] = {"UL", "UR", "R", "LR", "LL", "L"}; visit[i_start][j_start] = 0; queue< pair > q; q.push(make_pair(i_start, j_start)); while (!q.empty()) { int x = q.front().first; int y = q.front().second; q.pop(); for (int i = 0; i < 6; i++) { int nx = x + dx[i]; int ny = y + dy[i]; if (nx < 0 || ny < 0 || nx >= n || ny >= n) continue; if (visit[nx][ny] != -1) continue; visit[nx][ny] = visit[x][y] + 1; move[nx][ny] = s[i]; q.push(make_pair(nx, ny)); } if (visit[i_end][j_end] != -1) break; } if (visit[i_end][j_end] == -1) cout << "Impossible" << endl; else { cout << visit[i_end][j_end] << endl; vector ans; while (i_end != i_start || j_end != j_start) { ans.push_back(move[i_end][j_end]); for (int i = 0; i < 6; i++) { if (move[i_end][j_end] == s[i]) { i_end -= dx[i]; j_end -= dy[i]; break; } } } reverse(ans.begin(), ans.end()); for (string ss:ans) { cout << ss << ' '; } 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; }