#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
string readLine() {
  string str;
  getline(cin, str);
  if (str == "") getline(cin, str);
  return str;
}
vector<int> readVector(int n, bool decrease = false) {
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
    if (decrease) vec[i]--;
  }
  return vec;
}
template <typename T>
void println(const T& t) {
  cout << t << "\n";
}
template <typename T>
void println(T begin, T end) {
  while (begin != end) {
    cout << *begin++ << " ";
  }
  cout << "\n";
}
constexpr int DEBUG_MODE = 0;
constexpr int MULTIPLE_TEST_CASES = 1;
int gcd(int a, int b) {
  while (b > 0) {
    int temp = b;
    b = a % b;
    a = temp;
  }
  return a;
}
void solve() {
  int a, b;
  cin >> a >> b;
  if (gcd(a, b) == 1) {
    cout << "Finite\n";
  } else {
    cout << "Infinite\n";
  }
}
void solveAll() {
  int T = 1;
  if (MULTIPLE_TEST_CASES) cin >> T;
  while (T--) {
    solve();
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  if (!DEBUG_MODE) {
    solveAll();
    return 0;
  }
  ifstream in("main.01.inp");
  cin.rdbuf(in.rdbuf());
  solveAll();
  return 0;
}
