func_code_string: #include <bits/stdc++.h>   using namespace std;   long long MOD(string s, long long c) {     long long ans = 0, p = 1;     for (int i = (((int)s.size()) - 1); i >= (0); i--) {       ans = (ans + (s[i] -  0 ) * p) % c;       p *= 10;       p %= c;     }     return ans;   }   long long mod(long long a, long long b, long long c) {     long long ans = 1;     while (b) {       if (b % 2) ans = ans * a % c;       a = a * a % c;       b /= 2;     }     return ans;   }   long long solve(long long a, string b, long long c) {     long long ans = 1;     for (int i = (((int)b.size()) - 1); i >= (0); i--) {       ans = ans * mod(a, (b[i] -  0 ), c) % c;       a = mod(a, 10, c);     }     return ans;   }   string dec(string s) {     for (int i = (((int)s.size()) - 1); i >= (0); i--) {       if (s[i] !=  0 ) {         s[i]--;         break;       } else {         s[i] =  9 ;       }     }     return s;   }   int main() {     string bb, n;     long long c;     cin >> bb >> n >> c;     long long b = MOD(bb, c);     long long ans = (b - 1 + c) * solve(b, dec(n), c) % c;     if (ans == 0) ans = c;     cout << ans;   }   