#include using namespace std; void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { int p=0; vector vec; int i=i_start,j=j_start; while((i!=i_end || j!=j_end)){ if(i_end-i<0 && j_end-j<0 && (i-2>=0 || j-1>=0)){ i=i-2; j=j-1; p++; vec.push_back("UL"); continue; } else if(i_end-i<0 && j_end-j==0){ if((i-2)>=0 && j>=1){ i=i-2; j=j-1; p++; vec.push_back("UL"); continue; } if((i-2)>=0 && j<=n-1){ i=i-2; j=j+1; p++; vec.push_back("UR"); continue; } else{ vec.clear(); vec.push_back("Impossible"); break; } } else if(i_end-i<0 && j_end-j>0 &&(i>=2 || j<=n-1)){ i=i-2; j=j+1; p++; vec.push_back("UR"); continue; } else if(i_end-i>0 && j_end-j<0 &&(i<=n-2 || j-1>=0)){ i=i+2; j=j-1; p++; vec.push_back("LL"); continue; } else if(i_end-i>0 && j_end-j==0){ if((i+2)<=n && j<=n-1){ i=i+2; j=j+1; p++; vec.push_back("LR"); continue; } if((i+2)<=n && j>=1){ i=i+2; j=j-1; p++; vec.push_back("LL"); continue; } else{ vec.clear(); vec.push_back("Impossible"); break; } } else if(i_end-i>0 && j_end-j>0 &&(i<=n-2 || j<=n-1)){ i=i+2; j=j+1; p++; vec.push_back("LR"); continue; } else if(i_end-i==0 && j_end-j<0 && j>=2){ j=j-2; p++; vec.push_back("L"); continue; } else if(i_end-i==0 && j_end-j==0){ continue; } else if(i_end-i==0 && j_end-j>0 && j<=n-2){ j=j+2; p++; vec.push_back("R"); continue; } else{ vec.clear(); vec.push_back("Impossible"); } } if(vec[0]=="Impossible"){ cout<<"Impossible"<> 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; }