#include <bits/stdc++.h>
using namespace std;
const int mxN = 1e5;
const long long MOD = 1e9 + 7;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int main() {
  fast();
  int t;
  cin >> t;
  while (t--) {
    int a, b;
    cin >> a >> b;
    int gcdab = gcd(a, b);
    if (gcdab > 1) {
      cout << "Infinite\n";
    } else {
      cout << "Finite\n";
    }
  }
}
