#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
struct intmod {
  long long val;
  intmod operator+(const intmod other) const {
    intmod ret;
    ret.val = val + other.val;
    if (ret.val >= MOD) {
      ret.val -= MOD;
    }
    return ret;
  }
  intmod operator-(const intmod other) const {
    intmod ret;
    ret.val = val + MOD - other.val;
    if (ret.val >= MOD) {
      ret.val -= MOD;
    }
    return ret;
  }
  intmod operator*(const intmod other) const {
    intmod ret;
    ret.val = val * other.val % MOD;
    return ret;
  }
} HALF = {(MOD + 1) / 2}, THIRD = {(MOD + 1) / 3};
intmod make_int(long long x) { return {x}; }
struct polinom {
  intmod koef[4];
  intmod ans(intmod x) {
    intmod ret;
    ret = koef[3];
    ret = (ret * x) + koef[2];
    ret = (ret * x) + koef[1];
    ret = (ret * x) + koef[0];
    return ret;
  }
  polinom sum() {
    polinom ret;
    ret.koef[0] = {0};
    ret.koef[1] = koef[0] + ((koef[1] + (koef[2] * THIRD)) * HALF);
    ret.koef[2] = (koef[1] + koef[2]) * HALF;
    ret.koef[3] = koef[2] * THIRD;
    return ret;
  }
  polinom operator+(const polinom other) const {
    polinom ret;
    ret.koef[0] = koef[0] + other.koef[0];
    ret.koef[1] = koef[1] + other.koef[1];
    ret.koef[2] = koef[2] + other.koef[2];
    ret.koef[3] = koef[3] + other.koef[3];
    return ret;
  }
  polinom operator-(const polinom other) const {
    polinom ret;
    ret.koef[0] = koef[0] - other.koef[0];
    ret.koef[1] = koef[1] - other.koef[1];
    ret.koef[2] = koef[2] - other.koef[2];
    ret.koef[3] = koef[3] - other.koef[3];
    return ret;
  }
  polinom operator*(const intmod other) const {
    polinom ret;
    ret.koef[0] = koef[0] * other;
    ret.koef[1] = koef[1] * other;
    ret.koef[2] = koef[2] * other;
    ret.koef[3] = koef[3] * other;
    return ret;
  }
} BASE = {1, 3, 0, 0};
intmod f(long long K) {
  polinom save;
  save = BASE;
  save = save.sum();
  intmod ret;
  ret = save.ans({K / 3});
  if (K % 3 >= 1) {
    ret = ret + make_int(K / 3 + 1);
  }
  if (K % 3 >= 2) {
    ret = ret + make_int(K / 3 + 2);
  }
  return ret;
}
intmod a(long long K) {
  polinom save;
  save = BASE;
  save = save.sum();
  save = save * make_int(3);
  save = save - BASE;
  save = save.sum();
  intmod ret;
  ret = save.ans({K / 3});
  if (K % 3 >= 1) {
    ret = ret + f(K);
  }
  if (K % 3 >= 2) {
    ret = ret + f(K - 1);
  }
  return ret;
}
intmod b(long long K) {
  polinom save;
  save = BASE;
  save = save.sum();
  save = save.sum();
  return save.ans({K});
}
intmod c(long long K) { return a(3 * K / 2) - b(K / 2); }
intmod d(long long K) {
  polinom save;
  save = {0, 5, 2, 0};
  save = save.sum();
  return save.ans({K});
}
intmod e(long long K) {
  polinom save;
  save = {5, 2, 0, 0};
  save = save.sum();
  return save.ans({K});
}
intmod P(long long N, long long M) {
  long long K;
  N = min(N, 2 * M - 1);
  M = min(M, 2 * N - 1);
  K = max(3LL, M / 2);
  if (N <= 3) {
    return {0};
  }
  intmod ret;
  ret = a(N + M - 2) - a(M + K - 2);
  ret = ret + b(K - 1) - b(2);
  ret = ret - c(N - 1) + c(2);
  return ret;
}
intmod Q(long long N, long long M) {
  N = min(N, M / 2) - 2;
  M = M - 5;
  if (N <= 0) {
    return {0};
  }
  intmod ret;
  ret = d(N - 1);
  ret = ret + ((e(M / 2) - e(N - 1)) * make_int(N));
  if (M % 2 >= 1) {
    ret = ret + (make_int(N / 2) * make_int(M + 6));
    if (N % 2 >= 1) {
      ret = ret + make_int(2 * ((M + 1) / 4) + 3);
    }
  }
  return ret;
}
intmod area(long long N, long long M) {
  if (N < 3) {
    return {0};
  }
  intmod ret;
  ret = {0};
  for (long long i = 3; i <= 5; i++) {
    if (i <= M) {
      ret = ret + make_int(7 - i);
    }
  }
  ret = ret + P(N, M);
  ret = ret + Q(N, M);
  ret = ret + Q(M, N);
  return ret;
}
long long Nmin, Mmin;
long long Nmax, Mmax;
intmod ans;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long tc;
  cin >> tc;
  while (tc--) {
    cin >> Nmin >> Mmin;
    cin >> Nmax >> Mmax;
    ans = area(Nmax, Mmax) + area(Nmin - 1, Mmin - 1);
    ans = ans - (area(Nmax, Mmin - 1) + area(Nmin - 1, Mmax));
    cout << ans.val << '\n';
  }
  return 0;
}
