func_code_string: #include <bits/stdc++.h>   using namespace std;   long long max(long long x, long long y) { return x > y ? x : y; }   long long min(long long x, long long y) { return x < y ? x : y; }   long long gcd(long long p, long long q) {     if (q == 0) return p;     return gcd(q, p % q);   }   bool check(long long b, long long p) {     long long m;     while (gcd(p, b) != 1) {       m = gcd(p, b);       while (p % m == 0) p = p / m;       b = m;     }     if (p == 1)       return true;     else       return false;   }   int main() {     long long p, q, b;     int n;     scanf( %d , &n);     while (n--) {       scanf( %I64d%I64d%I64d , &p, &q, &b);       if (p == 0) {         printf( Finite n );         continue;       }       long long mmax = max(p, q);       long long mmin = min(p, q);       long long GCD = gcd(mmax, mmin);       p = q / GCD;       if (check(b, p))         printf( Finite n );       else         printf( Infinite n );     }     return 0;   }   