#include <bits/stdc++.h>
const long long MOD = 1000000007;
int N, M;
long long O, fc[1000001], fi[1000001], PMN, W, T = 1;
long long POWER(long long a, long long b) {
  long long r = 1;
  for (; b; b >>= 1) {
    if (b & 1) r = r * a % MOD;
    a = a * a % MOD;
  }
  return r;
}
inline long long C(int x, int y) {
  return fc[x] * fi[y] % MOD * fi[x - y] % MOD;
}
int main() {
  scanf("%d%d", &N, &M);
  fc[0] = fi[0] = fi[1] = 1;
  for (int i = 2; i <= N; i++) fi[i] = (MOD - MOD / i) * fi[MOD % i] % MOD;
  for (int i = 1; i <= N; i++) {
    fc[i] = fc[i - 1] * i % MOD;
    fi[i] = fi[i - 1] * fi[i] % MOD;
  }
  PMN = POWER(M, N);
  W = (M - 1) * POWER(M, MOD - 2) % MOD;
  for (int i = 1; i <= N; i++) {
    O = (O + C(N, i) * T) % MOD;
    T = T * W % MOD;
  }
  printf("%lld\n", (O + 1) * PMN % MOD);
  return 0;
}
