#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int n, m;
const int MOD = 1e9 + 7;
long long quick(long long A, long long B) {
  if (B == 0) return 1;
  long long tmp = quick(A, B >> 1);
  tmp *= tmp;
  tmp %= MOD;
  if (B & 1) tmp *= A, tmp %= MOD;
  return tmp;
}
int main() {
  scanf("%d%d", &n, &m);
  int rest = quick(m, n);
  for (int i = 1; i <= n; ++i) {
    (rest += 1ll * quick(m, n - i) * m % MOD * quick(m + m - 1, i - 1) % MOD) %=
        MOD;
  }
  cout << rest << endl;
  return 0;
}
