#include using namespace std; typedef long long ll; int tes; ll n,m,x1,x2,ans; void solve(){ scanf("%lld%lld%lld%lld",&n,&m,&x1,&x2); ans=min(x1-1,m-x2); if(x1!=x2)ans=min(ans,(abs(x1-x2)+n-1-1)/2); else ans=min(ans,(n-1)/2); ans=min(ans,n-1); printf("%lld\n",ans*ans); } int main() { scanf("%d",&tes); while(tes--)solve(); return 0; }