#include <bits/stdc++.h>
using namespace std;
const long long int maxn = 2e5 + 1;
long long int gcd(long long int a, long long int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
void solve() {
  long long int a, b;
  cin >> a >> b;
  if (gcd(a, b) == 1)
    cout << "Finite\n";
  else
    cout << "Infinite\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int T = 1, p = 0;
  cin >> T;
  do {
    solve();
    p++;
  } while (p < T);
  return 0;
}
