#include<bits/stdc++.h>
using namespace std;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)
#define TR(v,it) for( LET(it,v.begin()) ; it != v.end() ; it++)
#define rTR(v,it) for( LET(it,v.rbegin()) ; it != v.rend() ; it++)
#define repi(i,n) for(int i=0; i<(int)n;i++)
#define si(n) scanf("%d",&n)
#define sll(n) scanf("%lld",&n)
#define DRT()  int t; cin>>t; while(t--)
#define TRACE

//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);


#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector< PII > VPII;

#define mod 1000000007
LL F[2000001];
LL iF[2000001];
LL inv[2000001];
LL power(LL a, int p)
{
    LL ret = 1;
    while(p)
    {
        if(p&1)
            ret = (ret*a) % mod;
        p/=2;
        a = (a*a) % mod;
    }
    return ret;
}

LL f(int n, int m)
{
    if(min(n,m)<2)return min(n,m);
    LL num = n+m-2;
    LL den = n-1;
    LL den2 = num-den;
    num = F[num];
    den = iF[den];
    den = (den * iF[den2])%mod;
    return (num*den)%mod;
}

int main()
{
    F[0] =1;
    iF[0] = 1;
    for(int i=1; i<=2000000; i++)
    {
        F[i] = (i*F[i-1])%mod;
        inv[i] = power(i,mod-2);
        iF[i] = (iF[i-1]*inv[i])%mod;
    }
    int t; si(t); while(t--)
    {
        int R,C;
        si(R); si(C);
        int x1,y1,x2,y2;
        si(x1); si(y1);
        si(x2); si(y2);
        LL ans =0;
        for(int i=1; i<x1; i++)
            ans = (ans + f(i,y2)*f(R-i+1,C-y2)) % mod;
        for(int i=x2+1; i<=R; i++)
            ans = (ans + f(i,y1-1)*f(R-i+1,C-y1+1)) % mod;
        cout<<ans<<endl;
    }
    return 0;
}