#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b % a == 0)
    return a;
  else
    return gcd(b % a, a);
}
int main() {
  int tc, a, b, i, black, white;
  cin >> tc;
  while (tc--) {
    cin >> a >> b;
    int c = gcd(a, b);
    if (c == 1)
      cout << "Finite" << endl;
    else
      cout << "Infinite" << endl;
  }
  return 0;
}
