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