#include using namespace std; int selectMove(int i1 , int j1 , int i2 , int j2) { if(i1 == i2 && j1 == j2) return 6; if(j1 == j2){ if(i1 < i2) return 2; else return 5; } if(i1 == i2){ if(j1 < j2) return 3; else return 0; } if(i1 < i2 && j1 < j2) return 2; if(i1 < i2 && j1 > j2) return 1; if(i1 > i2 && j1 < j2) return 4; if(i1 > i2 && j1 > j2) return 0; return 6; } bool isPossible(int i1 , int i2 , int j1 , int j2) { if((i2-i1)%2 == 1){ if((j2-j1-2)%4 != 0) return false; } if((i2-i1)%2 == 0){ if((j2-j1)%4 != 0) return false; } return true; } void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { if(isPossible(i_start , i_end , j_start , j_end) == false){ cout<<"Impossible"; return ; } int temp[1000] , count = 0; while( i_start!=i_end || j_start!=j_end){ temp[count] = selectMove(i_start , j_start , i_end , j_end); if(temp[count] == 0){ i_start--; j_start -= 2; } if(temp[count] == 1){ i_start++; j_start -= 2; } if(temp[count] == 2) i_start += 2; if(temp[count] == 3){ i_start++; j_start += 2; } if(temp[count] == 4){ i_start--; j_start += 2; } if(temp[count] == 5) i_start -= 2; count++; // cout<<"*** ("<> n; int i_start; int j_start; int i_end; int j_end; cin >> i_start >> j_start >> i_end >> j_end; printShortestPath(n, j_start, i_start, j_end, i_end); return 0; }