#include using namespace std; void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { int si=i_start,sj=j_start,ei=i_end,ej=j_end; int temp,lon=-1,lat=-1; //up=0,down=1,left=0,right=1 if (si>ei) {temp=si-ei; lon=0;} else {temp=ei-si; lon=1;} temp=temp%2; if (sj>ej) {lat=0;} else lat=1; int rise,run,move=0; int array[100],x=0; //UL=0;UR=1;R=2;LR=3;LL=4,L=5 if (temp==1) {cout << "Impossible";} else { do { if (lon==0&&lat==0) { rise=sj-ej; run=si-ei; if (rise>1&&run>0) {si=si-1; sj=sj-2; array[x]=0; x++; move++;} else if (rise<2&&run>1) {si=si-2; array[x]=5; x++; move++;} } else if (lon==1&&lat==0) { rise=ej-sj; run=si-ei; if (rise>1&&run>0) {si=si+1; sj=sj-2; array[x]=4; x++; move++;} else if (rise<2&&run>1) {si=si-2; array[x]=5; x++; move++;} } else if (lon==0&&lat==1) { rise=ej-sj; run=ei-si; if (rise>1&&run>0) {si=si-1; sj=sj+2; array[x]=1; x++; move++;} else if (rise<2&&run>1) {si=si+2; array[x]=2; x++; move++;} } else if (lon==1&&lat==1) { rise=ej-sj; run=ei-si; if (rise>1&&run>0) {si=si+1; sj=sj+2; array[x]=3; x++; move++;} else if (rise<2&&run>1) {si=si+2; array[x]=2; x++; move++;} } } while (si!=ei&&sj!=ej); int s; cout << move << endl; for (s=0;s> 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; }