#include <bits/stdc++.h>

using namespace std;

#define flush cout.flush

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pl = pair<ll, ll>;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;
const ll mod2 = 998244353;
const ld eps = 1e-9;
const ld PI = acos(-1);

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    ll X;
    cin >> X;
    vector<ll> a(n);
    for (ll &i : a) cin >> i;
    ll res = INF * INF;
    for (ll k = 1; k <= n; ++k) {
        vector<vector<ll>> dp(k + 1, vector<ll>(k + 1, -1));
        dp[0][0] = 0;
        for (auto x : a) {
            vector<vector<ll>> new_dp(k + 1, vector<ll>(k + 1, -1));
            new_dp[0][0] = 0;
            for (ll i = 1; i <= k; ++i) {
                for (ll j = 0; j < k; ++j) {
                    ll back = ((j - x) % k + k) % k;
                    new_dp[i][j] = dp[i][j];
                    if (dp[i - 1][back] == -1)continue;
                    new_dp[i][j] = max(new_dp[i][j], dp[i - 1][back] + x);
                }
            }
            dp = new_dp;
        }
        if (dp[k][X % k] == -1)continue;
        res = min(res, (X - dp[k][X % k]) / k);
    }
    cout << res << "\n";
    return 0;
}
#include <bits/stdc++.h>

using namespace std;



struct math {
  __int128 Tgcd(__int128 a, __int128 b) {
    if (b == 0) {
      return a;
    } else {
      return Tgcd(b, a % b);
    }
  }
  __int128 d = 0;
  pair<__int128, __int128> gcd(__int128 a, __int128 b) {
    if (b == 0) {
      d = a;
      return {1, 0};
    } else {
      pair<__int128, __int128> it = gcd(b, a % b);
      return {it.second, it.first - a / b * it.second};
    }
  }
  pair<__int128, __int128> coef(__int128 a, __int128 b, __int128 c) {
    auto it = gcd(a, b);
    if (c % d) return {0, 0};
    it.first *= (c / d);
    it.second *= (c / d);
    return it;
  }
  __int128 crt(__int128 m1, __int128 m2, __int128 r1, __int128 r2) {
    pair<__int128, __int128> it = coef(m1, -m2, r2 - r1);
    __int128 t = m1 * it.first + r1, mod = m1 * m2 / abs(d);
    t %= mod;
    if (t < 0) {
      t += mod;
    }
    if (t % m1 != r1 || t % m2 != r2) {
      return -1;
    }
    return t;
  }
};

math user;

signed main() {
  int t;
  cin >> t;
  while (t--) {
    const __int128 inf = (__int128) 2e23;
    long long x, y, p, q;
    __int128 ret = inf;
    cin >> x >> y >> p >> q;
    for (__int128 t1 = x; t1 < x + y; t1++) {
      for (__int128 t2 = p; t2 < p + q; t2++) {
        __int128 val = user.crt(2 * (x + y), p + q, t1, t2);
        if (val != -1) ret = min(ret, val);
      }
    }
    if (ret == inf) {
      cout << "infinity\n";
    } else {
      long long print = ret;
      cout << print << "\n";
    }
  }
}


