#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  while (a * b) {
    if (a > b)
      a %= b;
    else
      b %= a;
  }
  return a + b;
}
void solve() {
  long long a, b;
  cin >> a >> b;
  if (gcd(a, b) > 1) {
    cout << "Infinite";
  } else
    cout << "Finite";
  cout << endl;
}
int main() {
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    solve();
  }
  return 0;
}
