#include using namespace std; int x[] = {-2, -2, 0, 2, 2, 0}; int y[] = {-1, 1, 2, 1, -1, -2}; string s[] = {"UL", "UR", "R", "LR", "LL", "L"}; bool validmove(int n, int x, int y, vector> &a) { if (x >= 0 && x < n && y >= 0 && y < n && !a[x][y]) { return true; } return false; } struct cell { int x; int y; std::vector path; cell() {} cell (int x, int y, vector &p):x(x), y(y), path(p) {} }; 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> a(n, vector(n, 0)); std::vector res; std::queue q; vector path; q.push(cell(i_start, j_start, path)); while (!q.empty()) { cell t = q.front(); q.pop(); a[t.x][t.y] = true; if (t.x == i_end && t.y == j_end) { std::cout << t.path.size() << std::endl; for (auto p : t.path) { std::cout << p << " "; } return; } for (int i = 0; i < 6; i++) { int xm = t.x + x[i]; int ym = t.y + y[i]; if (validmove(n, xm, ym, a)) { vector newpath(t.path); newpath.push_back(s[i]); q.push(cell(xm, ym, newpath)); } } } std::cout << "Impossible"; } 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; }