func_code_string: #include <bits/stdc++.h>   using namespace std;   long long u, v, p;   map<long long, int> M;   map<long long, int> pre, pre2;   queue<int> x, y;   bool in(int val, int rn) {     return ((M.find(val) != M.end()) & (((M[val] >> rn) & 1)));   }   long long modpow(long long x, long long n) {     long long res = 1;     while (n > 0) {       if (n & 1) res = res * x % p;       x = x * x % p;       n >>= 1;     }     return res;   }   int main() {     cin >> u >> v >> p;     x.push(u);     y.push(v);     for (int i = 0;; i++) {       int sz = x.size();       bool en = false;       int goal = -1;       while (sz--) {         int q = x.front();         x.pop();         if (in(q, 0)) continue;         M[q] |= 1;         if (M[q] == 3) {           en = true;           goal = q;           break;         }         if (!in((q + p - 1) % p, 0)) {           x.push((q + p - 1) % p);           pre[(q + p - 1) % p] = q;         }         if (!in((q + 1) % p, 0)) {           x.push((q + 1) % p);           pre[(q + 1) % p] = q;         }         long long rev = modpow(q, p - 2);         if (!in(rev, 0)) {           x.push(rev);           pre[rev] = q;         }       }       sz = y.size();       while (sz--) {         int q = y.front();         y.pop();         if (in(q, 1)) continue;         M[q] |= 2;         if (M[q] == 3) {           en = true;           goal = q;           break;         }         if (!in((q + p - 1) % p, 1)) {           y.push((q + p - 1) % p);           pre2[(q + p - 1) % p] = q;         }         if (!in((q + 1) % p, 1)) {           y.push((q + 1) % p);           pre2[(q + 1) % p] = q;         }         long long rev = modpow(q, p - 2);         if (!in(rev, 1)) {           y.push(rev);           pre2[rev] = q;         }       }       if (en) {         vector<int> num;         int cur = goal;         num.push_back(cur);         while (cur != u) {           cur = pre[cur];           num.push_back(cur);         }         reverse(num.begin(), num.end());         cur = goal;         while (cur != v) {           cur = pre2[cur];           num.push_back(cur);         }         cout << num.size() - 1 << endl;         for (int i = 1; i < num.size(); i++) {           long long a = num[i - 1];           long long b = num[i];           if ((a + 1) % p == b) {             printf( 1  );           } else if ((a + p - 1) % p == b) {             printf( 2  );           } else             printf( 3  );         }         puts(  );         return 0;       }     }   }   