#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>
#include <numeric>
#include <chrono>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define debug(x) cerr << #x << " = " << (x) << endl;
#define debug_pii(x) cerr << "(" << x.first << "," << x.second << ")";
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define F first
#define S second

// template<typename _Ty1, typename _Ty2>
// ostream& operator<<(ostream& _os, const pair<_Ty1, _Ty2>& _p) {
//     _os << '(' <<_p.first << ',' << _p.second << ')';
//     return _os;
// }
//
// template<typename _Ty1, typename _Ty2>
// istream& operator>>(istream& _is, pair<_Ty1, _Ty2>& _p) {
//     _is >> _p.first >> _p.second;
//     return _is;
// }

ll gcd(ll a, ll b, ll& x, ll& y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  ll x1, y1;
  ll d = gcd(b, a % b, x1, y1);
  x = y1;
  y = x1 - y1 * (a / b);
  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) {
    return false;
  }

  x0 *= c / g;
  y0 *= c / g;
  if (a < 0) x0 = -x0;
  if (b < 0) y0 = -y0;
  return true;
}

ll gcd(ll x, ll y) {
  return (y == 0 ? x : gcd(y, x % y));
}

ll lcm(ll x, ll y) {
    return (x*y)/gcd(x, y);
}

template<typename T>
T extgcd(T a, T b, T &x, T &y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  T p = b / a;
  T g = extgcd(b - p * a, a, y, x);
  x -= p * y;
  return g;
}

template<typename T>
bool diophantine(T a, T b, T c, T &x, T &y, T &g) {
  if (a == 0 && b == 0) {
    if (c == 0) {
      x = y = g = 0;
      return true;
    }
    return false;
  }
  if (a == 0) {
    if (c % b == 0) {
      x = 0;
      y = c / b;
      g = abs(b);
      return true;
    }
    return false;
  }
  if (b == 0) {
    if (c % a == 0) {
      x = c / a;
      y = 0;
      g = abs(a);
      return true;
    }
    return false;
  }
  g = extgcd(a, b, x, y);
  if (c % g != 0) {
    return false;
  }
  T dx = c / a;
  c -= dx * a;
  T dy = c / b;
  c -= dy * b;
  x = dx + (T) ((__int128) x * (c / g) % b);
  y = dy + (T) ((__int128) y * (c / g) % a);
  g = abs(g);
  return true;
}

bool crt(long long k1, long long m1, long long k2, long long m2, long long &k, long long &m) {
  k1 %= m1;
  if (k1 < 0) k1 += m1;
  k2 %= m2;
  if (k2 < 0) k2 += m2;
  long long x, y, g;
  if (!diophantine(m1, -m2, k2 - k1, x, y, g)) {
    return false;
  }
  long long dx = m2 / g;
  long long delta = x / dx - (x % dx < 0);
  k = m1 * (x - dx * delta) + k1;
  m = m1 / g * m2;
  assert(0 <= k && k < m);
  return true;
}

void solve() {
  ll x, y, p, q;
  ll fans = LONG_LONG_MAX;
  cin >> x >> y >> p >> q;
  for(ll t1 = x;t1 < x+y;t1++) {
    for(ll t2 = p;t2 < p+q;t2++) {
      ll a = (2*x+2*y);
      ll b = p+q;
      // t%a=t1
      // t%b=t2
      // find minimum t if exist
      // t=i*a+t1=j*b+t2
      // i*a-j*b=t2-t1
      // sol : t%(lcm(a,b))=any solution
      ll x0, y0, g;
      // bool ans = find_any_solution(a, -b, t2-t1, x0, y0, g);
      ll t,m;
      bool ans = crt(t1,a,t2,b,t,m);
      if(!ans) continue;
      // ll an = (a*x0+t1)%(lcm(a,b));
      ll an = t;
      if(an < 0) an += lcm(a,b);
      fans = min(fans, an);

    }
  }
  if(fans == LONG_LONG_MAX) cout << "infinity" << endl;
  else cout << fans << endl;
}



int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);
 // cout << fixed << setprecision(15);

 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);
 int t = 1;
 cin >> t;
 while (t--) {
   solve();
 }

 return 0;
}

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

struct point
{
	ll x;
	ll y;
};

const ll MxN = 1e3+5;
point arr[MxN];

double dist(point a, point b)
{
	return sqrt((b.x - a.x)*(b.x - a.x) + (b.y-a.y)*(b.y-a.y));
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	ll n; cin >> n;
	for (ll i=0; i<n; i++)
		cin >> arr[i].x >> arr[i].y;
	
	bool ans = 0;
	for (ll i=0; i<n-2; i++)
		for (ll j=i+1; j<n-1; j++)
			for (ll k=j+1; k<n; k++)
				if ((arr[k].x-arr[i].x)*(arr[j].y-arr[i].y) == (arr[j].x-arr[i].x)*(arr[k].y-arr[i].y))
				{
					ans = 1;
					break;
				}

	cout << (ans ? "Yes\n" : "No\n");

	return 0;
}