#include <bits/stdc++.h>
using namespace std;
long long f[1111111], g[1111111];
void init(int n, int m) {
  f[0] = g[0] = 1;
  for (int i = 1; i <= n; i++)
    f[i] = 1ll * m * f[i - 1] % 1000000007ll,
    g[i] = 1ll * (2 * m - 1) * g[i - 1] % 1000000007ll;
}
int main() {
  int n, m;
  while (~scanf("%d%d", &n, &m)) {
    init(n, m);
    long long ans = 0;
    for (int i = 1; i <= n; i++)
      ans = (ans + f[n - i + 1] * g[i - 1] % 1000000007ll) % 1000000007ll;
    ans = (ans + f[n]) % 1000000007ll;
    printf("%I64d\n", ans);
  }
  return 0;
}
