#include <bits/stdc++.h>
long long int INF = 10000000000001;
long long int MOD = 1000000007;
double pi = 2 * acos(0.0);
typedef unsigned long long int ull;
using namespace std;
inline long long int expo(long long int e, long long int n) {
  long long int x = 1, p = e;
  while (n) {
    if (n & 1) x = x * p;
    p = p * p;
    n >>= 1;
  }
  return x;
}
inline long long int power(long long int e, long long int n, long long int m) {
  long long int x = 1, p = e;
  while (n) {
    if (n & 1) x = (x * p) % m;
    p = (p * p) % m;
    n >>= 1;
  }
  return x;
}
inline long long int InverseEuler(long long int a, long long int m) {
  return (a == 1 ? 1 : power(a, m - 2, m));
}
inline long long int gcd(long long int a, long long int b) {
  while (a %= b ^= a ^= b ^= a)
    ;
  return b;
}
inline long long int lcm(long long int a, long long int b) {
  return (a * (b / gcd(a, b)));
}
long long int movex8[] = {-1, -1, -1, 0, 0, 1, 1, 1};
long long int movey8[] = {-1, 0, 1, -1, 1, -1, 0, 1};
long long int movex4[] = {1, -1, 0, 0};
long long int movey4[] = {0, 0, 1, -1};
int main() {
  long long int a, b, n, x, ans = 0;
  cin >> a >> b >> n >> x;
  if (a != 1) {
    long long int p1 = power(a, n, MOD) - 1;
    ans = (p1 * InverseEuler(a - 1, MOD)) % MOD;
    ans = (ans * (b % MOD)) % MOD;
    ans = ((ans % MOD) + (power(a, n, MOD) * (x % MOD)) % MOD) % MOD;
  } else
    ans = ((((n) % MOD) * (b % MOD)) % MOD + x % MOD) % MOD;
  cout << ans << endl;
  return 0;
}
