#include #include #include #include #include #include using namespace std; long minMoves(vector> &grid, vector> &moveList, int i, int j, int x, int y, int endi, int endj) { queue> q; q.push(pair(i,j)); while(!q.empty()) { pair p = q.front(); q.pop(); int x1 = p.first; int x2 = p.second; if (x2-1 >= 0 && x1-2 >= 0 && grid[x1-2][x2-1] == -1) { grid[x1-2][x2-1] = grid[x1][x2] + 1; moveList[x1-2][x2-1] = moveList[x1][x2] + "UL "; q.push(pair(x1-2, x2-1)); } if (x2+1 < y && x1-2 >= 0 && grid[x1-2][x2+1] == -1) { grid[x1-2][x2+1] = grid[x1][x2] + 1; moveList[x1-2][x2+1] = moveList[x1][x2] + "UR "; q.push(pair(x1-2, x2+1)); } if (x2+2 < y && grid[x1][x2+2] == -1) { grid[x1][x2+2] = grid[x1][x2] + 1; moveList[x1][x2+2] = moveList[x1][x2] + "R "; q.push(pair(x1, x2+2)); } if (x2+1 < y && x1+2 < x && grid[x1+2][x2+1] == -1) { grid[x1+2][x2+1] = grid[x1][x2] + 1; moveList[x1+2][x2+1] = moveList[x1][x2] + "LR "; q.push(pair(x1+2, x2+1)); } if (x2-1 >= 0 && x1+2 < x && grid[x1+2][x2-1] == -1) { grid[x1+2][x2-1] = grid[x1][x2] + 1; moveList[x1+2][x2-1] = moveList[x1][x2] + "LL "; q.push(pair(x1+2, x2-1)); } if (x2-2 >= 0 && grid[x1][x2-2] == -1) { grid[x1][x2-2] = grid[x1][x2] + 1; moveList[x1][x2-2] = moveList[x1][x2] + "L "; q.push(pair(x1, x2-2)); } } return grid[endi][endj]; } int main() { int n; scanf("%d", &n); int starti, startj, endi, endj; scanf("%d %d %d %d", &starti, &startj, &endi, &endj); vector> grid(n, vector(n, -1)); vector> moveList(n, vector(n, "")); grid[starti][startj] = 0; long moves = minMoves(grid, moveList, starti, startj, n,n,endi,endj); // for (int i = 0; i < n; i++) { // // for (int j = 0; j < n; j++) { // cout << grid[i][j] << " "; // } // cout << endl; // // } // // cout << endl; if (moves == -1) { cout << "Impossible" << endl; } else { cout << moves << endl; cout << moveList[endi][endj] << endl; } }