#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
const int N = 2e5 + 1;
const int oo = 1e9;
const double pi = acos(-1);
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b;
    cin >> a >> b;
    if (gcd(a, b) == 1)
      puts("Finite");
    else
      puts("Infinite");
  }
  return 0;
}
