#include #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 dx, dy; dx = j_end - j_start; dy = i_end - i_start; if((dy%2 != 0)||(dy%4==0 && dx%2!=0)||(dy%2==0 && dy%4!=0 && dx%2==0)) { cout << "Impossible"; return; } int cnt = 0; multiset ans; string res; while(dx != 0 || dy !=0) //UL, UR, R, LR, LL, L { cnt++; if(dy > 0) // move down { if(dx > 0) //move LR { //res += "LR "; ans.insert(4); dx -=1; dy -=2; } else //move LL { //res += "LL "; ans.insert(5); dx +=1; dy -=2; } } else if(dy < 0) //move up { if(dx > 0) //move UR { //res += "UR "; ans.insert(2); dx -=1; dy +=2; } else //move UL { //res += "UL "; ans.insert(1); dx +=1; dy +=2; } } else //dy == 0 { if(dx > 0) //move ight { //res += "R "; ans.insert(3); dx -=2; } else //move left { //res += "L "; ans.insert(6); dx +=2; } } } cout << cnt << endl; for(auto a:ans) { switch(a) { case 1: cout << "UL "; break; case 2: cout << "UR "; break; case 3: cout << "R "; break; case 4: cout << "LR "; break; case 5: cout << "LL "; break; case 6: cout << "L "; break; } } } 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; }