#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const ll inf = (1ll << 63) - 1;

array<ll, 3> egcd(ll a, ll b) {
    ll s0 = 1, t0 = 0, s1 = 0, t1 = 1;
    while (b) {
        ll d = a / b;
        tie(a, b) = make_pair(b, a % b);
        tie(s0, s1) = make_pair(s1, s0 - d * s1);
        tie(t0, t1) = make_pair(t1, t0 - d * t1);
    }
    return {a, s0, t0};
}

pair<ll, ll> crt(const vector<ll> &r, const vector<ll> &m) {
    ll r0 = 0, m0 = 1;
    for (int i = 0; i < int(r.size()); i++) {
        ll r1 = r[i] % m[i], m1 = m[i];
        auto [g, x, y] = egcd(m0, m1);
        if ((r1 - r0) % g) return {0, 0};

        r0 = (r0 + m0 * ((x * (r1 - r0) / g) % (m1 / g))) % (m0 * m1 / g);
        m0 *= m1 / g;
        if (r0 < 0) r0 += m0;
    }

    return {r0, m0};
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        ll x, y, p, q;
        cin >> x >> y >> p >> q;

        ll ans = inf;
        for (ll i = x; i < x + y; i++) {
            for (ll j = p; j < p + q; j++) {
                auto [r, n] = crt({i, j}, {2 * (x + y), p + q});
                if (n) ans = min(r, ans);
            }
        }

        if (ans == inf) cout << "infinity";
        else cout << ans;
        cout << '\n';
    }
}

#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

constexpr int MOD = 1'000'000'007;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    LL n,a,b;
    cin >> n >> a >> b;
    if (a + b > n) {
        cout << 0 << endl;
        return;
    }
    LL ap = n - a + 1, bp = n - b + 1, cp = n - a - b + 1;
    LL x4 = (cp * (cp + 1) / 2) % MOD;
    LL x3 = (x4 * 2) % MOD;
    LL x2 = (ap * bp - x3) % MOD;
    LL x1 = sqr(x2) % MOD;
    LL ans = ((sqr(ap)%MOD) * (sqr(bp)%MOD) - x1) % MOD;
    if (ans < 0) ans += MOD;
    cout << ans << endl;
}

signed main() {
    int t;
    cin >> t;
    REP(i,0,t) solve();
    
    return 0;
}