#include <bits/stdc++.h>
const int MOD = 1e9 + 7;
int main() {
  int n, m;
  long long ans = 1, tmp = 1;
  std ::cin >> n >> m;
  for (int i = 0; i < n; i++)
    ans = (ans * (2 * m - 1) + tmp) % MOD, tmp = tmp * m % MOD;
  std ::cout << ans << "\n";
  return 0;
}
