func_code_string: #include <bits/stdc++.h>   using namespace std;   long long p, q, b, n, tmp;   long long gcd(int x, int y) { return y ? gcd(y, x % y) : x; }   int main() {     ios::sync_with_stdio(false);     cin.tie();     cout.tie();     cin >> n;     for (int i = 0; i < n; i++) {       cin >> p >> q >> b;       q = q / gcd(q, p);       while ((tmp = gcd(q, b)) != 1)         while (q % tmp == 0) q /= tmp;       if (q == 1)         cout <<  Finite  << endl;       else         cout <<  Infinite  << endl;     }     return 0;   }   