#include <bits/stdc++.h>
using namespace std;
long long pow(long long a, long long n, long long p) {
  long long ret = 1ll;
  while (n > 0) {
    long long lsb = (n & 1ll);
    ret = ((lsb == 1ll) ? ((ret * a) % p) : ret);
    a = (a * a) % p;
    n >>= 1;
  }
  return ret;
}
int main(int argc, const char* argv[]) {
  long long a, b, n, x, p = 1000000007, sum = 0;
  cin >> a >> b >> n >> x;
  long long k = pow(a, n, p);
  long long k2 = pow(a - 1, p - 2, p);
  sum = (k * x) % p;
  if (a != 1) {
    long long d1 = (b * (k - 1ll)) % p;
    long long ad = (d1 * k2) % p;
    sum = (sum + ad) % p;
  } else {
    sum = (x + (n % p) * b) % p;
  }
  cout << sum << endl;
  return 0;
}
