#include <bits/stdc++.h>
using namespace std;
long long pow(long long a, int k) {
  long long res = 1;
  while (k) {
    if (k & 1) {
      res *= a;
      res %= 1000000007;
    }
    k /= 2;
    a *= a;
    a %= 1000000007;
  }
  return res;
}
int main() {
  long long n, m;
  cin >> n >> m;
  long long out = pow(m, n);
  for (int i = 0; i <= n - 1; ++i) {
    long long cur = pow(m, i + 1);
    cur *= pow(2 * m - 1, n - i - 1);
    cur %= 1000000007;
    out += cur;
    out %= 1000000007;
  }
  cout << out << endl;
}
