#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 10;
const long long mod = 1e9 + 7;
long long fast_pow(long long x, long long n) {
  if (n == 0)
    return 1;
  else if (n % 2 == 0) {
    long long y = fast_pow(x, n / 2);
    return (y * y) % mod;
  } else
    return (fast_pow(x, n - 1) * x) % mod;
}
long long rev(long long x) { return fast_pow(x, mod - 2); }
long long divm(long long a, long long b) { return (a * rev(b)) % mod; }
long long fact[maxn];
long long C(long long n, long long k) {
  return divm(fact[n], (fact[k] * fact[n - k]) % mod);
}
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  fact[0] = 1;
  for (long long i = 1; i <= n; ++i) {
    fact[i] = (fact[i - 1] * i) % mod;
  }
  long long ans = fast_pow(m, n);
  for (long long s = 1; s <= n; ++s) {
    long long subseq = fast_pow(m, s);
    long long another = (fast_pow(m - 1, n - s) * C(n, s - 1)) % mod;
    ans += (subseq * another) % mod;
    ans %= mod;
  }
  cout << ans;
}
