#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long mod_pow(long long x, long long n) {
  long long ans = 1;
  while (n > 0) {
    if (n & 1) ans = (ans * x) % mod;
    n >>= 1;
    x = (x * x) % mod;
  }
  return ans;
}
int main() {
  long long n, m;
  scanf("%I64d%I64d", &n, &m);
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    long long ans1 = mod_pow(m, n - i + 1);
    long long ans2 = mod_pow(2 * m - 1, i - 1);
    ans = (ans + (ans1 * ans2) % mod) % mod;
  }
  ans = (ans + mod_pow(m, n)) % mod;
  cout << ans;
  return 0;
}
