#include using namespace std; using ll=long long; using ld=long double; using vi=vector; using vl=vector; using pii=pair; using pll=pair; templateusing pqg=priority_queue,greater>; #define all(x) begin(x),end(x) #define rall(x) rbegin(x),rend(x) #define sz(x) (int)x.size() #define rep(i,a,b) for(int i=a;i=b;i--) const ll INF=4e18; const int MOD=1e9+7; const int MOD2=998244353; ll sign(ll x) { return (x > 0) - (x < 0); } void solve(){ ll H, W, h, w, x, y; cin >> H >> W >> h >> w >> x >> y; ll n = H * W - 1; ll c1 = 0; int dx[] = {0, 0, 1, -1, 1, 1, -1, -1}; int dy[] = {1, -1, 0, 0, 1, -1, 1, -1}; rep(i, 0, 8) { ll L = INF; if (dx[i] == 1) L = min(L, H - h); if (dx[i] == -1) L = min(L, h - 1); if (dy[i] == 1) L = min(L, W - w); if (dy[i] == -1) L = min(L, w - 1); bool f = 0; ll d_w = 0; if (dx[i] == 0) { if (x == h && sign(y - w) == dy[i]) { f = 1; d_w = abs(y - w); } } else if (dy[i] == 0) { if (y == w && sign(x - h) == dx[i]) { f = 1; d_w = abs(x - h); } } else { if (abs(x - h) == abs(y - w) && sign(x - h) == dx[i] && sign(y - w) == dy[i]) { f = 1; d_w = abs(x - h); } } if (f) c1 += d_w - 1; else c1 += L; } ll c3 = 0; auto get_c3 = [&](ll l, ll r, ll M) { if (l > r) return 0LL; ll res = 0; ll l2 = max(l, M + 1), r2 = min(r, 2 * M); if (l2 <= r2) res += (r2 + 1) / 2 - l2 / 2; ll l3 = max(l, 2 * M + 1); if (l3 <= r) res += r - l3 + 1; return res; }; if (x == h && y > w) c3 = get_c3(y - w + 1, W - w, max(H - h, h - 1)); else if (x == h && y < w) c3 = get_c3(w - y + 1, w - 1, max(H - h, h - 1)); else if (y == w && x > h) c3 = get_c3(x - h + 1, H - h, max(W - w, w - 1)); else if (y == w && x < h) c3 = get_c3(h - x + 1, h - 1, max(W - w, w - 1)); cout << 2 * n - 2 - c1 + c3 << "\n"; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int t; if(cin >> t) while(t--) solve(); }