#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int MAXN = 2111111;

const int MOD = 1000000007;
typedef long long LL;

LL mul(LL a, LL b, LL c) { // a*b % c
  LL ret = 0, tmp = a % c;
  for (; b; b >>= 1) {
    if (b & 1)
      if ((ret += tmp) >= c)
        ret -= c;
    if ((tmp <<= 1) >= c)
      tmp -= c;
  }
  return ret;
}
LL power(LL a, LL b, LL c) { // a^b % c
  LL res = 1;
  for (; b; b >>= 1) {
    if (b & 1) res = mul(res, a, c);
    a = mul(a, a, c);
  }
  return res;
}
LL exgcd(LL a, LL b, LL &x, LL &y) { //????????:?ax+by==1
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  LL d = exgcd(b, a % b, y, x);
  y -= a / b * x;
  return d;
}
LL mod(LL x, LL n) {
  return (x % n + n) % n;
}
LL inv(LL a, LL n) {
  LL x, y;
  return exgcd(a, n, x, y) == 1 ? mod(x, n) : -1;
}

LL fact[MAXN], invs[MAXN];

int C(int n, int m) {
  if (m > n || m < 0) return 0;
  return (LL)fact[n] * inv(fact[m], MOD) % MOD * inv(fact[n - m], MOD) % MOD;
}

int main() {
  fact[0] = 1;
  for (int i = 1; i < MAXN; ++i) {
    fact[i] = (long long)fact[i - 1] * i % MOD;
  }
  invs[1] = 1;
  for (int i = 2; i < MAXN; ++i) {
    invs[i] = (long long)invs[MOD % i] * (MOD - MOD / i) % MOD;
  }
  int n, m, cases;
  scanf("%d", &cases);
  while (cases--) {
    int r1, r2, c1, c2;
    scanf("%d %d", &n, &m);
    scanf("%d %d %d %d", &r1, &c1, &r2, &c2);
    LL ans = 0;
    int c = c2 + 1;
    for (int r = r1 - 1; r >= 1; --r) {
      ans = (ans + (LL)C(r - 1 + c - 1, r - 1) * C(m - c + n - r, n - r) % MOD) % MOD;
      c++;
    }
    c = c1 - 1;
    for (int r = r2 + 1; r <= n; ++r) {
      ans = (ans + (LL)C(r - 1 + c - 1, r - 1) * C(m - c + n - r, n - r) % MOD) % MOD;
      c--;
    }
    cout << ans << endl;
  }
}