#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. int vt = i_start - i_end; int ht = j_start - j_end; if(vt%2 != 0){ cout << "Impossible\n";return; } if((ht + vt/2 )%2 != 0){ cout << "Impossible\n"; return; } while(i_start != i_end || j_start != j_end) { int vt = i_start - i_end; int ht = j_start - j_end; if(vt > 0) { if(ht > 0) { cout << "UL "; i_start = i_start-2; j_start = j_start - 1; continue; } if(ht < 0) { cout << "UR "; i_start = i_start-2; j_start = j_start + 1; continue; } if(ht == 0) { if(j_start > 0) { cout << "UL "; i_start = i_start-2; j_start = j_start - 1; continue; } else { cout << "UR "; i_start = i_start-2; j_start = j_start + 1; continue; } } } else if(vt < 0) { int x = 0-vt; int y = 0 - ht; if(ht > 2) { cout << "LL "; i_start = i_start + 2; j_start = j_start - 1; continue; } else if(ht < -2) { if(y > x/2) { cout << "R "; j_start = j_start + 2; continue; } cout << "LR "; i_start = i_start + 2; j_start = j_start + 1;continue; } else { if(ht == -1) { cout << "LR "; i_start = i_start + 2; j_start = j_start + 1; continue; } if(ht == 1) { cout << "LL "; i_start = i_start + 2; j_start = j_start - 1;continue; } else{ if(j_start != n-1) { cout << "LR "; i_start = i_start+2; j_start = j_start + 1;continue; } cout << "LL "; i_start = i_start+2; j_start = j_start - 1;continue; } } } else { if(ht > 0) { cout << "L "; j_start = j_start - 2; continue; } cout << "R "; j_start = j_start + 2; } } 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; }