#include <bits/stdc++.h>
const int mod = 1e9 + 7;
using namespace std;
long long POW(long long bs, long long ex) {
  long long res = 1;
  while (ex) {
    if (ex % 2) res = (res * bs) % mod;
    bs = (bs * bs) % mod;
    ex /= 2LL;
  }
  return res % mod;
}
long long GS(long long r, long long n) {
  if (r == 1) return n % mod;
  return (POW(r, n) - 1) * POW(r - 1, mod - 2) % mod;
}
int main() {
  long long a, b, n, x;
  cin >> a >> b >> n >> x;
  cout << (POW(a, n) * x + b * GS(a, n)) % mod;
}
