#include using namespace std; 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. vector row(n); vector> grid(n, row); grid[i_start][j_start] = ""; queue> q; q.emplace(i_start, j_start); pair found(-1, -1); while(!q.empty()) { // UL, UR, R, LR, LL, L auto p = q.front(); q.pop(); if (p.first == i_end && p.second == j_end) { found = p; break; } int i = p.first - 2; int j = p.second - 1; if (i >= 0 && j >= 0 && grid[i][j].empty()) { grid[i][j] = grid[p.first][p.second]; grid[i][j].append(1, '1'); q.emplace(i, j); } // UR i = p.first - 2; j = p.second + 1; if (i >= 0 && j < n && grid[i][j].empty()) { grid[i][j] = grid[p.first][p.second]; grid[i][j].append(1, '2'); q.emplace(i, j); } // R i = p.first; j = p.second + 2; if (j < n && grid[i][j].empty()) { grid[i][j] = grid[p.first][p.second]; grid[i][j].append(1, '3'); q.emplace(i, j); } // LR i = p.first + 2; j = p.second + 1; if (i < n && j < n && grid[i][j].empty()) { grid[i][j] = grid[p.first][p.second]; grid[i][j].append(1, '4'); q.emplace(i, j); } // LL i = p.first + 2; j = p.second - 1; if (i < n && j >= 0 && grid[i][j].empty()) { grid[i][j] = grid[p.first][p.second]; grid[i][j].append(1, '5'); q.emplace(i, j); } // L i = p.first; j = p.second - 2; if (j >= 0 && grid[i][j].empty()) { grid[i][j] = grid[p.first][p.second]; grid[i][j].append(1, '6'); q.emplace(i, j); } } if (found.first < 0) { cout << "Impossible\n"; } else { cout << grid[found.first][found.second].size() << '\n'; for(char c : grid[found.first][found.second]) { string str; switch (c) { case '1': str = "UL"; break; case '2': str = "UR"; break; case '3': str = "R"; break; case '4': str = "LR"; break; case '5': str = "LL"; break; case '6': str = "L"; break; } cout << str << " "; } } } 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; }