#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int,int> pii; double PI = acos(-1); double EPS = 1e-7; int INF = 1000000000; LL INFLL = 1000000000000000000LL; #define fi first #define se second #define mp make_pair #define pb push_back #define input(in) freopen(in,"r",stdin) #define output(out) freopen(out,"w",stdout) #define MIN(a, b) (a) = min((a), (b)) #define MAX(a, b) (a) = max((a), (b)) #define RESET(a, b) memset(a,b,sizeof(a)) #define ALL(a) (a).begin(), (a).end() #define SIZE(a) (int)a.size() #define SORT(a) sort(ALL(a)) #define UNIQUE(a) (a).erase( unique( ALL(a) ), (a).end() ) #define FOR(a, b, c) for (int (a)=(b); (a)<=(c); (a)++) #define FORD(a, b, c) for (int (a)=(b); (a)>=(c); (a)--) #define FORIT(a, b) for (__typeof((b).begin()) a=(b).begin(); a!=(b).end(); a++) int mx[8] = {-1,1,0,0,-1,-1,1,1}; int my[8] = {0,0,-1,1,-1,1,-1,1}; // ----- // LL inv[2000005]; LL fac[2000005]; LL mod = 1000000007; inline long long ipow(long long base, int exp) { long long result = 1; while (exp) { if (exp & 1) result *= base; exp >>= 1; base *= base; result %= mod; base %= mod; } return result; } long long ways(int r1,int c1,int r2,int c2) { int r = r2-r1; int c = c2-c1; if (r < 0 || c < 0) return 0; return (((fac[r+c]*inv[r])%mod)*inv[c])%mod; } int main() { inv[0] = 1; fac[0] = 1; inv[1] = 1; fac[1] = 1; FOR(a,2,2000005) { if (a <= 1000000) inv[a] = (inv[a-1]*ipow(a,mod-2))%mod; fac[a] = (fac[a-1]*(LL)a)%mod; } int t; scanf("%d",&t); while(t--) { int r,c; scanf("%d%d",&r,&c); int r1,c1; scanf("%d%d",&r1,&c1); int r2,c2; scanf("%d%d",&r2,&c2); long long ans = ways(1,1,r,c); ans += mod-(ways(1,1,r1,c1)*ways(r1,c1,r,c))%mod; ans %= mod; FOR(a,r1+1,r2) { ans += mod-(ways(1,1,a,c1-1)*ways(a,c1,r,c))%mod; ans %= mod; } FOR(a,c1+1,c2) { ans += mod-(ways(1,1,r1-1,a)*ways(r1,a,r,c))%mod; ans %= mod; } cout << ans << endl; } }