#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y) {
  if (y == 0) {
    return x;
  } else {
    return gcd(y, x % y);
  }
}
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int a, b;
    cin >> a;
    cin >> b;
    int temp;
    if (b > a) {
      temp = a;
      a = b;
      b = temp;
    }
    int hcf = gcd(a, b);
    if (hcf == 1)
      cout << "Finite" << '\n';
    else
      cout << "Infinite" << '\n';
  }
}
