#include <bits/stdc++.h>
using namespace std;
const long long p = 1000000007LL;
long long power(long long x, long long n) {
  long long ret = 1LL;
  while (n > 0LL) {
    if (n & 1LL) ret = ret * x % p;
    x = x * x % p;
    n >>= 1LL;
  }
  return ret;
}
long long n, m;
long long dp;
int main() {
  cin >> n >> m;
  dp = 1;
  for (long long i = 1LL; i <= n; i++)
    dp = (dp * (m * 2LL - 1LL) + power(m, i - 1LL)) % p;
  cout << dp << endl;
}
