#include <bits/stdc++.h>
using namespace std;
long long Pow(long long a, long long b) {
  long long ans = 1LL, base = a % 1000000007;
  while (b != 0) {
    if (b & 1LL != 0) ans = ans * base % 1000000007;
    base = base * base % 1000000007;
    b >>= 1LL;
  }
  return ans;
}
long long A, B, n, x;
long long ans;
int main() {
  scanf("%lld %lld %lld %lld", &A, &B, &n, &x);
  long long ppow = Pow(A, n) % 1000000007;
  if (A == 1LL)
    ans = (x % 1000000007 + n % 1000000007 * B % 1000000007) % 1000000007;
  else
    ans = (ppow * x % 1000000007 + B % 1000000007 * (ppow - 1LL) % 1000000007 *
                                       Pow(A - 1LL, 1000000007 - 2) %
                                       1000000007) %
          1000000007;
  cout << ans;
}
