#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //#include //#include //using Modint = atcoder::modint998244353; using namespace std; typedef long long ll; void ex_gcd(ll a, ll b, ll &d, ll &x, ll &y) { if (!b) { d = a; x = 1; y = 0; } else { ex_gcd(b, a % b, d, y, x); y -= a / b * x; } } ll inv(ll a, ll n) { ll d, x, y; ex_gcd(a, n, d, x, y); return d == 1 ? (x % n + n) % (n / d) : -1; } ll gcd(ll x, ll y) { if (y == 0) return x; return gcd(y, x % y); } int gcd(int x, int y) { if (y == 0) return x; return gcd(y, x % y); } inline bool scan_d(int &ret) { char c; int sgn; if(c=getchar(),c==EOF) return 0; //EOF while(c!='-'&&(c<'0'||c>'9')) c=getchar(); sgn=(c=='-')?-1:1; ret=(c=='-')?0:(c-'0'); while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0'); ret*=sgn; return 1; } const int maxn = 10; const int mod = 1000000007; bool check(int n, int m, int x1, int x2, int ti){ if(x1-1<=ti||m-x2<=ti||(n-1+m-x1)<=ti||(n-1+x2-1)<=ti)return true; if(n-1 + abs(x1-x2)<=ti + ti)return true; if(x2>T; while(T--){ int n,m,x1,x2; scan_d(n); scan_d(m); scan_d(x1); scan_d(x2); int l = 0, r = min(n-1, m-1), ret = r; while(l<=r){ int mid = (l+r)>>1; if(check(n,m,x1,x2,mid)){ ret = mid; r = mid - 1; } else l = mid + 1; } printf("%I64d\n", ret * (ll)ret); } return 0; }