#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long n, m;
long long pm[1000005], pmm[1000005];
long long ans;
int main() {
  scanf("%I64d%I64d", &n, &m);
  pm[0] = 1;
  for (long long k = 1; k <= n; k++) pm[k] = (pm[k - 1] * m) % mod;
  pmm[0] = 1;
  for (long long k = 1; k <= n; k++) pmm[k] = (pmm[k - 1] * (2 * m - 1)) % mod;
  ans = 0;
  for (long long k = 1; k <= n; k++)
    ans = (ans + pm[n - k + 1] * pmm[k - 1]) % mod;
  ans = (ans + pm[n]) % mod;
  printf("%I64d\n", ans);
  return 0;
}
