#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7ll;
long long n, m, ans;
long long ksm(long long x, long long w) {
  long long s = 1;
  while (w) {
    if (w & 1) s = s * x % M;
    x = x * x % M;
    w >>= 1;
  }
  return s;
}
signed main() {
  cin >> n >> m;
  ans = ksm(m, n);
  for (long long j = 0; j < n; j++)
    ans = (ans + ksm(m, n - j) * ksm(2 * m - 1, j)) % M;
  cout << ans << endl;
  return 0;
}
