#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000006;
long long fac[maxn], inv[maxn], facinv[maxn];
long long C(long long n, long long k) {
  return fac[n] * facinv[k] % (1000000007) * facinv[n - k] % (1000000007);
}
void init() {
  fac[0] = fac[1] = 1;
  inv[0] = inv[1] = 1;
  facinv[0] = facinv[1] = 1;
  long long p = (1000000007);
  for (int i = 2; i < maxn; i++) {
    fac[i] = fac[i - 1] * i % (1000000007);
    inv[i] = (p - p / i) * inv[p % i] % p;
    facinv[i] = facinv[i - 1] * inv[i] % (1000000007);
  }
}
long long qp(long long a, long long p) {
  long long res = 1;
  while (p > 0) {
    if (p & 1) res = res * a % (1000000007);
    a = a * a % (1000000007);
    p >>= 1;
  }
  return res;
}
int main() {
  long long n, m;
  init();
  while (cin >> n >> m) {
    long long res = qp(m, n);
    for (long long i = 1; i <= n; i++) {
      long long temp = (qp(m, i) * qp(m - 1, n - i)) % (1000000007);
      temp = (temp * C(n, i - 1)) % (1000000007);
      res = (res + temp) % (1000000007);
    }
    cout << res << endl;
  }
  return 0;
}
