/*** Author: ShivamRathore (Shivam010) Problem: Red Knight's Shortest Path ***/ #include //#include using namespace std; #define ll long long #define mk make_pair #define pb push_back #define Pi pair #define Pl pair #define vi vector #define vl vector #define vb vector #define vp vector > #define vpl vector > #define F first #define S second const ll mod=1000000007; ll ab(ll c){ if(c<0) return -c; return c; } ll pow(ll a,ll b){ ll p=a%mod,ans=1; while(b){ if(b&1) ans=(ans*p)%mod; p=(p*p)%mod; b>>=1; } return ans; } ll gcd(ll a,ll b){ if(b==0) return a; return gcd(b,a%b); } int a[201][201]; int n,ix,iy,fx,fy; int cnt=0; int P[201][201]; void fun(int p,int q){ cnt++; int v=a[p][q]+1; if(q+23)){ a[p][q+2]=v; P[p][q+2]=3; fun(p,q+2); } } if(q-2>=0){ if(v6)){ a[p][q-2]=v; P[p][q-2]=6; fun(p,q-2); } } if(p+24)){ a[p+2][q+1]=v; P[p+2][q+1]=4; fun(p+2,q+1); } } if(q-1>=0){ if(v5)){ a[p+2][q-1]=v; P[p+2][q-1]=5; fun(p+2,q-1); } } } if(p-2>=0){ if(q+12)){ a[p-2][q+1]=v; P[p-2][q+1]=2; fun(p-2,q+1); } } if(q-1>=0){ if(v1)){ a[p-2][q-1]=v; P[p-2][q-1]=1; fun(p-2,q-1); } } } } int main() { cin>>n; for(int i=0;i>ix>>iy>>fx>>fy; a[ix][iy]=0; P[ix][iy]=0; fun(ix,iy); for(int i=0;i