#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll N = 1e7;
ll prime[N];
ll tot_fact[N];
ll power(ll x, ll y) {
  ll temp;
  if (y == 0) return 1;
  temp = power(x, y / 2);
  if (y % 2 == 0)
    return (temp % MOD * temp % MOD) % MOD;
  else
    return ((x % MOD * temp % MOD) % MOD * temp % MOD) % MOD;
}
void solve() {
  ll a, b, n, x;
  cin >> a >> b >> n >> x;
  ll tans = power(a, n);
  if (a == 1) {
    cout << (x % MOD + (n % MOD * b % MOD) % MOD) % MOD;
    return;
  }
  ll p = (tans - 1) % MOD;
  ll tt = power(a - 1, MOD - 2);
  ll t = (tt % MOD * p % MOD) % MOD;
  ll ans = ((tans % MOD * x % MOD) % MOD + (b % MOD * t) % MOD) % MOD;
  cout << ans;
}
int main() {
  int t = 1;
  while (t--) solve();
}
