func_code_string: #include <bits/stdc++.h>   using namespace std;   const long double epsilon = 1e-9;   string minus1(const string& str) {     string str1(str);     for (int i = str.size() - 1; i >= 0; i--) {       if (str1[i] !=  0 ) {         str1[i]--;         break;       } else         str1[i] =  9 ;     }     return str1;   }   long long rem(const string& str, long long c) {     long long temp = 0;     for (int i = 0; i < str.size(); i++) {       temp = (temp * 10LL + (long long)(str[i] -  0 )) % c;     }     return temp;   }   long long phi(long long c) {     long long res = 1;     for (long long i = 2; i * i <= c; i++) {       if (c % i == 0) {         c /= i;         res *= (i - 1);         while (c % i == 0) {           c /= i;           res *= i;         }       }     }     if (c > 1) res *= c - 1;     return res;   }   long long rem2(const string& str, long long c) {     long long temp = 0;     long long t2;     for (int i = 0; i < str.size(); i++) {       t2 = (temp * 10LL + (long long)(str[i] -  0 ));       temp = t2 % c + t2 / c;     }     return temp;   }   long long powe(long long a, long long p, long long c) {     long long res = 1;     long long mul = a;     while (p > 0) {       if (p & 1) {         res = (res * mul) % c;       }       mul = (mul * mul) % c;       p >>= 1;     }     return res;   }   long long bruteForce(string B, string N, long long c) {     stringstream ss;     ss << B <<     << N;     long long b, n;     ss >> b >> n;     long long res = (b - 1) % c;     for (int i = 1; i < n; i++) res = (res * b) % c;     if (res == 0) res = c;     return res;   }   long long nod(long long a, long long b) {     if (a < b) swap(a, b);     long long x;     while (b) {       x = a % b;       a = b;       b = x;     }     return a;   }   bool isPow(long long i, long long j) {     if (j == 1) return false;     while (i % j == 0) i /= j;     return i == 1;   }   void fail() {     long long nd;     for (int i = 2; i < 10000; i++) {       for (int j = 1; j < i; j++) {         nd = nod(i, j);         if (isPow(i, nd)) continue;         if (powe(j, phi(i) + 1, i) != j) {           cerr <<  Failed with:   << i <<     << j << endl;           return;         }       }     }   }   int main() {     string n, b;     long long c;     long long e;     int o = 1;     while (cin >> b >> n >> c) {       long long a = rem(minus1(b), c);       long long b2 = rem(b, c);       n = minus1(n);       long long mat[10];       for (int i = 0; i < 10; i++) mat[i] = 1LL;       long long ge, ye;       int idx;       for (int i = n.size() - 1; i >= 0; i--) {         idx = n[i] -  0 ;         mat[idx] = (mat[idx] * b2) % c;         ge = (b2 * b2) % c;         ye = (ge * ge) % c;         ye = (ye * ye) % c;         b2 = (ye * ge) % c;       }       long long re = 1;       for (int i = 0; i < 10; i++) {         for (int j = 0; j < i; j++) re = (re * mat[i]) % c;       }       long long q = (a * re) % c;       if (q == 0) q = c;       cout << q << endl;       o++;     }     return 0;   }   