#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include using namespace std; template using V=vector; template using VV=V>; int dh[]={1,0,-1,0}; int dw[]={0,1,0,-1}; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int h,w; cin>>h>>w; int si,sj,gi,gj; cin>>si>>sj>>gi>>gj; si--,sj--,gi--,gj--; map,int>,ll> m; V A(h*w); A[si*w+sj]=1; m[{A,si*w+sj}]=1; queue,int>> que; que.push({A,si*w+sj}); while(que.size()){ auto p=que.front(); que.pop(); auto B=p.first; auto i=p.second/w,j=p.second%w; rep(k,4){ int ni=i+dh[k],nj=j+dw[k]; if(ni<0 || nj<0 || ni>=h || nj>=w) continue; int next=ni*w+nj; if(B[next]) continue; if(k==0 && ((nj>0 && B[next-1]) || (ni0 && B[next-w]) || (nj0 && B[next-1]) || (ni>0 && B[next-w]) || (nj0 && B[next-w]) || (nj>0 && B[next-1]) || (ni