codeforces#P983A. Finite or not?
Finite or not?
Description
You are given several queries. Each query consists of three integers , and . You need to answer whether the result of in notation with base is a finite fraction.
A fraction in notation with base 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.
The first line contains a single integer () — the number of queries.
Next lines contain queries, one per line. Each line contains three integers , , and (, , ). All numbers are given in notation with base .
For each question, in a separate line, print Finite if the fraction is finite and Infinite otherwise.
Input
The first line contains a single integer () — the number of queries.
Next lines contain queries, one per line. Each line contains three integers , , and (, , ). All numbers are given in notation with base .
Output
For each question, in a separate line, print Finite if the fraction is finite and Infinite otherwise.
Samples
Note