#include <bits/stdc++.h>
using namespace std;
long long int removeDuplicates(long long int arr[], long long int n) {
  sort(arr, arr + n);
  if (n == 0 || n == 1) return n;
  long long int temp[n];
  long long int j = 0;
  for (long long int i = 0; i < n - 1; i++)
    if (arr[i] != arr[i + 1]) temp[j++] = arr[i];
  temp[j++] = arr[n - 1];
  for (long long int i = 0; i < j; i++) arr[i] = temp[i];
  return j;
}
long long int mostFrequent(long long int arr[], long long int n) {
  sort(arr, arr + n);
  long long int max_count = 1, res = arr[0], curr_count = 1;
  for (long long int i = 1; i < n; i++) {
    if (arr[i] == arr[i - 1])
      curr_count++;
    else {
      if (curr_count > max_count) {
        max_count = curr_count;
        res = arr[i - 1];
      }
      curr_count = 1;
    }
  }
  if (curr_count > max_count) {
    max_count = curr_count;
    res = arr[n - 1];
  }
  return res;
}
bool isPerfectSquare(long double x) {
  long double sr = sqrt(x);
  return ((sr - floor(sr)) == 0);
}
long long int gcd(long long int a, long long int b) {
  while (b) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
long long int fSum(long long int arr[], long long int n, long long int sum) {
  unordered_map<long long int, long long int> prevSum;
  long long int res = 0;
  long long int currsum = 0;
  for (long long int i = 0; i < n; i++) {
    currsum += arr[i];
    if (currsum == sum) res++;
    if (prevSum.find(currsum - sum) != prevSum.end())
      res += (prevSum[currsum - sum]);
    prevSum[currsum]++;
  }
  return res;
}
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, i, l, ans = 0, pos, j, k, x, y, z, c1 = 0, count = 0,
                           c2 = 0, c3 = 0, flag = 0;
    long long int a, b;
    cin >> a >> b;
    l = gcd(a, b);
    if (l == 1)
      cout << "Finite\n";
    else
      cout << "Infinite\n";
  }
}
