#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<long long, long long> &a, pair<long long, long long> &b) {
  if (a.first == b.first) return (a.second < b.second);
  return a.first < b.first;
}
long long gcdextended(long long a, long long b, long long *x, long long *y) {
  if (a == 0) {
    *x = 0, *y = 1;
    return b;
  }
  long long x1, y1;
  long long gcd = gcdextended(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return gcd;
}
long long modinverse(long long a, long long m) {
  long long x, y;
  long long g = gcdextended(a, m, &x, &y);
  return ((x % m + m) % m);
}
long long nCr(long long n, long long r) {
  long long res = 1;
  for (int i = n; i > max(r, n - r); i--) res *= i, res %= 1000000007;
  for (int i = 2; i <= min(r, n - r); i++) res /= i;
  return res % 1000000007;
}
long long exp(long long n, long long j) {
  long long i = n, res = 1;
  while (j > 0) {
    if (j & 1) res *= i;
    res %= 1000000007;
    i = i * i;
    i %= 1000000007;
    j >>= 1;
  }
  return res % 1000000007;
}
int main() {
  int T = 1;
  while (T--) {
    long long a, b, n, x, i;
    cin >> a >> b >> n >> x;
    long long inv;
    if (a > 1) inv = modinverse(a - 1, 1000000007);
    long long k = exp(a, n);
    long long ans;
    if (a == 1)
      ans = ((b * (n % 1000000007)) % 1000000007 + (k * x) % 1000000007) %
            1000000007;
    else
      ans = ((b * (((k - 1) * inv) % 1000000007)) % 1000000007 +
             (k * x) % 1000000007) %
            1000000007;
    cout << ans;
  }
}
