func_code_string: #include <bits/stdc++.h>   using namespace std;   long long int n, p, q, b, l;   long long int gcd(long long int a, long long int c) {     if (!c) return a;     return gcd(c, a % c);   }   long long int read_ll() {     char ch;     long long int num = 0;     ch = getchar();     while (!isdigit(ch)) {       ch = getchar();     }     while (isdigit(ch)) {       num = num * 10 + (long long int)ch - (long long int) 0 ;       ch = getchar();     }     return num;   }   int main() {     scanf( %ld , &n);     while (n--) {       p = read_ll();       q = read_ll();       b = read_ll();       long long int d = gcd(p, q);       p = p / d;       q = q / d;       while (1) {         b = gcd(q, b);         if (b == 1) {           if (q == 1)             printf( Finite n );           else             printf( Infinite n );           break;         }         while (q % b == 0) q /= b;       }     }     return 0;   }   