func_code_string: #include <bits/stdc++.h>   using namespace std;   long long int power(long long int a, long long int b) {     if (b == 0) return 1;     long long int c = power(a, b >> 1);     c = (c * c) % 1000000007;     if (b & 1) return (a * c) % 1000000007;     return c;   }   const int N = (int)1e5 + 5;   const int Q = 301;   int dp[N][10], num[N][10];   string query[N];   string s, temp;   void solve() {     cin >> s;     int q, p;     cin >> q;     for (int i = 0; i <= q - 1; i++) {       cin >> temp;       query[i] = temp;     }     for (int i = 0; i <= 9; i++) {       dp[q][i] = i;       num[q][i] = 1;     }     for (int i = q - 1; i >= 0; i--) {       for (int j = 0; j <= 9; j++) {         dp[i][j] = dp[i + 1][j];         num[i][j] = num[i + 1][j];       }       p = query[i][0] -  0 ;       temp = query[i].substr(3, query[i].size() - 3);       long long int pos = 0;       dp[i][p] = 0;       for (int k = temp.size() - 1; k >= 0; k--) {         dp[i][p] += (dp[i + 1][temp[k] -  0 ] * power(10, pos)) % 1000000007;         if (dp[i][p] >= 1000000007) dp[i][p] -= 1000000007;         pos += num[i][temp[k] -  0 ];         pos %= (1000000007 - 1);       }       num[i][p] = pos;     }     int ans = 0;     int pos = 0;     for (int i = s.size() - 1; i >= 0; i--) {       ans += (dp[0][s[i] -  0 ] * power(10, pos)) % 1000000007;       if (ans >= 1000000007) ans -= 1000000007;       pos += num[0][s[i] -  0 ];       pos %= (1000000007 - 1);     }     cout << ans;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int T = 1;     for (int TC = 1; TC <= T; TC++) {       solve();       cout <<   n ;     }   }   