#include using namespace std; int main(){ int tt;scanf("%d",&tt); for (;tt--;){ int n,m,x,y;scanf("%d%d%d%d",&n,&m,&x,&y); int ans=n-1; if (x==y) ans=min(ans, (n-1)/2); else ans=min(ans, (abs(x-y)+n-1-1)/2); ans=min(ans, x-1); ans=min(ans, m-y); ans=max(ans,0); cout<<1ll*ans*ans<