#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (a == 0) return b;
  if (b == 0) return a;
  if (a == b) return a;
  if (a > b) return gcd(a - b, b);
  return gcd(a, b - a);
}
void finite() {
  int a, b;
  int t;
  cin >> t;
  while (t--) {
    cin >> a >> b;
    int c = max(a, b);
    int d = min(a, b);
    if (gcd(c, d) == 1)
      cout << "Finite" << endl;
    else
      cout << "Infinite" << endl;
  }
}
int main() {
  finite();
  return 0;
}
