#include #include #include #include #include #include #include void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { char c[5000][5]; int i = 0, j; while ((i_start != i_end)&&(j_start != j_end)){ if(i_start > i_end){ if(j_start > j_end){ i_start = i_start - 2; j_start = j_start - 1; strcat(c[++i],"UL"); } else{ i_start = i_start - 2; j_start = j_start + 1; strcat(c[++i],"UR"); } } else{ if(j_start < j_end){ i_start = i_start + 2; j_start = j_start + 1; strcat(c[++i],"LR"); } else{ i_start = i_start + 2; j_start = j_start - 1; strcat(c[++i],"LL"); } } } if(i_start == i_end){ if((abs(j_start-j_end)%2)==0){ if(j_start < j_end){ while(j_start != j_end){ j_start = j_start + 2; strcat(c[++i],"R"); } } else{ while(j_start != j_end){ j_start = j_start -2; strcat(c[++i],"L"); } } } } if(j_start == j_end){ if((abs(i_start-i_end)%4)==0){ if(i_start < i_end){ while(i_start != i_end){ i_start += 4; strcat(c[++i],"LR"); strcat(c[++i],"LL"); } } else{ while(i_start != i_end){ i_start -= 4; strcat(c[++i],"UL"); strcat(c[++i],"UR"); } } } } if((i_start == i_end)&&(j_start == j_end)){ printf("%d\n",i); for(j= 1; j <= i; j++) printf("%s ",c[j]); } else printf("Impossible"); } 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; }