#include <bits/stdc++.h>
using namespace std;
long long a, b, n, x;
const int mod = 1e9 + 7;
long long ans;
long long aced(long long i, long long k) {
  if (k == 0) return 1;
  long long tmp = aced(i, k / 2);
  if (k % 2 == 1)
    return 1LL * tmp * tmp % mod * i % mod;
  else
    return 1LL * tmp * tmp % mod;
}
int main() {
  cin >> a >> b >> n >> x;
  if (a == 1) {
    cout << 1LL * (x + 1LL * b * (n % mod)) % mod;
    return 0;
  }
  ans = 1LL * (ans + 1LL * aced(a, n) * x % mod) % mod;
  long long tmp =
      1LL * (aced(a, n) % mod - 1) % mod * aced(a - 1, mod - 2) % mod * b % mod;
  ans = 1LL * (ans + tmp) % mod;
  cout << ans << endl;
}
