func_code_string: #include <bits/stdc++.h>   char buf[1 << 21], *p1 = buf, *p2 = buf;   inline long long read() {     long long ret = 0, ff = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) ff = -ff;       ch = getchar();     }     while (isdigit(ch)) {       ret = (ret << 3) + (ret << 1) + ch -  0 ;       ch = getchar();     }     return ret * ff;   }   long long p, q, b;   long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }   inline long long ksm(long long a, long long b) {     long long res = 1, base = a;     while (b) {       if (b & 1) {         res = (res * base) % q;         if (res == 0) return 0;       }       base = (base * base) % q;       b >>= 1;     }     return res;   }   int main() {     int T = read();     while (T--) {       p = read(), q = read(), b = read();       long long g = gcd(p, q);       p /= g;       q /= g;       if (q == 1ll) {         printf( Finite n );       } else {         while (1) {           g = gcd(q, b);           if (g == 1) break;           while (q % g == 0) q /= g;           if (q == 1) break;         }         if (q == 1) {           printf( Finite n );         } else {           printf( Infinite n );         }       }     }     return 0;   }   