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