func_code_string: #include <bits/stdc++.h>   using namespace std;   const int m = 1e9 + 7;   const int N = 3e5 + 15;   const int64_t INF = 100000000000000018LL;   priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,                  greater<pair<long long, long long>>>       pq;   vector<vector<long long>> graph(N);   vector<long long> collect;   map<long long, long long> mpp;   set<pair<long long, long long>> s;   set<long long> second;   long long odd = 0, even = 0;   long long pow(long long a, long long b, long long m) {     long long ans = 1;     while (b) {       if (b & 1) ans = (ans * a) % m;       b /= 2;       a = (a * a) % m;     }     return ans;   }   long long inv(long long a) { return pow(a, m - 2, m); }   void dfs(long long ind, vector<bool>& visited) {     visited[ind] = true;     for (auto it : graph[ind]) {       {         if (!visited[it]) dfs(it, visited);       }     }   }   bool isPowerOfTwo(long long n) {     if (n == 0) return false;     return (ceil(log2(n)) == floor(log2(n)));   }   void solve() {     long long a, b, n, x;     cin >> a >> b >> n >> x;     long long ans = pow(a, n, m);     n = n % m;     long long aa = ans * x;     if (aa < 0) aa += m;     aa = aa % m;     long long aa1 = 1;     if (a == 1) {       long long z1 = b * n;       z1 = z1 % m;       cout << (x + z1) % m;       return;     }     aa1 = ((ans - 1 + m) % m) * inv(a - 1);     aa1 = aa1 % m;     if (aa1 < 0) aa1 += m;     aa1 = aa1 * b;     cout << (aa + aa1 + m) % m <<   n ;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long t = 1;     while (t--) {       solve();     }   }   