#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
ll gcd(ll x, ll y) {return (x%y) ? gcd(y, x%y) : y; }
const int inf = 1000000000;
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
const ll mod = 1e9+7;

int main(){
    int x, y;
    cin >> x >> y;
    if(y>x){
        if(y-x>=3){
            cout << "No" << endl; return 0;
        } 
        else{
            cout << "Yes" << endl;
            return 0;
        } 
    }
    else{
        if(x-y>=3){
            cout << "No" << endl; return 0;
        } 
        else{
            cout << "Yes" << endl;
            return 0;
        }
    }
}
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#define ll long long
#define MAXN 200005
#define uns unsigned
#define MOD 998244353ll
#define INF 0x7f7f7f7f
using namespace std;
inline ll read(){
	ll x=0;bool f=1;char s=getchar();
	while((s<'0'||s>'9')&&s>0){if(s=='-')f^=1;s=getchar();}
	while(s>='0'&&s<='9')x=(x<<1)+(x<<3)+s-'0',s=getchar();
	return f?x:-x;
}
ll x,y,p,q;
inline ll ksm(ll a,ll b,ll mo){
	ll res=1;
	for(;b;b>>=1,a=a*a%mo)if(b&1)res=res*a%mo;
	return res;
}
inline ll gcd(ll a,ll b){
	return b==0?a:gcd(b,a%b);
}
inline ll exgcd(ll a,ll b,ll&x,ll&y){
	if(b==0){x=1,y=0;return a;}
	ll res=exgcd(b,a%b,y,x);
	y-=a/b*x;return res;
}
signed main()
{
	for(int T=read();T--;){
		x=read(),y=read(),p=read(),q=read();
		ll md=(x+y)<<1,lim=md*(p+q)+1,ans=lim;
		for(ll i=x;i<x+y;i++){
			ll b=p,a=p+q,c=((i-b)%md+md)%md;
			ll k,f,g=exgcd(a,md,k,f);
			if(c%g!=0)continue;
			c/=g,k=(k*c%md+md)%md,f=md/g,k%=f,a=p+q,b=p;
			if((k*a+b)%md>=x&&(k*a+b)%md<x+y)ans=min(ans,k*a+b);
		}
		md=p+q;
		for(ll i=p;i<p+q;i++){
			ll b=x,a=(x+y)<<1,c=((i-b)%md+md)%md;
			ll k,f,g=exgcd(a,md,k,f);
			if(c%g!=0)continue;
			c/=g,k=(k*c%md+md)%md,f=md/g,k%=f,a=(x+y)<<1,b=x;
			if((k*a+b)%md>=p&&(k*a+b)%md<p+q)ans=min(ans,k*a+b);
		}
		if(ans>=lim)printf("infinity\n");
		else printf("%lld\n",ans);
	}
	return 0;
}