#include<bits/stdc++.h> usingnamespacestd; constint N = 300000 + 10; longlong s1[N], s2[N], tot, ans; int l[4], r[4]; voidsolve(int x){ int id[3], c = 0; for (int i = 0; i <= r[x]; i++) s1[i] = s2[i] = 0; for (int i = 0; i < 4; i++) { if (i == x) continue; id[c++] = i; } for (int i = l[id[0]]; i <= r[id[0]]; i++) { s1[l[id[1]] + i]++; s1[r[id[1]] + i + 1]--; } for (int i = 1; i <= r[x]; i++) s1[i] += s1[i - 1]; for (int i = 1; i <= r[x]; i++) { s2[l[id[2]] + i] += s1[i]; s2[r[id[2]] + i + 1] -= s1[i]; } for (int i = 1; i <= r[x]; i++) s2[i] += s2[i - 1]; for (int i = 1; i <= r[x]; i++) s2[i] += s2[i - 1]; for (int i = l[x]; i <= r[x]; i++) ans += s2[i]; } int T; intmain(){ scanf("%d", &T); while (T--) { tot = 1; ans = 0; for (int i = 0; i < 4; i++) { scanf("%d%d", &l[i], &r[i]); tot = tot * (r[i] - l[i] + 1); } for (int i = 0; i < 4; i++) solve(i); printf("%lld\n", tot - ans); } return0; }