#include #define debug(x) cerr<<"\tDEBUG: "<<#x<<" = "<<(x)<>QuQ; while(QuQ--){ int n,m,x1,x2; scanf("%d%d%d%d",&n,&m,&x1,&x2); if(n==1||m==1){ puts("0"); continue; } int ans=min(x1-1,m-x2); ans=min(ans,n-1); int tmp1=n-1; int tmp2=abs(x1-x2); if(tmp1>tmp2)swap(tmp1,tmp2); if(tmp1!=0){ if(tmp1%2==tmp2%2){ tmp2--; } ans=min(ans,(tmp1+tmp2)/2); }else { ans=min(ans,tmp2/2); } cout<<1LL*ans*ans<