#include using namespace std; void printShortestPath(int n, int j_start, int i_start, int j_end, int i_end) { // Print the distance along with the sequence of moves. int v_moves = abs((j_start - j_end) / 2); int h_moves = abs((i_start - i_end) / 2), h_start; bool impossible = false; if((j_start - j_end) % 2 == 1){ impossible = true; } if(!impossible && ((v_moves % 2 ) != (abs(i_start - i_end) % 2))){ impossible = true; } int num_moves[6]; memset(num_moves, 0, sizeof(num_moves)); string moves[] ={"UL ", "UR ", "R ", "LR ", "LL ", "L "}; if(impossible){ cout << "Impossible" << endl; } else{ int total_moves = v_moves; h_start = i_start; if(j_start > j_end){ while(v_moves --){ if(h_start >= i_end){ num_moves[0] ++; h_start --; } else{ num_moves[1]++; h_start ++; } } } else if(j_start < j_end){ while(v_moves --){ if(h_start >= i_end){ num_moves[4] ++; h_start --; } else{ num_moves[3] ++; h_start ++; } } } h_moves = abs(h_start - i_end) / 2; total_moves += h_moves; if(h_start > i_end){ num_moves[5] = h_moves; } else{ num_moves[2] = h_moves; } cout << total_moves << endl; for(int index = 0; index < 6; index ++){ while(num_moves[index] --){ cout << moves[index]; } } 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; }