#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 flag2 = 0; int flag1 = 0; int x = 0; int y = 0; if(abs(i_end - i_start)%4 == 0 && abs(j_end - j_start)%2 == 0){ flag2 = 1; } if(abs(i_end - i_start)%2 == 0 && abs(j_end - j_start)%2 == 1){ flag1 = 1; } if(flag1 == flag2 && flag1 == 0){ cout << "Impossible" << endl; return; } if(i_end <= i_start && j_end <= j_start){ y = -(i_end - i_start); x = -(j_end - j_start); if(y == 0 && x == 0){ cout << 0 << endl; } if(y == 2*x){ cout << x << endl; for(int i = 0;i < x;i++){ cout << "UL "; } return; } if(y < 2*x){ int steps = y/2 + (x - y/2)/2; cout << steps << endl; while(y > 0){ y = y - 2; x = x - 1; cout << "UL "; } while(x > 0){ x = x - 2; cout << "L "; } return; } if(y > 2*x){ int steps = y/2; cout << steps << endl; while(x > 0){ y = y - 2; x = x - 1; cout << "UL "; } while(y > 0){ if(y%4 == 0){ cout << "UL "; }else{ cout << "UR "; } y = y - 2; } return; } } if(i_end >= i_start && j_end >= j_start){ y = (i_end - i_start); x = (j_end - j_start); if(x == 0 && y == 0){ cout << 0 << endl; } if(y == 2*x){ cout << x << endl; for(int i = 0;i < x;i++){ cout << "LR "; } return; } if(y < 2*x){ int steps = y/2 + (x - y/2)/2; cout << steps << endl; for(int i = 0;i < (x - y/2)/2;i++){ cout << "R "; } for(int j = 0;j < y/2;j++){ cout << "LR "; } return; } if(y > 2*x){ int steps = y/2; cout << steps << endl; while(x > 0){ y = y - 2; x = x - 1; cout << "LR "; } while(y > 0){ if(y%4 == 0){ cout << "LR "; }else{ cout << "LL "; } y = y - 2; } return; } } if(i_end >= i_start && j_end <= j_start){ y = (i_end - i_start); x = -(j_end - j_start); if(x == 0 && y == 0){ cout << 0 << endl; } if(y == 2*x){ cout << x << endl; for(int i = 0;i < x;i++){ cout << "LL "; } return; } if(y < 2*x){ int steps = y/2 + (x - y/2)/2; cout << steps << endl; for(int j = 0;j < y/2;j++){ cout << "LL "; } for(int i = 0;i < (x - y/2)/2;i++){ cout << "L "; } return; } if(y > 2*x){ int steps = y/2; int y1 = y - 2*x; cout << steps << endl; while(y1 > 0){ if(y1%4 == 0){ cout << "LR "; } if(y1%2 == 0){ cout << "LL "; } y1 = y1 - 2; } while(x > 0){ cout << "LL "; x = x-1; } return; } } if(i_end <= i_start && j_end >= j_start){ y = -(i_end - i_start); x = (j_end - j_start); if(x == 0 && y == 0){ cout << 0 << endl; } if(y == 2*x){ cout << x << endl; for(int i = 0;i < x;i++){ cout << "UR "; } return; } if(y < 2*x){ int steps = y/2 + (x - y/2)/2; cout << steps << endl; for(int j = 0;j < y/2;j++){ cout << "UR "; } for(int i = 0;i < (x - y/2)/2;i++){ cout << "R "; } return; } if(y > 2*x){ int steps = y/2; int y1 = y - 2*x; cout << steps << endl; while(x > 0){ cout << "UR "; x = x-1; } while(y1 > 0){ if(y1%4 == 0){ cout << "UR "; } if(y1%2 == 0){ cout << "UL "; } y1 = y1 - 2; } return; } } } 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; }