import sys
from sys import stdin,stdout
from math import *
import math, random, operator
from itertools import product, permutations, combinations
from collections import deque, defaultdict, Counter
input=sys.stdin.readline
def gcd(a,b):
if b==0:return abs(a)
else:return gcd(b,a%b)
def hi():
a,b=map(int,input().split())
if gcd(a,b)==1:print('Finite')
else:print("Infinite")
if __name__=="__main__":
for _ in range(int(input())):hi()
//https://codeforces.com/contest/1245/problem/A
#include <iostream>
using namespace std;
int gcd(int a, int b) {
if (b > a) {
swap(a,b);
}
if (b != 0) {
gcd(a % b, b);
} else {
return a;
}
}
int main()
{
int tests;
cin >> tests;
for (int i = 1; i <= tests; ++i) {
int a, b;
cin >> a >> b;
if (gcd(a, b) != 1) {
cout << "Infinite" << "\n";
} else {
cout << "Finite" << "\n";
}
}
}
1401C - Mere Array | 1613B - Absent Remainder |
1536B - Prinzessin der Verurteilung | 1699B - Almost Ternary Matrix |
1545A - AquaMoon and Strange Sort | 538B - Quasi Binary |
424A - Squats | 1703A - YES or YES |
494A - Treasure | 48B - Land Lot |
835A - Key races | 1622C - Set or Decrease |
1682A - Palindromic Indices | 903C - Boxes Packing |
887A - Div 64 | 755B - PolandBall and Game |
808B - Average Sleep Time | 1515E - Phoenix and Computers |
1552B - Running for Gold | 994A - Fingerprints |
1221C - Perfect Team | 1709C - Recover an RBS |
378A - Playing with Dice | 248B - Chilly Willy |
1709B - Also Try Minecraft | 1418A - Buying Torches |
131C - The World is a Theatre | 1696A - NIT orz |
1178D - Prime Graph | 1711D - Rain |