/*
ID: leezhen
TASK: practice
LANG: C++11
*/
#include <assert.h>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <iterator>
#include <map>
#include <new>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;
typedef long long ll;
#define bit(x, i) (x & (1 << i))
#define IN(i, l, r) (l < i && i < r)
#define LINR(i, l, r) (l <= i && i <= r)
#define LIN(i, l, r) (l <= i && i < r)
#define INR(i, l, r) (l < i && i <= r)
#define getI(a) scanf("%d", &a)
#define getII(a, b) scanf("%d%d", &a, &b)
#define getIII(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define getS(x) scanf("%s", x)
#define clr(a, x) memset(a, x, sizeof(a))
#define char2Int(c) (c - '0')
#define sz(x) ((int)((x).size()))
#define all(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
// for debug
#define what_is(x) \
  cerr << "Line " << __LINE__ << ": " << #x << " is " << (x) << endl;
#define error(args...)                       \
  {                                          \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
  }

void err(istream_iterator<string> it) { cerr << endl; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << " , ";
  err(++it, args...);
}
#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const int fx[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
const int fxx[8][2] = {{0, 1}, {0, -1}, {1, 0},  {-1, 0},
                       {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};

// struct
class UnionFind {
 private:
  vi p, rank, sz;

 public:
  UnionFind(int n) {
    p.assign(n, 0);
    rank.assign(n, 0);
    sz.assign(n, 1);
    for (int i = 0; i < n; i++) p[i] = i;
  }
  int findSet(int i) { return (i == p[i] ? i : findSet(p[i])); }
  bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
  void unionSet(int i, int j) {
    if (!isSameSet(i, j)) {
      int x = findSet(i), y = findSet(j);
      if (rank[x] > rank[y]) {
        p[y] = x;
        sz[x] += sz[y];
      } else {
        sz[y] += sz[x];
        p[x] = y;
        if (rank[x] == rank[y]) rank[y]++;
      }
    }
  }
};

// data
int n, m;
map<int, int> s;
vii nodes;
int A[300010];
int rv[300010];
int rr[300010];
int add(int x, int y) { return ((x + y) % mod + mod) % mod; }

int mul(int x, int y) { return (x * 1ll * y) % mod; }

int binpow(int x, int y) {
  int z = 1;
  while (y > 0) {
    if (y % 2 == 1) z = mul(z, x);
    x = mul(x, x);
    y /= 2;
  }
  return z;
}

int inv(int x) { return binpow(x, mod - 2); }

int C(int n, int k) {
  if (k > n || n < 0 || k < 0) return 0;
  return mul(A[n], mul(rv[n - k], rv[k]));
}

int main() {
  getII(n, m);
  int l, r;
  REP(i, 1, n + 1) {
    getII(l, r);
    nodes.eb(l, -i);
    nodes.eb(r, i);
    rr[i] = r;
  }
  int a, b;
  UnionFind uf(n + 1);
  REP(i, 0, m) {
    getII(a, b);
    uf.unionSet(a, b);
  }
  sort(nodes.begin(), nodes.end());
  A[0] = 1;
  REP(i, 1, n + 1) A[i] = mul(A[i - 1], i);
  REP(i, 0, n + 1) rv[i] = inv(A[i]);

  int ans = 0;
  int j = 0;
  REP(i, 1, n + 1) {
    while (j < nodes.size() && nodes[j].second < 0 && nodes[j].first == i) {
      ++s[uf.findSet(-nodes[j].second)];
      ++j;
    }
    // ans += C(s.size(), i);
    ans = add(ans, C(s.size(), i));
    // error(i, ans, s.size(), C(s.size(), i));
    while (j < nodes.size() && nodes[j].first == i) {
      int u = uf.findSet(nodes[j].second);
      --s[u];
      if (s[u] == 0) s.erase(u);
      ++j;
    }
  }
  printf("%d\n", ans);
  return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int maxn=3e5+10;
const ll mod=998244353;

ll invP[maxn],P[maxn];
int sum[maxn][42],n,l[maxn],r[maxn],val[maxn],m;
ll ans=0;
bool f[maxn];
vector <pair<int,int> > v;

int get_inv(ll x,ll k){
	if(k==0) return 1;
	ll res=get_inv(x,k>>1); res*=res;res%=mod;
	if(k&1) res*=x,res%=mod;
	return res;
}

ll C(ll a,ll b){
	if(a<b||a<0||b<0) return 0;
	ll res=P[a]*invP[a-b]%mod; res=res*invP[b]%mod;
	return res;
}

int main(){
	P[0]=1;
	for(int i=1;i<maxn;i++) P[i]=ll(i)*P[i-1]%mod;
	for(int i=0;i<maxn;i++) invP[i]=get_inv(P[i],mod-2);
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++) scanf("%d%d",&l[i],&r[i]);
	for(int i=0;i<m;i++){
		int a,b; scanf("%d%d",&a,&b); a--; b--; v.pb(mp(a,b));
	}
	for(int i=0;i<n;i++) val[l[i]]++,val[r[i]+1]--;
	for(int i=1;i<=n;i++) val[i]+=val[i-1];
	for(int i=1;i<=n;i++) for(int j=0;j<=m*2;j++)
		sum[i][j]=(sum[i-1][j]+C(val[i]-j,i-j))%mod;
	for(int mask=0;mask<(1<<m);mask++){
	//	cout<<mask<<endl;
		vector <int> now;
		for(int i=0;i<m;i++) if(mask&(1<<i)){
			if(!f[v[i].fst]) f[v[i].fst]=true,now.pb(v[i].fst);
			if(!f[v[i].snd]) f[v[i].snd]=true,now.pb(v[i].snd);
		}
		int L=1,R=n;
		for(int i=0;i<now.size();i++){
			L=max(L,l[now[i]]);
			R=min(R,r[now[i]]);
		}
	//	cout<<L<<" "<<R<<endl;
		if(R<L) continue;
	//	cout<<L<<" "<<R<<endl;
		if(__builtin_popcount(mask)%2==1) ans-=sum[R][now.size()]-sum[L-1][now.size()];
		else ans+=sum[R][now.size()]-sum[L-1][now.size()];
		ans+=mod; ans%=mod;
	}
	printf("%d\n",ans);
	return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int maxn=3e5+10;
const ll mod=998244353;

ll invP[maxn],P[maxn];
int sum[maxn][42],n,l[maxn],r[maxn],val[maxn],m;
ll ans=0;
bool f[maxn];
vector <pair<int,int> > v;

int get_inv(ll x,ll k){
	if(k==0) return 1;
	ll res=get_inv(x,k>>1); res*=res; res%=mod;
	if(k&1) res*=x,res%=mod;
	return res;
}

ll C(ll a,ll b){
	if(a<b||a<0||b<0) return 0;
	ll res=P[a]*invP[a-b]%mod; res=res*invP[b]%mod;
	return res;
}

int main(){
	P[0]=1;
	for(int i=1;i<maxn;i++) P[i]=ll(i)*P[i-1]%mod;
	for(int i=0;i<maxn;i++) invP[i]=get_inv(P[i],mod-2);
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++) scanf("%d%d",&l[i],&r[i]);
	for(int i=0;i<m;i++){
		int a,b; scanf("%d%d",&a,&b); a--; b--; v.pb(mp(a,b));
	}
	for(int i=0;i<n;i++) val[l[i]]++,val[r[i]+1]--;
	for(int i=1;i<=n;i++) val[i]+=val[i-1];
	for(int i=1;i<=n;i++) for(int j=0;j<=m*2;j++) sum[i][j]=(sum[i-1][j]+C(val[i]-j,i-j))%mod;
	for(int mask=0;mask<(1<<m);mask++){
		vector <int> now;
		for(int i=0;i<m;i++) if(mask&(1<<i)){
			if(!f[v[i].fst]) f[v[i].fst]=true,now.pb(v[i].fst);
			if(!f[v[i].snd]) f[v[i].snd]=true,now.pb(v[i].snd);
		}
		int L=1,R=n;
		for(int i=0;i<now.size();i++) L=max(L,l[now[i]]),R=min(R,r[now[i]]);
		for(int i=0;i<now.size();i++) f[now[i]]=false;
		if(R<L) continue;
		ll res=sum[R][now.size()]-sum[L-1][now.size()]+mod; res%=mod;
		if(__builtin_popcount(mask)%2==1) ans-=res;
		else ans+=res;
		ans+=mod; ans%=mod;
	}
	printf("%d\n",ans);
	return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int maxn=3e5+10;
const ll mod=998244353;

ll invP[maxn],P[maxn];
int sum[maxn][42],n,l[maxn],r[maxn],val[maxn],m;
ll ans=0;
bool f[maxn];
vector <pair<int,int> > v;

int get_inv(ll x,ll k){
	if(k==0) return 1;
	ll res=get_inv(x,k>>1); res*=res; res%=mod;
	if(k&1) res*=x,res%=mod;
	return res;
}

ll C(ll a,ll b){
	if(a<b||a<0||b<0) return 0;
	ll res=P[a]*invP[a-b]%mod; res=res*invP[b]%mod;
	return res;
}

int main(){
	P[0]=1;
	for(int i=1;i<maxn;i++) P[i]=ll(i)*P[i-1]%mod;
	for(int i=0;i<maxn;i++) invP[i]=get_inv(P[i],mod-2);
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++) scanf("%d%d",&l[i],&r[i]);
	for(int i=0;i<m;i++){
		int a,b; scanf("%d%d",&a,&b); a--; b--; v.pb(mp(a,b));
	}
	for(int i=0;i<n;i++) val[l[i]]++,val[r[i]+1]--;
//	for(int i=1;i<=n;i++) cout<<val[i]<<" "; cout<<endl;
	for(int i=1;i<=n;i++) val[i]+=val[i-1];
//	for(int i=1;i<=n;i++) cout<<val[i]<<" "; cout<<endl;
	for(int i=1;i<=n;i++) for(int j=0;j<=m*2;j++)
		sum[i][j]=(sum[i-1][j]+C(val[i]-j,i-j))%mod;
//	cout<<C(10,2)<<endl;
	for(int mask=0;mask<(1<<m);mask++){
	//	cout<<mask<<endl;
		vector <int> now;
		for(int i=0;i<m;i++) if(mask&(1<<i)){
		//	cout<<mask<<","<<i<<" ";
			if(!f[v[i].fst]) f[v[i].fst]=true,now.pb(v[i].fst);
			if(!f[v[i].snd]) f[v[i].snd]=true,now.pb(v[i].snd);
		}
		int L=1,R=n;
		for(int i=0;i<now.size();i++){
			L=max(L,l[now[i]]);
			R=min(R,r[now[i]]);
		}
		for(int i=0;i<now.size();i++) f[now[i]]=false;
	//	cout<<L<<" "<<R<<endl;
		if(R<L) continue;
	//	cout<<mask<<endl;
	//	for(int i=0;i<now.size();i++) cout<<now[i]<<" "; cout<<endl;
	//	cout<<mask<<" "<<L<<" "<<R<<endl;
		ll res=sum[R][now.size()]-sum[L-1][now.size()]+mod; res%=mod;
		if(__builtin_popcount(mask)%2==1) ans-=res;
		else ans+=res;
		ans+=mod; ans%=mod;
	//	cout<<mask<<" "<<sum[R][now.size()]-sum[L-1][now.size()]<<" "<<ans<<endl;
	}
	printf("%d\n",ans);
	return 0;
}


import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class a{
     static int[] count;
     // static int[] count1;
     static long[] arr;
     static char[] ch,c1;
     static long[] darr;
     static long x;
     static long maxl;
     static double dec;
     static String s;
     // static long minl;
     static int mx = (int)1e6;
     static long mod = 998244353l;
     // static int minl = -1;
     // static long n;
     static int n,n1,n2;
     static long a;
     static long b;
     static long c;
     static long d;
     static long y;
     static long m;
     static long k;
     static int q;
     static String[] str,str1;
     static Set<Character> set,set1;
     static List<Long> list;
     static Map<Long,Integer> map;
     static StringBuilder sb;

     public static boolean solve(){

        if(gcd(a,b) == 1)
            return !false;
        return !true;

     }

     public static void main(String[] args) {

            // FastScanner sc = new FastScanner();
            Scanner sc = new Scanner(System.in);
            int t = sc.nextInt();
            while(t > 0){
                 // set = new HashSet<>();
                 // map = new HashMap<>();

                // x = sc.nextLong();
                // y = sc.nextLong();

                // d = sc.nextLong();

                a = sc.nextLong();
                b = sc.nextLong();
                // n = sc.nextInt();
                // a = sc.nextLong();
                // b = sc.nextLong();

                // c = sc.nextLong();
                // // n = sc.nextLong();
                // // x = sc.nextLong();
                // ch = sc.next().toCharArray();
                // s = sc.next();

                 // long x = sc.nextLong();

                // k = sc.nextLong();
                // dec = sc.nextDouble();
                // n = sc.nextInt();
                // m = sc.nextLong();

                // arr = new long[n];
                // for(int i = 0; i < n ; i++){
                //     arr[i] = sc.nextLong();
                // }
                // // set = new HashSet<>();
                // for(int i = 0 ; i < n ; i++)
                //     set.add(sc.next().charAt(0));

                // n1 = sc.nextInt();
                //  darr = new long[n1];
                //  for(int i = 0; i < n1 ; i++){
                //      darr[i] = sc.nextLong();
                //  }

                System.out.println(solve()?"FINITE":"INFINITE");
                // solve();
                 // System.out.println(solve());
                 // sb = new StringBuilder();
                 // sb.append(str);

                 t -= 1;
            }

     }

    public static int log(long n){
         if(n == 0)
             return 0;

         if(n == 1)
             return 0;
         if(n == 2)
             return 1;
         double num = Math.log(n);
         double den = Math.log(2);
         if(den == 0)
             return 0;
         return (int)(num/den);
     }

     public static long gcd(long a,long b){

        if(b%a == 0)
            return a;

        return gcd(b%a,a);

     }

     // public static void swap(int i,int j){
     //     long temp = arr[j];
     //     arr[j] = arr[i];
     //     arr[i] = temp;
     // }

    static final Random random=new Random();

    static void ruffleSort(long[] a) {
        int n=a.length;//shuffle, then sort
        for (int i=0; i<n; i++) {
            int oi=random.nextInt(n);
            long temp=a[oi];
            a[oi]=a[i]; a[i]=temp;
        }
        Arrays.sort(a);
    }

    static class Node{
        int first;
        int second;
        Node(int f,int s){
            this.first = f;
            this.second = s;
        }
    }

     static class FastScanner {

                BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
                StringTokenizer st=new StringTokenizer("");
                String next() {
                        while (!st.hasMoreTokens())
                                try {
                                        st=new StringTokenizer(br.readLine());
                                } catch (IOException e) {
                                        e.printStackTrace();
                                }
                        return st.nextToken();
                }

                int nextInt() {
                        return Integer.parseInt(next());
                }
                int[] readArray(int n) {
                        int[] a=new int[n];
                        for (int i=0; i<n; i++) a[i]=nextInt();
                        return a;
                }
                long nextLong() {
                        return Long.parseLong(next());
                }
        }

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public static boolean prime(int a){
            if (a==1) return true;
            for (int i = 2; i*i <=a ; i++) {
                if (a%i == 0) return false;
            }
            return true;
        }
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int t = in.nextInt();
            for (int i = 0; i <t ; i++) {
                int a = in.nextInt();
                int b = in.nextInt();
                if (prime(a) || prime(b)) out.println("Finite");
                else out.println("Infinite");

            }

        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public Long nextLong() { return Long.parseLong(next()); }

    }

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public static int gcd(int a , int b){
            if (a == 0)
                return b;
            return gcd(b % a, a);
        }
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int t = in.nextInt();
            for (int i = 0; i <t ; i++) {
                int a = in.nextInt();
                int b = in.nextInt();
                if (gcd(a,b)!=1) out.println("Infinite");
                else out.println("finite");

            }

        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public Long nextLong() { return Long.parseLong(next()); }

    }

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int t = in.nextInt();
            for (int i = 0; i <t ; i++) {
                int a = in.nextInt();
                int b = in.nextInt();
                if (a == 1 || b == 1) {
                    out.println("Finite");
                    continue;
                }
                if (a%b==1 || b%a==1){
                    out.println("Finite");
                    continue;
                }
                out.println("Infinite");
            }

        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public Long nextLong() { return Long.parseLong(next()); }

    }

}


import java.io.*;
import java.util.*;

public class Main
{
    public static void main(String[] args) throws IOException
	{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int t = Integer.parseInt(st.nextToken()),a,b;

        for(int i=0; i<t; i++)
        {
            st = new StringTokenizer(br.readLine());
            a = Integer.parseInt(st.nextToken());
            b = Integer.parseInt(st.nextToken());

            if(gcd(a,b) == 1) System.out.println("Finite");
            else System.out.println("Infinite");
        }
    }

    static double findDistanceBetweenTwoPoints(int x1, int y1, int x2, int y2){
        return Math.sqrt(Math.pow(x2-x1,2) + Math.pow(y2-y1,2));
    }

    static int[] countLetterFreqeuncy(String str, int[] ltrs){
        for(int i=0; i<str.length(); i++)
            ltrs[(int) (str.charAt(i) - 'a')]++;
        return ltrs;
    }

    static long gcd(long a, long b) {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }

    static long lcm(long a, long b) {
        return (a*b)/
        gcd(a, b);
    }

    // Arrays.sort(arr, new Comparator<Integer[]>() {
    //     @Override
    //             //arguments to this method represent the arrays to be sorted
    //     public int compare(Integer[] arr1, Integer[] arr2) {
    //             //get the item ids which are at index 0 of the array
    //             Integer item1 = arr1[0];
    //             Integer item2 = arr2[0];
    //         // sort based on price
    //         return item1.compareTo(item2);
    //     }
    // });

    //String.join("", Collections.nCopies(n-1, "");

    static int binarySearch(int left, int right, int find, int[] arr){
        int mid = left + (right-left)/2;
        if(find == arr[mid]) return mid;
        else if(find < arr[mid]) return binarySearch(left,mid-1,find,arr);
        else return binarySearch(mid+1,right,find,arr);
    }

    static ArrayList<Integer> separateDigits(int num){
         int pow = 0;
         ArrayList<Integer> arr = new ArrayList<>();
         while(num != 0)
         {
             if(num % 10 != 0)
             {
                 arr.add((num % 10) * (int) Math.pow(10, pow));
             }
             num /= 10;
             pow++;
         }
         return arr;
     }

     //find pattern
//     for(int i = 0; i<n-1; i++)
//     {
//         for(int j = 0; j<m-1; j++)
//         {
//                 if(pixel[i].charAt(j)*pixel[i+1].charAt(j)*pixel[i].charAt(j+1)*pixel[i+1].charAt(j+1) == 'f'*'a'*'c'*'e')
//                     faceNum++;
//         }
//     }

// row and column checking
    // static boolean checkAllRows(String[] board)
    // {
    //     for(int i=0; i<board.length; i++)
    //     {
    //         for(int j=0; j<board.length; j++)
    //         {
    //             if(board[i].charAt(j) == 'B')
    //             {
    //                 return false;
    //             }
    //         }
    //     }
    //     return true;
    // }

    class Pair implements Comparable<Pair>{
        int x;
        int y;

        public Pair(int x, int y)
        {
            this.x = x;
            this.y = y;
        }
        @Override
        public int compareTo(Pair p)
        {
            if(p.y == y)
            return x - p.x;
            return p.y - y;
        }
    }
}


import java.io.ByteArrayInputStream;

public class A {

    public static void main(String[] args) {
        java.util.Scanner scanner = new java.util.Scanner(System.in);

        int testCount = scanner.nextInt();
        scanner.nextLine();
        for (int i = 0; i < testCount; i++) {
            int a = scanner.nextInt();
            //4scanner.next(" ");
            int b = scanner.nextInt();
            String result = "";

            if (a==b) result="infinite";
            else if (a==1 || b==1 )
                result= "finite";
            else if (a>b)
                result = getResult(a, b);
            else
                result = getResult(b, a);
            System.out.println(result);
        }

    }

    private static String getResult(int a, int b) {

        int n = gcdByEuclidsAlgorithm(a, b);
        if (n==1)
            return "Finite";
        return "Infinite";

    }

    static int gcdByEuclidsAlgorithm(int a, int b) {
        if (b == 0) {
            return a;
        }
        return gcdByEuclidsAlgorithm(b, a % b);
    }

}


import java.io.ByteArrayInputStream;

public class A {

    public static void main(String[] args) {
        java.util.Scanner scanner = new java.util.Scanner(System.in);

        int testCount = scanner.nextInt();
        scanner.nextLine();
        for (int i = 0; i < testCount; i++) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            String result = "";

            getResult(a, b);
            System.out.println(result);
        }

    }

    private static String getResult(int a, int b) {

        int n = gcdByEuclidsAlgorithm(a, b);
        if (n==1)
            return "Finite";
        return "Infinite";

    }

    static int gcdByEuclidsAlgorithm(int a, int b) {
        if (b == 0) {
            return a;
        }
        return gcdByEuclidsAlgorithm(b, a % b);
    }

}


import java.io.ByteArrayInputStream;

public class A {

    public static void main(String[] args) {
        java.util.Scanner scanner = new java.util.Scanner(System.in);

        int testCount = scanner.nextInt();
        scanner.nextLine();
        for (int i = 0; i < testCount; i++) {
            int a = scanner.nextInt();
            //4scanner.next(" ");
            int b = scanner.nextInt();
            String result = "";

            if (a==b) result="infinite";
            else if (a==1 || b==1 )
                result= "finite";
            else if (a==2 && b%2==1)
                result= "finite";
            else if (b==2 && a%2==1)
                result= "finite";
            else if (b==2 && a%2==0 || a==2 && b%2==0)
                result= "infinite";
            else if (a>b)
                result = getResult(a, b);
            else
                result = getResult(b, a);
            System.out.println(result);
        }

    }

    private static String getResult(int a, int b) {

        int n = gcdByEuclidsAlgorithm(a, b);
        if (n==1)
            return "Finite";
        return "Infinite";

    }

    static int gcdByEuclidsAlgorithm(int a, int b) {
        if (b == 0) {
            return a;
        }
        return gcdByEuclidsAlgorithm(b, a % b);
    }

}


import java.io.ByteArrayInputStream;

public class A {

    public static void main(String[] args) {
        java.util.Scanner scanner = new java.util.Scanner(System.in);

        int testCount = scanner.nextInt();
        scanner.nextLine();
        for (int i = 0; i < testCount; i++) {
            int a = scanner.nextInt();
            //4scanner.next(" ");
            int b = scanner.nextInt();
            String result = "";

            if (a==b) result="infinite";
            else if (a==1 || b==1 )
                result= "finite";
            else if (b%2==0 && a%2==0)
                result= "infinite";
            else if (a>b)
                result = getResult(a, b);
            else
                result = getResult(b, a);
            System.out.println(result);
        }

    }

    private static String getResult(int a, int b) {

        int n = gcdByEuclidsAlgorithm(a, b);
        if (n==1)
            return "Finite";
        return "Infinite";

    }

    static int gcdByEuclidsAlgorithm(int a, int b) {
        if (b == 0) {
            return a;
        }
        return gcdByEuclidsAlgorithm(b, a % b);
    }

}


import java.io.ByteArrayInputStream;

public class A {

    public static void main(String[] args) {
        java.util.Scanner scanner = new java.util.Scanner(System.in);

        int testCount = scanner.nextInt();
        scanner.nextLine();
        for (int i = 0; i < testCount; i++) {
            int a = scanner.nextInt();
            //4scanner.next(" ");
            int b = scanner.nextInt();

            if (a==b) return "infinite";
            String result = "";
            if (a>a)
                result = getResult(a, b);
            else
                result = getResult(b, a);
            System.out.println(result);
        }

    }

    private static String getResult(int a, int b) {

        int n = gcdByEuclidsAlgorithm(a, b);
        if (n==1)
            return "Infinite";
        return "Finite";

    }

    static int gcdByEuclidsAlgorithm(int a, int b) {
        if (b == 0) {
            return a;
        }
        return gcdByEuclidsAlgorithm(b, a % b);
    }

}


import java.io.ByteArrayInputStream;

public class A {

    public static void main(String[] args) {
        java.util.Scanner scanner = new java.util.Scanner(System.in);

        int testCount = scanner.nextInt();
        scanner.nextLine();
        for (int i = 0; i < testCount; i++) {
            int a = scanner.nextInt();
            //4scanner.next(" ");
            int b = scanner.nextInt();
            String result = "";

            if (a==b) result="infinite";
            else if (a>a)
                result = getResult(a, b);
            else
                result = getResult(b, a);
            System.out.println(result);
        }

    }

    private static String getResult(int a, int b) {

        int n = gcdByEuclidsAlgorithm(a, b);
        if (n==1)
            return "Infinite";
        return "Finite";

    }

    static int gcdByEuclidsAlgorithm(int a, int b) {
        if (b == 0) {
            return a;
        }
        return gcdByEuclidsAlgorithm(b, a % b);
    }

}


import java.io.ByteArrayInputStream;

public class A {

    public static void main(String[] args) {
        java.util.Scanner scanner = new java.util.Scanner(System.in);

        int testCount = scanner.nextInt();
        scanner.nextLine();
        for (int i = 0; i < testCount; i++) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            String result = "";

            if (a==b) result="infinite";
            else if (a==1 || b==1 )
                result= "finite";
            else if (b%2==0 && a%2==0)
                result= "infinite";
            else if (a>b)
                result = getResult(a, b);
            else
                result = getResult(b, a);
            System.out.println(result);
        }

    }

    private static String getResult(int a, int b) {

        int n = gcdByEuclidsAlgorithm(a, b);
        if (n==1)
            return "Finite";
        return "Infinite";

    }

    static int gcdByEuclidsAlgorithm(int a, int b) {
        if (b == 0) {
            return a;
        }
        return gcdByEuclidsAlgorithm(b, a % b);
    }

}


import java.io.ByteArrayInputStream;

public class A {

    public static void main(String[] args) {
        java.util.Scanner scanner = new java.util.Scanner(System.in);

        int testCount = scanner.nextInt();
        scanner.nextLine();
        for (int i = 0; i < testCount; i++) {
            int a = scanner.nextInt();
            scanner.next(" ");
            int b = scanner.nextInt();

            String result = getResult(a, b);
            System.out.println(result);
        }

    }

    private static String getResult(int a, int b) {

        if ((b>a && b-a < a) || (a>b && a-b < b) || a==b)
            return "infinite";
        else return "finite";

    }

}


import java.io.ByteArrayInputStream;

public class A {

    public static void main(String[] args) {
        java.util.Scanner scanner = new java.util.Scanner(System.in);

        int testCount = scanner.nextInt();
        scanner.nextLine();
        for (int i = 0; i < testCount; i++) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            String result = "";

             if (a==1 || b==1 )
                result= "Finite";
             else if (a==b)
                 result="Infinite";

            else if (b%2==0 && a%2==0)
                result= "Infinite";
            else if (a>b)
                result = getResult(a, b);
            else
                result = getResult(b, a);
            System.out.println(result);
        }

    }

    private static String getResult(int a, int b) {

        int n = gcdByEuclidsAlgorithm(a, b);
        if (n==1)
            return "Finite";
        return "Infinite";

    }

    static int gcdByEuclidsAlgorithm(int a, int b) {
        if (b == 0) {
            return a;
        }
        return gcdByEuclidsAlgorithm(b, a % b);
    }

}


import java.io.ByteArrayInputStream;

public class A {

    public static void main(String[] args) {
        java.util.Scanner scanner = new java.util.Scanner(System.in);

        int testCount = scanner.nextInt();
        scanner.nextLine();
        for (int i = 0; i < testCount; i++) {
            int a = scanner.nextInt();
            //4scanner.next(" ");
            int b = scanner.nextInt();

            String result = getResult(a, b);
            System.out.println(result);
        }

    }

    private static String getResult(int a, int b) {

        //if ((b>a && b-a < a) || (a>b && a-b < b) || a==b)
        if ((b>a && 2*a < b) || (a>b && 2*b < a))
            return "Finite";
        else return "Infinite";

    }

}


import java.io.ByteArrayInputStream;

public class A {

    public static void main(String[] args) {
        java.util.Scanner scanner = new java.util.Scanner(System.in);

        int testCount = scanner.nextInt();
        scanner.nextLine();
        for (int i = 0; i < testCount; i++) {
            int a = scanner.nextInt();
            //4scanner.next(" ");
            int b = scanner.nextInt();
            String result = "";

            if (a==b) result="infinite";
            else if (a==1 || b==1 )
                result= "finite";
            else if (a>a)
                result = getResult(a, b);
            else
                result = getResult(b, a);
            System.out.println(result);
        }

    }

    private static String getResult(int a, int b) {

        int n = gcdByEuclidsAlgorithm(a, b);
        if (n==1)
            return "Finite";
        return "Infinite";

    }

    static int gcdByEuclidsAlgorithm(int a, int b) {
        if (b == 0) {
            return a;
        }
        return gcdByEuclidsAlgorithm(b, a % b);
    }

}


import java.io.ByteArrayInputStream;

public class A {

    public static void main(String[] args) {
        java.util.Scanner scanner = new java.util.Scanner(System.in);

        int testCount = scanner.nextInt();
        scanner.nextLine();
        for (int i = 0; i < testCount; i++) {
            int a = scanner.nextInt();
            scanner.next();
            int b = scanner.nextInt();

            String result = getResult(a, b);
            System.out.println(result);
        }

    }

    private static String getResult(int a, int b) {

        if ((b>a && b-a < a) || (a>b && a-b < b) || a==b)
            return "infinite";
        else return "finite";

    }

}


import java.io.ByteArrayInputStream;

public class A {

    public static void main(String[] args) {
        java.util.Scanner scanner = new java.util.Scanner(System.in);

        int testCount = scanner.nextInt();
        scanner.nextLine();
        for (int i = 0; i < testCount; i++) {
            int a = scanner.nextInt();
            //4scanner.next(" ");
            int b = scanner.nextInt();

            String result = getResult(a, b);
            System.out.println(result);
        }

    }

    private static String getResult(int a, int b) {

        if ((b>a && b-a < a) || (a>b && a-b < b) || a==b)
            return "infinite";
        else return "finite";

    }

}


import java.util.*;
/*
NOTES:
-more than 10 digits (10^10), use long
-prefix sum of 1's and -1's to control flow of highlighting a region
-log(a)/log(b) = log base b of a
-create a position array if trying to see if elements show up next to each other sequentially
 i.e. elements 1,2,3 are within 3 spots of each other in an array
      arr[scannedInt - 1] = i; (position of i at p[i] in original)
- use a freq array when counting instances of an element occurring
- increment the counter first before simulating anything turn-based (two player game)

 */

public class Main {
    static long mod = (long)(Math.pow(10, 9) + 7);
    public static String alpha = "zabcdefghijklmnopqrstuvwxy";
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int t = scan.nextInt();
        while (t-- > 0) {
            int a = scan.nextInt();
            int b = scan.nextInt();
            if(GCD(a,b) == 1) System.out.println("Finite");
            else System.out.println("Infinite");
        }
        scan.close();
    }

    static int GCD(int a, int b) {
        // Everything divides 0
        if (a == 0) return b;
        if (b == 0) return a;

        // base case
        if (a == b) return a;

        // a is greater
        if (a > b) return GCD(a-b, b);
        return GCD(a, b-a);
    }
    static int LCM(int a, int b){
        return (a*b)/(GCD(a,b));
    }
    static String rev(String s){
        char[] arr = s.toCharArray();
        for(int i = 0; i<(s.length()+1)/2; i++){
            char temp = arr[i];
            arr[i] = arr[s.length()-i-1];
            arr[s.length()-i-1] = temp;
        }
        String fin = new String(arr);
        return fin;
    }
    static long pow(long a, long N) {
        if (N == 0) return 1;
        else if (N == 1) return a;
        else {
            long R = pow(a,N/2);
            if (N % 2 == 0) {
                return R*R;
            }
            else {
                return R*R*a;
            }
        }
    }

    static long powMod(long a, long N) {
        if (N == 0) return 1;
        else if (N == 1) return a % mod;
        else {
            long R = powMod(a,N/2) % mod;
            R *= R;
            R %= mod;
            if (N % 2 == 1) {
                R *= a;
                R %= mod;
            }
            return R % mod;
        }
    }

}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        int n;
        int a , b;
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        for (int i = 0; i < n; i++){
            a = sc.nextInt();
            b = sc.nextInt();
            if (a == 1 || b == 1){
                System.out.println("Finite");
            }
            else if (a % b == 1 || b % a == 1){
                System.out.println("Finite");
            }
            else{
                System.out.println("Infinite");
            }
        }
    }
}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        int n = 1;
        int a = 13, b=20;
        int arr[] = new int[10000];
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();

        for (int i = 0; i < n; i++){
            a = sc.nextInt();
            b = sc.nextInt();
            if (a == 1 || b == 1){
                System.out.println("Finite");
            }
            else if (a % 2 ==0 && b % 2 == 0){
                System.out.println("Finite");
            }
            else{
                System.out.println("Infinite");
            }
        }
        arr[0] = 1;

       /* for (int i = 0; i < 1000; i++){
            if (i-a >= 0){
                if (arr[i - a] == 1  ){
                    arr[i] = 1;
                }
            }
            if (i-b >= 0){
                if (arr[i - b] == 1  ){
                    arr[i] = 1;
                }
            }
            System.out.print(i + ": " + arr[i] + ", " );
            if (i % 20 == 0){
                System.out.println();
            }*/
        }
    }


package com.company;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        int n;
        int a , b;
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        for (int i = 0; i < n; i++){
            a = sc.nextInt();
            b = sc.nextInt();
            if (a == 1 || b == 1){
                System.out.println("Finite");
            }
            else if (a % b == 1 || b % a == 1){
                System.out.println("Finite");
            }
            else{
                System.out.println("Infinite");
            }
        }
    }
}


import java.util.Scanner;

public class Main {
    static int nod(int a , int b){
        while(a * b != 0){
            if (a > b){
                a = a % b;
            }
            else{
                b = b % a;
            }
        }
        return a + b;
    }

    public static void main(String[] args) {
        int n = 1;
        int a = 13, b=20;
        int arr[] = new int[10000];
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();

        for (int i = 0; i < n; i++){
            a = sc.nextInt();
            b = sc.nextInt();
            if (a == 1 || b == 1){
                System.out.println("Finite");
            }
            else if (a % 2 ==0 && b % 2 == 0){
                System.out.println("Infinite");
            }
            else if (nod(a,b)  == 1){
                System.out.println("Finite");
            }
            else{
                System.out.println("Infinite");
            }
        }
        arr[0] = 1;

       /* for (int i = 0; i < 1000; i++){
            if (i-a >= 0){
                if (arr[i - a] == 1  ){
                    arr[i] = 1;
                }
            }
            if (i-b >= 0){
                if (arr[i - b] == 1  ){
                    arr[i] = 1;
                }
            }
            System.out.print(i + ": " + arr[i] + ", " );
            if (i % 20 == 0){
                System.out.println();
            }*/
        }
    }


import java.util.*;
import java.util.Map.Entry;
import java.io.*;
import java.math.*;

public class daniel {

	public static void main(String args[]) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

		int t=Integer.parseInt(br.readLine());
		while(t-->0) {
			String s[]=br.readLine().split("\\ ");
			int a=Integer.parseInt(s[0]);
			int b=Integer.parseInt(s[1]);
			int min=(int)Math.min(a, b);
			int max=(int)Math.max(a, b);
			int c=gcd(max,min);
			if(c==1)
				System.out.println("Finite");
			else
				System.out.println("Infinite");

		}
				}

	static int gcd(int a,int b) {
		if(a%b==0)
			return b;
		return gcd(b,a%b);
	}
	}


public class daniel {

	public static void main(String args[]) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

		int t=Integer.parseInt(br.readLine());
		while(t-->0) {
			String s[]=br.readLine().split("\\ ");
			int a=Integer.parseInt(s[0]);
			int b=Integer.parseInt(s[1]);
			int min=(int)Math.min(a, b);
			int max=(int)Math.max(a, b);
			int c=gcd(max,min);
			if(c==1)
				System.out.println("Finite");
			else
				System.out.println("Infinite");

		}
				}

	static int gcd(int a,int b) {
		if(a%b==0)
			return b;
		return gcd(b,a%b);
	}
	}


import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) {
        InputReader cin = new InputReader(System.in);
        PrintWriter cout = new PrintWriter(System.out);
        int t = cin.nextInt();
        while(t-->0) {
        	int a = cin.nextInt(), b = cin.nextInt();
        	if(gcd(a, b) == 1)
        		cout.println("Finite");
        	else
        		cout.println("Infinite");
        }
        cout.flush();
        cout.close();
    }

    static long gcd(long a, long b) {
    	return b==0? a : gcd(b, a % b);
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}


import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader cin = new InputReader(inputStream);
        PrintWriter cout = new PrintWriter(outputStream);
        int t = cin.nextInt();
        while(t-->0) {
        	int a = cin.nextInt(), b = cin.nextInt();
        	if(gcd(a, b) != 1)
        		cout.println("Finite");
        	else
        		cout.println("Infinite");
        }
    }

    static long gcd(long a, long b) {
    	return b==0? a : gcd(b, a % b);
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author shivam
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task6 solver = new Task6();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task6 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int t = in.nextInt();
            while (t-- > 0) {
                int n = in.nextInt();
                int m = in.nextInt();
                if (gcd(n, m) == 1) {
                    out.println("Finite");
                } else {
                    out.println("Infinite");
                }
            }
        }

        static int gcd(int a, int b) {
            if (b == 0)
                return a;
            return gcd(b, a % b);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.util.Scanner;

/**
 * Created by codancer on 2019.11.2.
 **/
public class TaskA {
    static int [] color =  new int [100000];
    public static int gcd(int a,int b){
        if(b==0) return a;
        return gcd(b,a%b);
    }
    public static void main(String [] args){
        int a,b,T;
        Scanner cin = new Scanner(System.in);
        T=cin.nextInt();
        while(T-->0){
            a=cin.nextInt();
            b=cin.nextInt();
            if(gcd(a,b)==1){
                System.out.println("Finite");
            }else{
                System.out.println("Infinite");
            }
        }
    }
}


import java.awt.desktop.SystemEventListener;
import java.util.Scanner;

/**
 * Created by codancer on 2019.11.2.
 **/
public class TaskA {
    static int [] color =  new int [100000];
    public static int gcd(int a,int b){
        if(b==0) return a;
        return gcd(b,a%b);
    }
    public static void main(String [] args){
        int a,b,T;
        Scanner cin = new Scanner(System.in);
        T=cin.nextInt();
        while(T-->0){
            a=cin.nextInt();
            b=cin.nextInt();
            if(gcd(a,b)==1){
                System.out.println("Finite");
            }else{
                System.out.println("Infinite");
            }
        }
    }
}


import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Scanner;

public class Main{
	static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }

	public static void main(String[] args) throws IOException {
		Reader s=new Reader();
		int t= s.nextInt();
		for(int y=0; y<t; ++y) {
			int a=s.nextInt();
			int b= s.nextInt();
			int min= Math.min(a, b);
			int size= a*b;
			boolean arr[]= new boolean[size+1];
			arr[0]= true;
			int cont=0;
			int flag=0;
			for(int i=1; i<=size; ++i) {
				if(i>=a && (i-a)>=0 && arr[i-a]==true) {
					arr[i]=true;
					cont++;
				}
				else if(i>=b && (i-b)>=0 && arr[i-b]==true) {
					arr[i]=true;
					cont++;
				}
				else {
					arr[i]= false;
					cont=0;
				}
				if(cont>=min) {
					System.out.println("Finite");
					flag=1;
					break;
				}
			}
			if(flag==0) {
				System.out.println("Infinite");
			}
		}

	}
}


import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Scanner;

public class Main{
	static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }

	public static int gcd(int num1, int num2) {
		int gcd=1;
		for(int i = 1; i <= num1 && i <= num2; i++)
        {
            if(num1%i==0 && num2%i==0)
                gcd = i;
        }
		return gcd;
	}
	public static void main(String[] args) throws IOException {
		Reader s=new Reader();
		int t= s.nextInt();
		for(int y=0; y<t; ++y) {
			int a=s.nextInt();
			int b= s.nextInt();
			int gcd= gcd(a,b);
			if(gcd!=1) {
				System.out.println("Infinite");
			}
			else
				System.out.println("Finite");
		}

	}
}


import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Scanner;

public class Main2 {
	static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }

	public static void main(String[] args) throws IOException {
		Reader s=new Reader();
		int t= s.nextInt();
		for(int y=0; y<t; ++y) {
			int a=s.nextInt();
			int b= s.nextInt();
			int min= Math.min(a, b);
			int size= Math.min(a*b, 10000000);
			boolean arr[]= new boolean[size+1];
			arr[0]= true;
			int cont=0;
			int flag=0;
			for(int i=1; i<=size; ++i) {
				if(i>=a && (i-a)>=0 && arr[i-a]==true) {
					arr[i]=true;
					cont++;
				}
				else if(i>=b && (i-b)>=0 && arr[i-b]==true) {
					arr[i]=true;
					cont++;
				}
				else {
					arr[i]= false;
					cont=0;
				}
				if(cont>=min) {
					System.out.println("Finite");
					flag=1;
					break;
				}
			}
			if(flag==0) {
				System.out.println("Infinite");
			}
		}

	}
}


import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Scanner;

public class Main{
	static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }

	public static void main(String[] args) throws IOException {
		Reader s=new Reader();
		int t= s.nextInt();
		for(int y=0; y<t; ++y) {
			int a=s.nextInt();
			int b= s.nextInt();
			int min= Math.min(a, b);
			int size= Math.min(a*b, 100000000);
			boolean arr[]= new boolean[size+1];
			arr[0]= true;
			int cont=0;
			int flag=0;
			for(int i=1; i<=size; ++i) {
				if(i>=a && (i-a)>=0 && arr[i-a]==true) {
					arr[i]=true;
					cont++;
				}
				else if(i>=b && (i-b)>=0 && arr[i-b]==true) {
					arr[i]=true;
					cont++;
				}
				else {
					arr[i]= false;
					cont=0;
				}
				if(cont>=min) {
					System.out.println("Finite");
					flag=1;
					break;
				}
			}
			if(flag==0) {
				System.out.println("Infinite");
			}
		}

	}
}


import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Scanner;

public class Main {
	static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }

	public static void main(String[] args) throws IOException {
		Reader s=new Reader();
		int t= s.nextInt();
		for(int y=0; y<t; ++y) {
			int a=s.nextInt();
			int b= s.nextInt();
			int min= Math.min(a, b);
			int size= Math.min(a*b, 1000000);
			boolean arr[]= new boolean[size+1];
			arr[0]= true;
			int cont=0;
			int flag=0;
			for(int i=1; i<=size; ++i) {
				if(i>=a && (i-a)>=0 && arr[i-a]==true) {
					arr[i]=true;
					cont++;
				}
				else if(i>=b && (i-b)>=0 && arr[i-b]==true) {
					arr[i]=true;
					cont++;
				}
				else {
					arr[i]= false;
					cont=0;
				}
				if(cont>=min) {
					System.out.println("Finite");
					flag=1;
					break;
				}
			}
			if(flag==0) {
				System.out.println("Infinite");
			}
		}

	}
}


import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner s= new Scanner(System.in);
		int t= s.nextInt();
		for(int y=0; y<t; ++y) {
			int n= s.nextInt();
			double x= (double)n/2;
			int r= s.nextInt();
			int p=s.nextInt();
			int sc= s.nextInt();
			String bob= s.next();
			int count=0;
			int br=0;
			int bp=0;
			int bs=0;
			for(int i=0; i<bob.length(); ++i) {
				if(bob.charAt(i)=='R') {
					br++;
				}
				else if(bob.charAt(i)=='P') {
					bp++;
				}
				else {
					bs++;
				}
			}
			if(p>0 && br>0)
				count+=Math.min(p,br);
			if(sc>0 && bp>0)
				count+=Math.min(sc, bp);
			if(r>0 && bs>0)
				count+=Math.min(r, bs);
			String ans="";
			//System.out.println(count+" "+ Math.ceil(x));
			if(count>= Math.ceil(x)) {
			for(int i=0; i<bob.length(); ++i) {
				if(bob.charAt(i)=='R') {
					br--;
					if(p>0) {
						p--;
						ans+="P";
					}
					else {
						if(r>bs) {
							ans+="R";
							r--;
						}
						else {
							ans+="S";
							sc--;
						}
					}
				}
				else if(bob.charAt(i)=='P') {
					bp--;
					if(sc>0) {
						sc--;
						ans+="S";
					}
					else {
						if(r>bs) {
							ans+="R";
							r--;
						}
						else {
							ans+="P";
							p--;
						}
					}
				}
				else {
					bs--;
					if(r>0) {
						r--;
						ans+="R";
					}
					else {
						if(p>br) {
							ans+="P";
							p--;
						}
						else  {
							ans+="S";
							sc--;
						}

					}
				}

			}
				System.out.println("YES");
				System.out.println(ans);

			}
			else {
				System.out.println("NO");
			}

		}
	}
}


import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner s= new Scanner(System.in);
		int t= s.nextInt();
		for(int y=0; y<t; ++y) {
			int a=s.nextInt();
			int b= s.nextInt();
			int min= Math.min(a, b);
			int size= a*b;
			boolean arr[]= new boolean[size+1];
			arr[0]= true;
			int cont=0;
			int flag=0;
			for(int i=1; i<=size; ++i) {
				if(i>=a && (i-a)>=0 && arr[i-a]==true) {
					arr[i]=true;
					cont++;
				}
				else if(i>=b && (i-b)>=0 && arr[i-b]==true) {
					arr[i]=true;
					cont++;
				}
				else {
					arr[i]= false;
					cont=0;
				}
				if(cont>=min) {
					System.out.println("Finite");
					flag=1;
					break;
				}
			}
			if(flag==0) {
				System.out.println("Infinite");
			}
		}

	}
}


#include<iostream>

using namespace std;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

int main () {
    int a, b, n;
    cin >> n;
    while (n--) {
    cin >> a >> b;
        if (gcd(a, b) == 1) {
            cout << "finite" << endl;
        } else {
            cout << "infinite" << endl;
        }
    }
   return 0;
}


#include <iostream>
#include <unordered_set>
using namespace std;

int primes[] = {2,3,5,7,11,13,17,19,23,29,31,37,41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199};

unordered_set<int> facs(int A) {
	unordered_set<int> retval;
	for (auto prime : primes) {
		if (A % prime == 0) retval.insert(prime);
		while (A % prime == 0) A /= prime;
	}
	return retval;
}

int main() {
	int T;
	cin >> T;
	while (T--) {
		int A,B;
		cin >> A >> B;
		if (A == 1 || B == 1) {
			cout << "finite" << endl;
			continue;
		}
		if (A > B) {
			int temp = A;
			A = B;
			B = temp;
		}
		if (B % A == 1) {
			cout << "finite" << endl;
		} else {
			cout << "infinite" << endl;
		}
	}
	return 0;
}


  var lines = parseInt(readline(), 10);

  function gcd(a, b) {
    while (true) {
      if (b === 0) return a;
      a %= b;
      if (a === 0) return b;
      b %= a;
    }
  }

  for (var i = 0; i < lines; i++) {
    var ab = readline()
      .split(" ")
      .map(function(value) {
        return parseInt(value);
      })
      .sort();

    print(gcd(ab[0], ab[1]) > 1 ? "Infinite" : "Finite");
  }


// Example program
#include <iostream>
#include <string>
using namespace std;
int nod(int a,int b){
    if(b==0)
    return a;
    else
    return nod(b,b%a);
}
int main()
{
   int n,a,b;
   cin>>n;
   for(int i=0;i<n;i++){
     cin>>a>>b;
     if(a==1||b==1)
     cout<<"finite"<<endl;
     else if(nod(min(a,b),max(a,b))!=1)
     cout<<"Infinite"<<endl;
     else
     cout<<"Finite"<<endl;

   }

  return 0;
}


// Example program
#include <iostream>
#include <string>
using namespace std;
int nod(int a,int b){
    if(b==0)
    return a;
    nod(b,b%a);
}
int main()
{
   int n,a,b;
   cin>>n;
   for(int i=0;i<n;i++){
     cin>>a>>b;
     if(a==1||b==1)
     cout<<"finite"<<endl;
     else if(nod(a,b)!=1)
     cout<<"Infinite"<<endl;
     else
     cout<<"Finite"<<endl;

   }

  return 0;
}


// Example program
#include <iostream>
#include <string>
using namespace std;
int nod(int a,int b){
    if(b==0)
    return a;
    nod(b,b%a);
}
int main()
{
   int n,a,b;
   cin>>n;
   for(int i=0;i<n;i++){
     cin>>a>>b;
     if(a==1||b==1)
     cout<<"Infinite";
     else if(nod(a,b)==1)
     cout<<"Infinite";
     else
     cout<<"Finite";

   }

  return 0;
}


// Example program
#include <iostream>
#include <string>
using namespace std;
int nod(int a,int b){
    if(b==0)
    return a;
    else
    return nod(b,a%b);
}
int main()
{
   int n,a,b;
   cin>>n;
   for(int i=0;i<n;i++){
     cin>>a>>b;
     if(a==1||b==1)
     cout<<"finite"<<endl;
     else if(nod(min(a,b),max(a,b))!=1){
     cout<<"Infinite"<<endl;
     }
     else
     cout<<"Finite"<<endl;

   }

  return 0;
}


// Example program
#include <iostream>
#include <string>
using namespace std;
int nod(int a,int b){
    if(b==0)
    return a;
    nod(b,b%a);
}
int main()
{
   int n,a,b;
   cin>>n;
   for(int i=0;i<n;i++){
     cin>>a>>b;
     if(a==1||b==1)
     cout<<"finite"<<endl;
     else if(nod(min(a,b),max(a,b))!=1){
     cout<<"Infinite"<<endl;
     cout<<nod(a,b);
     }
     else
     cout<<"Finite"<<endl;

   }

  return 0;
}


// Example program
#include <iostream>
#include <string>
using namespace std;
int nod(int a,int b){
    if(b==0)
    return a;
    nod(b,b%a);
}
int main()
{
   int n,a,b;
   cin>>n;
   for(int i=0;i<n;i++){
     cin>>a>>b;
     if(a==1||b==1)
     cout<<"finite"<<endl;
     else if(nod(min(a,b),max(a,b))!=1){
     cout<<"Infinite"<<endl;

     }
     else
     cout<<"Finite"<<endl;

   }

  return 0;
}


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


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t, a, b, i;
    cin >> t;
    while(t--)
    {
        bool flag = false;
        cin >> a >> b;
        if(a == b)
            cout << "Infinite" << endl;
        else
        {
            for(i = 2; i <= sqrt(max(a, b)); i++)
            {
                if(a%i == 0 && b%i == 0)
                    flag = true;
            }
            if(flag)
                cout << "Infinte" << endl;
            else
                cout << "Finite" << endl;
        }
    }
}


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


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


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


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


#include<bits/stdc++.h>
using namespace std;

int main()
{
    long long int t;
    cin>>t;
    while(t--)
    {
        long long int aa[100005]={0};

        long long int a,b,i;
        cin>>a>>b;

        long long int ct=0;
        aa[0]=1;
        for(i=1;i<100005;i++)
        {
            if(i-a>=0&&aa[i-a]==1)
                aa[i]=1;
            else if(i-b>=0&&aa[i-b]==1)
                aa[i]=1;
            else
                ct++;
        }

        if(ct>1000)
            cout<<"Infinite\n";
        else
            cout<<"Finite\n";
    }
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    long long int t;
    cin>>t;
    while(t--)
    {
       /* long long int n;
        cin>>n;

        long long int rock,paper,scissor;

        cin>>rock>>paper>>scissor;

        string s;
        cin>>s;

        long long int s_r=0,s_p=0,s_s=0;

        for(i=0;i<n;i++)
        {
            if(s[i]=='R')
                s_r++;
            else if(s[i]=='P')
                s_p++;
            else
                s_s++;
        }

        long long int wins=min()*/

        long long int a,b;
        cin>>a>>b;

        if(__gcd(a,b)==1)
            cout<<"Finite\n";
        else
            cout<<"Infinite\n";
    }
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    long long int t;
    cin>>t;
    while(t--)
    {
        long long int aa[100005]={0};

        long long int a,b,i;
        cin>>a>>b;

        long long int ct=0;
        aa[0]=1;
        for(i=1;i<100005;i++)
        {
            if(i-a>=0&&aa[i-a]==1)
                aa[i]=1;
            else if(i-b>=0&&aa[i-b]==1)
                aa[i]=1;
            else
                ct++;
        }

        if(ct>=100000/4)
            cout<<"Infinite\n";
        else
            cout<<"Finite\n";
    }
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    long long int t;
    cin>>t;
    while(t--)
    {
        long long int aa[100005]={0};

        long long int a,b,i;
        cin>>a>>b;

        long long int ct=0;
        aa[0]=1;
        for(i=1;i<100005;i++)
        {
            if(i-a>=0&&aa[i-a]==1)
                aa[i]=1;
            else if(i-b>=0&&aa[i-b]==1)
                aa[i]=1;
            else
                ct++;
        }

        if(ct>10000)
            cout<<"Infinite\n";
        else
            cout<<"Finite\n";
    }
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    long long int t;
    cin>>t;
    while(t--)
    {
        long long int a,b;
        cin>>a>>b;

        long long int x=1,y=1;

        long long int ct=100000;
        while((x*a)<=100000||(y*b)<=100000)
        {
            if(x*a<y*b)
            {
                ct--;
                x++;
            }
            else if(x*a>y*b)
            {
                ct--;
                y++;
            }
            else
            {
                ct--;
                x++;
                y++;
            }
        }

        if(ct>=75000)
            cout<<"Infinite\n";
        else
            cout<<"Finite\n";
    }
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    long long int t;
    cin>>t;
    while(t--)
    {
        long long int aa[100005]={0};

        long long int a,b,i;
        cin>>a>>b;

        long long int ct=0;
        aa[0]=1;
        for(i=1;i<100005;i++)
        {
            if(i-a>=0&&aa[i-a]==1)
                aa[i]=1;
            else if(i-b>=0&&aa[i-b]==1)
                aa[i]=1;
            else
                ct++;
        }

        if(ct>=100000/2)
            cout<<"Infinite\n";
        else
            cout<<"Finite\n";
    }
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mod 1000000007
bool arr[10000000];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin>>t;
    while(t--)
    {
        int a,b;
        cin>>a>>b;
        memset(arr,0,sizeof(arr));
        arr[0]=true; // that is 0th ball is white....
        for(int i=1;i<10000000;i++)
        {
            if(i>=a)
            {
                if(arr[i-a]==true)
                   arr[i]=true;
            }
            if(i>=b)
            {
                if(arr[i-b]==true)
                   arr[i]=true;
            }
        }
        int freq=0;
        int flag=1;
        for(int i=0;i<10000000;i++)
        {
            if(arr[i])
            {
                freq++;
                if(freq==min(a,b))
                   flag=0;  //which means black is finite...iske aage jitne bhi ball hain vo saare ke saare white hain
            }
            else
               freq=0;
        }
        if(flag)
           cout<<"infinite"<<"\n";
        else
          cout<<"finite"<<"\n";
    }

    return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mod 1000000007

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin>>t;
    while(t--)
    {
        int a,b;
        cin>>a>>b;
        if(__gcd(a, b)==1)
           cout<<"finite"<<"\n";
        else
           cout<<"infinite"<<"\n";
    }

    return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mod 1000000007

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin>>t;
    while(t--)
    {
        int a,b;
        cin>>a>>b;
        bool arr[5000000];
        memset(arr,0,sizeof(arr));
        arr[0]=true; // that is 0th ball is white....
        for(int i=1;i<5000000;i++)
        {
            if(i>=a)
            {
                if(arr[i-a]==true)
                   arr[i]=true;
            }
            if(i>=b)
            {
                if(arr[i-b]==true)
                   arr[i]=true;
            }
        }
        int freq=0;
        int flag=1;
        for(int i=0;i<5000000;i++)
        {
            if(arr[i])
            {
                freq++;
                if(freq==min(a,b))
                   flag=0;  //which means black is finite...iske aage jitne bhi ball hain vo saare ke saare white hain
            }
            else
               freq=0;
        }
        if(flag)
           cout<<"infinite"<<"\n";
        else
          cout<<"finite"<<"\n";
    }

    return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mod 1000000007

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin>>t;
    while(t--)
    {
        int a,b;
        cin>>a>>b;
        int arr[100000];
        memset(arr,0,sizeof(arr));
        arr[0]=1; // which means 0 is white...
        for(int i=1;i<100000;i++)
        {
            if(i>=a)
            {
                if(arr[i-a]==1)
                   arr[i]=1;
            }
            if(i>=b)
            {
                if(arr[i-b]==1)
                   arr[i]=1;
            }
        }
        int consecutive=min(a,b);
        int freq=0;
        int flag=0;  // black infinite hai...
        for(int i=0;i<100000;i++)
        {
            if(arr[i]==1)
            {
                freq++;
                if(freq==consecutive)
                {
                    flag=1; // iske baad tu saare white he hooge...
                    break;
                }
            }
            else
            {
                freq=0;
            }
        }
        if(flag)
           cout<<"finite"<<"\n";
        else
          cout<<"infinite"<<"\n";

    }

    return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mod 1000000007
bool arr[100000000];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin>>t;
    while(t--)
    {
        int a,b;
        cin>>a>>b;
        memset(arr,0,sizeof(arr));
        arr[0]=true; // that is 0th ball is white....
        for(int i=1;i<100000000;i++)
        {
            if(i>=a)
            {
                if(arr[i-a]==true)
                   arr[i]=true;
            }
            if(i>=b)
            {
                if(arr[i-b]==true)
                   arr[i]=true;
            }
        }
        int freq=0;
        int flag=1;
        for(int i=0;i<100000000;i++)
        {
            if(arr[i])
            {
                freq++;
                if(freq==min(a,b))
                   flag=0;  //which means black is finite...iske aage jitne bhi ball hain vo saare ke saare white hain
            }
            else
               freq=0;
        }
        if(flag)
           cout<<"infinite"<<"\n";
        else
          cout<<"finite"<<"\n";
    }

    return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mod 1000000007

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin>>t;
    while(t--)
    {
        int a,b;
        cin>>a>>b;
        int arr[100000];
        memset(arr,0,sizeof(arr));
        arr[0]=1; // which means 0 is white...
        for(int i=1;i<100000;i++)
        {
            if(i>=a)
            {
                if(arr[i-a]==1)
                   arr[i]=1;
            }
            if(i>=b)
            {
                if(arr[i-b]==1)
                   arr[i]=1;
            }
        }
        int consecutive=max(a,b);
        int freq=0;
        int flag=0;  // black infinite hai...
        for(int i=0;i<10000;i++)
        {
            if(arr[i]==1)
            {
                freq++;
                if(freq==consecutive)
                {
                    flag=1; // iske baad tu saare white he hooge...
                    break;
                }
            }
            else
            {
                freq=0;
            }
        }
        if(flag)
           cout<<"finite"<<"\n";
        else
          cout<<"infinite"<<"\n";

    }

    return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mod 1000000007

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin>>t;
    while(t--)
    {
        int a,b;
        cin>>a>>b;
        int arr[100000];
        memset(arr,0,sizeof(arr));
        arr[0]=1; // which means 0 is white...
        for(int i=1;i<100000;i++)
        {
            if(i>=a)
            {
                if(arr[i-a]==1)
                   arr[i]=1;
            }
            if(i>=b)
            {
                if(arr[i-b]==1)
                   arr[i]=1;
            }
        }
        int consecutive=min(a,b);
        int freq=0;
        int flag=0;  // black infinite hai...
        for(int i=0;i<10000;i++)
        {
            if(arr[i]==1)
            {
                freq++;
                if(freq==consecutive)
                {
                    flag=1; // iske baad tu saare white he hooge...
                    break;
                }
            }
            else
            {
                freq=0;
            }
        }
        if(flag)
           cout<<"finite"<<"\n";
        else
          cout<<"infinite"<<"\n";

    }

    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    ll t;
    cin>>t;
    while(t--)
    {
        ll a,b;
        cin>>a>>b;
        if(a==1)
        {
            cout<<"Finite"<<endl;

        }
        else if((2*a)<(b))
        {
            cout<<"Finite"<<endl;

        }
        else if(a>(2*b))
        {
            cout<<"Finite"<<endl;

        }
        else
        {
            cout<<"Infinite"<<endl;
        }

    }
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    ll t;
    cin>>t;
    while(t--)
    {
        ll a,b;
        cin>>a>>b;
        if(__gcd(a,b)==1)
        cout<<"Finite"<<endl;
        else
        {
            cout<<"Infinite"<<endl;
        }

    }
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    ll t;
    cin>>t;
    while(t--)
    {
        ll a,b;
        cin>>a>>b;
        if(a==1 || abs(a-b)==1)
        {
            cout<<"Finite"<<endl;

        }
        else if((2*a)<(b) && b%a!=0)
        {
            cout<<"Finite"<<endl;

        }
        else if(a>(2*b) && a%b!=0)
        {
            cout<<"Finite"<<endl;

        }
        else
        {
            cout<<"Infinite"<<endl;
        }

    }
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    ll t;
    cin>>t;
    while(t--)
    {
        ll a,b;
        cin>>a>>b;
        if(a>b || (a==1))
        cout<<"Finite"<<endl;
        else
        {
            cout<<"Infinite"<<endl;
        }

    }
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    ll t;
    cin>>t;
    while(t--)
    {
        ll a,b;
        cin>>a>>b;
        if((2*a)<(b))
        {
            cout<<"Finite"<<endl;

        }
        else if(a>(2*b))
        {
            cout<<"Finite"<<endl;

        }
        else
        {
            cout<<"Infinite"<<endl;
        }

    }
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    ll t;
    cin>>t;
    while(t--)
    {
        ll a,b;
        cin>>a>>b;
        if(a==1)
        {
            cout<<"Finite"<<endl;

        }
        else if((2*a)<(b) && b%a!=0)
        {
            cout<<"Finite"<<endl;

        }
        else if(a>(2*b) && a%b!=0)
        {
            cout<<"Finite"<<endl;

        }
        else
        {
            cout<<"Infinite"<<endl;
        }

    }
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    ll t;
    cin>>t;
    while(t--)
    {
        ll a,b;
        cin>>a>>b;
        if(a==1 || b==1 || abs(a-b)==1)
        {
            cout<<"Finite"<<endl;

        }
        else if((2*a)<(b) && b%a!=0)
        {
            cout<<"Finite"<<endl;

        }
        else if(a>(2*b) && a%b!=0)
        {
            cout<<"Finite"<<endl;

        }
        else
        {
            cout<<"Infinite"<<endl;
        }

    }
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    ll t;
    cin>>t;
    while(t--)
    {
        ll a,b;
        cin>>a>>b;
        if(a>(2*b) || (a==1))
        cout<<"Finite"<<endl;
        else
        {
            cout<<"Infinite"<<endl;
        }

    }
}


#include <bits/stdc++.h>
using namespace std;
long long n,m,x,y,z;

int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n;
    while(n--){
        int arr[100005] = {0};
        cin>>x>>y;
        arr[0] = 1;
        z=0;
        for(int i=1  ; i<=100000 ; i++){
            if((i>=x && arr[i-x] == 1) || (i>=y  && arr[i-y] ==1))
                arr[i] = 1;
         }
         for(int i=100000 ; i>=90000 ; i--){
            if(arr[i] == 0){z=1; break;}
         }
        if(z==0 || abs(x-y) == 1)
            cout<<"Finite\n";
        else
            cout<<"Infinite\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
long long n,m,x,y,z;

int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n;
    while(n--){
        int arr[100005] = {0};
        cin>>x>>y;
        arr[0] = 1;
        z=0;
        for(int i=1  ; i<=100000 ; i++){
            if((i>=x && arr[i-x] == 1) || (i>=y  && arr[i-y] ==1))
                arr[i] = 1;
         }
         for(int i=100000 ; i>=90000 ; i--){
            if(arr[i] == 0){z=1; break;}
         }
        if(z==0)
            cout<<"Finite\n";
        else
            cout<<"Infinite\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
long long n,m,x,y,z;

int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n;
    while(n--){

        cin>>x>>y;
        if(__gcd(x,y) == 1)
            cout<<"Finite\n";
        else
            cout<<"Infinite\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
long long n,m,x,y,z;
bool prime(int a){
    if(a==2) return true;
    for(int i=2 ; i*i<=a; i++){
        if(a%i == 0) return false;
    }
    return true;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n;
    while(n--){
        cin>>x>>y;
        if((prime(x) == true && prime(y) == true) || x == 1 || y == 1)
            cout<<"Finite\n";
        else
            cout<<"Infinite\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
long long n,m,x,y,z;

int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n;
    while(n--){
        int arr[10000] = {0};
        cin>>x>>y;
        arr[0] = 1;
        z=0;
        for(int i=1  ; i<=10000 ; i++){
            if((i>=x && arr[i-x] == 1) || (i>=y  && arr[i-y] ==1))
                arr[i] = 1;
         }
         for(int i=10000 ; i>=9000 ; i--){
            if(arr[i] == 0){z=1; break;}
         }
        if(z==0)
            cout<<"Finite\n";
        else
            cout<<"Infinite\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
long long n,m,x,y,z;

int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n;
    while(n--){
        int arr[10000] = {0};
        cin>>x>>y;
        arr[0] = 1;
        z=0;
        for(int i=1  ; i<=100000 ; i++){
            if((i>=x && arr[i-x] == 1) || (i>=y  && arr[i-y] ==1))
                arr[i] = 1;
         }
         for(int i=100000 ; i>=90000 ; i--){
            if(arr[i] == 0){z=1; break;}
         }
        if(z==0)
            cout<<"Finite\n";
        else
            cout<<"Infinite\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
long long n,m,x,y,z;
bool prime(int a){
    if(a==2) return true;
    for(int i=2 ; i*i<=a; i++){
        if(a%i == 0) return false;
    }
    return true;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n;
    while(n--){
        cin>>x>>y;
        if((prime(x) == true || prime(y) == true) || x == 1 || y == 1)
            cout<<"Finite\n";
        else
            cout<<"Infinite\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
long long n,m,x,y,z;

int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n;
    while(n--){
        cin>>x>>y;
        if((x%2 == 1 && y%2 == 1) || x == 1 || y == 1)
            cout<<"Finite\n";
        else
            cout<<"Infinite\n";
    }
    return 0;
}