func_code_string: #include <bits/stdc++.h>   using namespace std;   int gi() {     int a;     scanf( %d , &a);     return a;   }   long long gli() {     long long a;     scanf( %I64d , &a);     return a;   }   long long gcd(long long a, long long b) {     if (a == 0) return b;     if (b == 0) return a;     if (a > b) return gcd(a % b, b);     return gcd(b % a, a);   }   int pr[1000000];   int main() {     unordered_map<long long, vector<pair<long long, long long> > > m;     unordered_map<long long, vector<pair<long long, long long> > >::iterator it;     int n = gi();     for (int i = 0; i < n; i++) {       long long x = gli();       long long y = gli();       long long c = gli();       m[x].push_back(make_pair(y, c));     }     vector<pair<long long, long long> > main;     int L = 0;     long long gg = 0;     int first = 1;     for (it = m.begin(); it != m.end(); it++) {       vector<pair<long long, long long> > &v = it->second;       sort(v.begin(), v.end());       if (first) {         first = 0;         L = v.size();         long long g = 0;         for (int i = 0; i < L; i++) g = gcd(g, v[i].second);         for (int i = 0; i < L; i++)           main.push_back(make_pair(v[i].first, v[i].second / g));       } else {         if (int(v.size()) != L || v[0].first != main[0].first ||             v[0].second % main[0].second != 0) {           printf( 0 n );           return 0;         }         long long f = v[0].second / main[0].second;         for (int i = 1; i < L; i++)           if (v[i].first != main[i].first || v[i].second % main[i].second != 0 ||               v[i].second / main[i].second != f) {             printf( 0 n );             return 0;           }       }       gg = gcd(gg, v[0].second);     }     m.clear();     long long g = 0;     for (int i = 0; i < L; i++) g = gcd(g, main[i].second);     g *= gg / main[0].second;     memset(pr, -1, sizeof(pr));     long long r = 1;     long long c = 1;     while (g % 2 == 0) {       c++;       g /= 2;     }     r *= c;     for (int i = 3; i < 1000000; i += 2)       if (pr[i]) {         for (int j = i * 3; j < 1000000; j += i * 2) pr[i] = 0;         long long c = 1;         while (g % i == 0) {           c++;           g /= i;         }         r *= c;       }     if (g > 1LL) r *= 2;     cout << r << endl;     return 0;   }   