#include<bits/stdc++.h>
using namespace std;

int main() {
	int n;
	cin>>n;
	
	int pt[n][2];
	for(int i=0; i<n; i++) {
		cin>>pt[i][0]>>pt[i][1];
	}
	int x1, y1, x2, y2, x3, y3;
	for(int i=0; i<=n-3; i++) {
		x1 = pt[i][0];
		y1 = pt[i][1];
		for(int j=i+1; j<=n-2; j++) {
			x2 = pt[j][0];
			y2 = pt[j][1];
			for(int k=j+1; k<=n-1; k++) {
				x3 = pt[k][0];
				y3 = pt[k][1];
				if(x3*(y1-y2) + x1*(y2-y3) + x2*(y3-y1) == 0) { 
					cout<<"Yes";
					return 0;
				}
			}
		}
	}
	cout<<"No";
	return 0;
}
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

pll operator+(pll a,pll b){
  return pll(a.first+b.first,a.second+b.second);
}
pll operator-(pll a,pll b){
  return pll(a.first-b.first,a.second-b.second);
}
pll operator*(ll a,pll b){
  return pll(b.first*a,b.second*a);
}
const ll INF=(1LL<<60);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  a=abs(a);
  b=abs(b);
  if(a==0)return b;
  if(b==0)return a;
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


template<typename T> 
int sgn(T val){
  return (T(0)<val)-(val<T(0));
}

tuple<long long,long long,long long> egcd(long long a,long long b){
  // (val,da,db) val==gcd(a,b) da*a+db*b=val
  if(a==0||b==0)return std::make_tuple(0LL,0LL,0LL);
  long long sa=sgn(a),sb=sgn(b);
  a=std::abs(a);b=std::abs(b);
  long long p=1,q=0,r=0,s=1;
  while(b>0){
    long long c=a/b;
    long long d;
    d=a;a=b;b=d%b;
    d=p;p=q;q=d-c*q;
    d=r;r=s;s=d-c*s;
  }
  return std::make_tuple(a,p*sa,r*sb);
}
long long inverse(long long a,long long m){
  using namespace std;
  assert(abs(gcd(a,m))==1LL);
  assert(a!=0);
  auto [val,da,dm]=egcd(a,m);
  return (da%m+m)%m;
}
int main(){
  cout<<setprecision(1000);
  ll T;
  cin>>T;
  For(times,T){
    ll X,Y,P,Q;
    cin>>X>>Y>>P>>Q;
    ll mod=P+Q;
    ll l=X%mod,r=(X+Y)%mod;
    ll s=2*(X+Y);
    ll g=gcd(s,mod);
    ll ans=LLONG_MAX;
    FOR(i,P,P+Q){
      For(jj,Y){
        ll j=(jj+X)%mod;
        if(s%mod==0&&j!=i)continue;
        if(s%mod==0&&j==i){
          chmin(ans,jj+X);
          continue;
        }
        ll k=(i-j+mod)%mod;
        if(k%g!=0){
          continue;
        }
        ll nmod=mod/g;
        ll ns=s/g%nmod;
        ll nk=k/g;
        ll tmpans=inverse(ns,nmod)*nk%nmod*s+X+jj;
        chmin(ans,tmpans);
      }
    }
    if(ans==LLONG_MAX){
      cout<<"infinity"<<endl;
    }else{
      cout<<ans<<endl;
    }
  }
  return 0;
}
