#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long power(long long a, long long b) {
  long long r = 1;
  while (b) {
    if (b % 2) r = (r * a) % mod;
    a = (a * a) % mod;
    b /= (long long)2;
  }
  return r % mod;
}
long long geo(long long a, long long b) {
  if (a == 1) return b % mod;
  return (1 - power(a, b)) * (power(1 - a, mod - 2)) % mod;
}
int main() {
  long long a, b, n, x;
  cin >> a >> b >> n >> x;
  cout << (power(a, n) * x + b * geo(a, n)) % mod << endl;
  return 0;
}
