#include <bits/stdc++.h>
using namespace std;
long long fastPow(long long base, long long ind) {
  if (ind == 0) return 1;
  long long ret = fastPow(base, ind / 2);
  ret = ret * ret % 1000000007;
  if (ind % 2) ret = ret * base % 1000000007;
  return ret;
}
int main() {
  long long n, m;
  cin >> n >> m;
  long long ans = fastPow(m, n);
  for (int i = 1; i <= n; i++) {
    long long tmp =
        fastPow(m, n - i + 1) * fastPow(2 * m - 1, i - 1) % 1000000007;
    ans = (ans + tmp) % 1000000007;
  }
  cout << ans << endl;
  return 0;
}
