#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
int main() {
  long long t;
  cin >> t;
  while (t--) {
    int a, b;
    cin >> a >> b;
    if (gcd(a, b) == 1)
      cout << "Finite\n";
    else
      cout << "Infinite\n";
  }
}
