#include <bits/stdc++.h>
using namespace std;
int judge(int a, int b) {
  for (int i = 2; i <= min(a, b); i++) {
    if (a % i == 0 && b % i == 0) return 0;
  }
  return 1;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b;
    cin >> a >> b;
    if (judge(a, b) == 1)
      cout << "Finite" << endl;
    else
      cout << "Infinite" << endl;
  }
}
