/*
“The only way that we can live is if we grow.
 The only way we can grow is if we change. 
The only way we can change is if we learn.
 The only way we can learn is if we are exposed.
 And the only way that we are exposed is if we throw ourselves into the open.”
 ***************************************   ************************   **********************************
*/
#include <bits/stdc++.h>
using namespace std;


//---------------------mishra ka idea------------------ 
#define int         long long
#define double      long double
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define sz(x)     (int)(x).size()
#define ull       unsigned long long
//------------------------mishra ka idea-------------------

//-------------------------alsi hu mai-----------------------
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
#define _init(b)     memset(b,-1,sizeof(b))
#define _init0(b)     memset(b,0,sizeof(b))
#define MOD         1000000007
#define hell        998244353
#define output(x) cout << (x ? "YES" : "NO")<<endl;
#define Output(x) cout << (x ? "Yes" : "No")<<endl;
//-------------------------alsi hu mai-----------------------



//--------------------het se uthaya---------------------
#define MOD2 (998244353)
#define MOD3 (1000000009)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18) 
 
 
 
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("in.txt");ofstream coutt("out.txt");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;} 

//--------------------het se uthaya-------------------------------------------------------------------


int gcd(int a, int b) {if(a>b)swap(a,b) ;  if (a == 0)  return b; return gcd(b % a, a); }  
int rint(int  l , int r){return rand()%(r-l+1) + l ;}
 
//---------------------------aab code dekho bahut template dekh liya---------------------------------


 
signed main()
{
   //freopen("input.txt", "r", stdin);
   //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int i,j,x;
   vi v;
   vi vv;
   fo(i,0,4){
    cin>>x;
    v.pb(x);
    vv.pb(x);
   }
   sort(all(v));
   int sum = 0;
   fo(i,0,(1<<4)){
    int a = 0 , b =0 ;
    fo(j,0,4){
      if(i&(1<<j)){
        a+=v[j];
      }
      else{
        b+=v[j];
      }
      if(a==b){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
   }

cout<<"No"<<endl;
   
   
   
   
    return 0;
}

//----------------abc tez kar liya iska matlab ye nahi tum legend ho kya pata hagdo aage ------------------
#pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
 
// const ll p = 998244353;
const ll nax = 100001;

ll gcd (ll a, ll b, ll & x, ll & y) {
	if (a == 0) {
		x = 0; y = 1;
		return b;
	}
	ll x1, y1;
	ll d = gcd (b%a, a, x1, y1);
	x = y1 - (b / a) * x1;
	y = x1;
	return d;
}
 
bool find_any_solution (ll a, ll b, ll c, ll & x0, ll & y0, ll & g) {
	g = gcd (abs(a), abs(b), x0, y0);
	if (c % g != 0)
		return false;
	b /= g;
	x0 *= c / g;
	y0 *= c / g;
	x0 %= b;
	if (x0 < 0) x0 += b;
	if (a < 0)   x0 *= -1;
	if (b < 0)   y0 *= -1;
	return true;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t;
	cin >> t;
	while (t--) {
		ll x, y, p, q, ans = INT64_MAX;
		cin >> x >> y >> p >> q;
		for (int i = 0; i < y; ++i) {
			for (int j = 0; j < q; ++j) {
				ll f, s, g;
				if (find_any_solution(2 * (x + y), p + q, p + j - x - i, f, s, g)) {
					ans = min(ans, 2 * f * (x + y) + x + i);
				}
			}
		}
		if (ans == INT64_MAX) cout << "infinity\n";
		else cout << ans << '\n';
	}
}