#include <bits/stdc++.h>
bool gcd_one(int a, int b) {
  int c;
  while (b) c = a % b, a = b, b = c;
  return a == 1;
}
int main() {
  int Q;
  scanf("%d", &Q);
  while (Q--) {
    int a, b;
    scanf("%d %d", &a, &b);
    if (!gcd_one(a, b)) printf("in");
    printf("finite\n");
  }
}
