You are given several queries. Each query consists of three integers p, q and b. You need to answer whether the result of p/q in notation with base b is a finite fraction.

A fraction in notation with base b is finite if it contains finite number of numerals after the decimal point. It is also possible that a fraction has zero numerals after the decimal point.

Input

The first line contains a single integer n (1 ≤ n ≤ 10^5) — the number of queries.

Next n lines contain queries, one per line. Each line contains three integers p, q, and b (0 ≤ p ≤ 10^{18}, 1 ≤ q ≤ 10^{18}, 2 ≤ b ≤ 10^{18}). All numbers are given in notation with base 10.

Output

For each question, in a separate line, print Finite if the fraction is finite and Infinite otherwise.

Examples

Input

2
6 12 10
4 3 10


Output

Finite
Infinite


Input

4
1 1 2
9 36 2
4 12 3
3 5 4


Output

Finite
Finite
Finite
Infinite

Note

6/12 = 1/2 = 0,5_{10}

4/3 = 1,(3)_{10}

9/36 = 1/4 = 0,01_2

4/12 = 1/3 = 0,1_3 
								import java.io.BufferedReader;
	import java.io.IOException;
	import java.io.InputStream;
	import java.io.InputStreamReader;
	import java.io.PrintWriter;
	import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
	import java.util.Iterator;
	
												public class Solution1 implements Runnable
												{
													static final long MAX = 1000000007L;
													static class InputReader
													{
														private InputStream stream;
														private byte[] buf = new byte[1024];
														private int curChar;
														private int numChars;
														private SpaceCharFilter filter;
														private BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
												 
														public InputReader(InputStream stream)
														{
															this.stream = stream;
														}
														
														public int read()
														{
															if (numChars==-1) 
																throw new InputMismatchException();
															
															if (curChar >= numChars)
															{
																curChar = 0;
																try 
																{
																	numChars = stream.read(buf);
																}
																catch (IOException e)
																{
																	throw new InputMismatchException();
																}
																
																if(numChars <= 0)				
																	return -1;
															}
															return buf[curChar++];
														}
													 
														public String nextLine()
														{
															String str = "";
												            try
												            {
												                str = br.readLine();
												            }
												            catch (IOException e)
												            {
												                e.printStackTrace();
												            }
												            return str;
														}
														public int nextInt()
														{
															int c = read();
															
															while(isSpaceChar(c)) 
																c = read();
															
															int sgn = 1;
															
															if (c == '-') 
															{
																sgn = -1;
																c = read();
															}
															
															int res = 0;
															do 
															{
																if(c<'0'||c>'9') 
																	throw new InputMismatchException();
																res *= 10;
																res += c - '0';
																c = read();
															}
															while (!isSpaceChar(c)); 
															
															return res * sgn;
														}
														
														public long nextLong() 
														{
															int c = read();
															while (isSpaceChar(c))
																c = read();
															int sgn = 1;
															if (c == '-') 
															{
																sgn = -1;
																c = read();
															}
															long res = 0;
															
															do 
															{
																if (c < '0' || c > '9')
																	throw new InputMismatchException();
																res *= 10;
																res += c - '0';
																c = read();
															}
															while (!isSpaceChar(c));
																return res * sgn;
														}
														
														public double nextDouble() 
														{
															int c = read();
															while (isSpaceChar(c))
																c = read();
															int sgn = 1;
															if (c == '-') 
															{
																sgn = -1;
																c = read();
															}
															double res = 0;
															while (!isSpaceChar(c) && c != '.') 
															{
																if (c == 'e' || c == 'E')
																	return res * Math.pow(10, nextInt());
																if (c < '0' || c > '9')
																	throw new InputMismatchException();
																res *= 10;
																res += c - '0';
																c = read();
															}
															if (c == '.') 
															{
																c = read();
																double m = 1;
																while (!isSpaceChar(c)) 
																{
																	if (c == 'e' || c == 'E')
																		return res * Math.pow(10, nextInt());
																	if (c < '0' || c > '9')
																		throw new InputMismatchException();
																	m /= 10;
																	res += (c - '0') * m;
																	c = read();
																}
															}
															return res * sgn;
														}
														
														public String readString() 
														{
															int c = read();
															while (isSpaceChar(c))
																c = read();
															StringBuilder res = new StringBuilder();
															do 
															{
																res.appendCodePoint(c);
																c = read();
															} 
															while (!isSpaceChar(c));
															
															return res.toString();
														}
													 
														public boolean isSpaceChar(int c) 
														{
															if (filter != null)
																return filter.isSpaceChar(c);
															return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
														}
													 
														public String next() 
														{
															return readString();
														}
														
														public interface SpaceCharFilter 
														{
															public boolean isSpaceChar(int ch);
														}
													}
												 	
													public static void main(String args[]) throws Exception
													{
														new Thread(null, new Solution1(),"Solution",1<<26).start();
													}
														
													public static int gcd(int a, int b)
												    {
												        if (a == 0)
												            return b;
												         
												        return gcd(b%a, a);
												    }
													int lcm(int a, int b)
													{
													    return (a*b)/gcd(a, b);
													}
													boolean[][] bits;
													ArrayList<Integer> adj[];
													long[] val;
													int[] depth;
													int[][] parent;
													boolean[] visited;
													int level = 20;
													int root = 1;
													public void run() 
													{
														InputReader sc= new InputReader(System.in);
														PrintWriter w= new PrintWriter(System.out);
														int t = sc.nextInt();
														while(t-- > 0) {
															long n = sc.nextLong();
															long m = sc.nextLong();
															long b = sc.nextLong();
															if(n == 0) {
																w.println("Finite");
															}else {
																long gcd = gcd(n,m);
																if(gcd != 1) {
																	n = n/gcd;
																	m = m/gcd;
																	
																}
																if(isValid(b,m) ) {
																	w.println("Finite");
																}else {
																	w.println("Infinite");
																}
															}
														}
													
														w.close(); 
													}
													 static boolean isValid(long x, long y)
													    {
													        if (y == 1)
													            return true;
													             
													        long z = gcd(x, y);
													        
													        if(z == 1) {
													        	return false;
													        }
													        while(y % z == 0) {
													        	y = y/z;
													        }
													        return isValid(x, y);
													    }
													 
													 public static long gcd(long a, long b)
													    {
													        if (a == 0)
													            return b;
													         
													        return gcd(b%a, a);
													    }
													int check(char[][] ch,int i,int j,int n,int m) {
														int count = 0;
														if(i + 1 < n) {
															if(ch[i+1][j] == '*') {
																count++;
															}
														}if(i - 1 >= 0) {

															if(ch[i-1][j] == '*') {
																count++;
															}
														}if(i + 1 < n && j + 1 < m) {
															if(ch[i+1][j+1] == '*') {
																count++;
															}
														}if(i + 1 < n && j - 1 >= 0) {
															if(ch[i+1][j-1] == '*') {
																count++;
															}
														}if(j + 1 < m) {
															if(ch[i][j+1] == '*') {
																count++;
															}
														}if(j - 1 >= 0) {
															if(ch[i][j-1] == '*') {
																count++;
															}
														}if(i - 1 >= 0 && j + 1 < m) {
															if(ch[i-1][j+1] == '*') {
																count++;
															}
														}if(i - 1 >= 0 && j - 1 >= 0) {
															if(ch[i-1][j-1] == '*') {
																count++;
															}
														}
														return count;
													}
													static class Pair implements Comparable<Pair>{
														int x;
														int y;
														
														Pair(){}	
														Pair(int x,int y){
															this.x = x;
															this.y = y;
															
														}
														public int compareTo(Pair p){
															if(p.x == this.x) {
																return Long.compare(this.y,p.y);
															}
															return Long.compare(this.x,p.x);
														}
													}
													
									}