#include <bits/stdc++.h>
using namespace std;
const int Maxn = 1000 * 1000 + 5, Mod = 1000 * 1000 * 1000 + 7;
long long n, m, powm[Maxn], pow2m[Maxn], ans;
int main() {
  cin >> n >> m;
  powm[0] = 1;
  for (int i = 1; i < Maxn; i++) powm[i] = (powm[i - 1] * m) % Mod;
  pow2m[0] = 1;
  for (int i = 1; i < Maxn; i++) pow2m[i] = (pow2m[i - 1] * (2 * m - 1)) % Mod;
  ans = powm[n];
  for (int i = 0; i < n; i++)
    ans += (powm[i + 1] * pow2m[n - i - 1]) % Mod, ans %= Mod;
  cout << ans << endl;
  return 0;
}
