#include #include #include #include #include #include #include void printShortestPath(int n, int is, int js, int ie, int je) { int count=0; char ans[10000009]; int x=0; if((is%2==ie%2) && ((is%4==ie%4 && js%2==je%2) || (is%4!=ie%4 && js%2!=je%2))) { while(je!=js || ie!=is) { //UL, UR, R, LR, LL, L if(je>=js+1 && ie<=is-2) { ans[x]='U'; ans[x+1]='R'; ans[x+2]=' '; x+=3; //printf("UR "); js+=1; is-=2; } else if(ie<=is-2) { ans[x]='U'; ans[x+1]='L'; ans[x+2]=' '; x+=3; //printf("UL "); js-=1; is-=2; } else if(ie==is && je>=js+2) { ans[x]='R'; ans[x+1]=' '; x+=2; //printf("R "); js+=2; } else if(ie>=is+2 && je<=js-1) { ans[x]='L'; ans[x+1]='L'; ans[x+2]=' '; x+=3; //printf("LL "); js-=1; is+=2; } else if(ie>=is+2) { ans[x]='L'; ans[x+1]='R'; ans[x+2]=' '; x+=3; //printf("LR "); js+=1; is+=2; } else if(ie==is && je<=js-2) { ans[x]='L'; ans[x+1]=' '; x+=2; //printf("L "); js-=2; } count++; /* else { printf("______\n%d %d %d %d\n_______",is,js,ie,je); is=ie; js=je; } */ } ans[x-1]='\0'; printf("%d\n%s",count,ans); } else { printf("Impossible"); } return; // Print the distance along with the sequence of moves. } int main() { int n; scanf("%i", &n); int i_start; int j_start; int i_end; int j_end; scanf("%i %i %i %i", &i_start, &j_start, &i_end, &j_end); printShortestPath(n, i_start, j_start, i_end, j_end); return 0; }