#include using namespace std; const int MaxN = (int)2e3 + 10; const int INF = (int)1e9; const int MOD = 998244353; void solve() { int n, m, x, y; scanf("%d%d%d%d", &n, &m, &x, &y); int total = (n * m - 1) * (n * m - 2); total -= (n - 1) * m * (m - 1); total -= (m - 1) * n * (n - 1); total -= (x - 1) * (x - 2); total -= (y - 1) * (y - 2); total -= (n - x) * (n - x - 1); total -= (m - y) * (m - y - 1); map mx, mn; for (int i = 1; i <= n + m - 1; ++i) { mx[i] = 0; mn[i] = INF; } for (int i = 1; i <= n; ++i) { mx[i + 1] = max(mx[i + 1], i); mn[i + 1] = min(mn[i + 1], i); mx[i + m] = max(mx[i + m], i); mn[i + m] = min(mn[i + m], i); } for (int j = 1; j <= m; ++j) { mx[1 + j] = max(mx[1 + j], 1); mn[1 + j] = min(mn[1 + j], 1); mx[n + j] = max(mx[n + j], n); mn[n + j] = min(mn[n + j], n); } for (int d = 1; d <= n + m - 1; ++d) { int a = mn[d], b = mx[d]; if (a == 0 || b == 0) continue; if (d != x + y) { total -= (b - a + 1) * (b - a); } else { total -= (b - x) * (b - x - 1); total -= (x - a) * (x - a - 1); } } for (int i = 1 - m; i <= n - 1; ++i) { mx[i] = 0; mn[i] = INF; } for (int i = 1; i <= n; ++i) { mx[i - 1] = max(mx[i - 1], i); mn[i - 1] = min(mn[i - 1], i); mx[i - m] = max(mx[i - m], i); mn[i - m] = min(mn[i - m], i); } for (int j = 1; j <= m; ++j) { mx[1 - j] = max(mx[1 - j], 1); mn[1 - j] = min(mn[1 - j], 1); mx[n - j] = max(mx[n - j], n); mn[n - j] = min(mn[n - j], n); } for (int d = 1 - m; d <= n - 1; ++d) { int a = mn[d], b = mx[d]; if (a == 0 || b == 0) continue; if (d != x - y) { total -= (b - a + 1) * (b - a); } else { total -= (b - x) * (b - x - 1); total -= (x - a) * (x - a - 1); } } cout << total << "\n"; } int main() { // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); int t; scanf("%d", &t); while (t --> 0) { solve(); } return 0; }