#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
long long n, m, p1[1000005], p2[1000005], mod = 1e9 + 7;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  long long ans = 1;
  for (long long i = 1; i <= n; i++) ans = ans * m % mod;
  p1[0] = p2[0] = 1;
  for (long long i = 1; i <= n; i++) {
    p1[i] = p1[i - 1] * m % mod;
    p2[i] = p2[i - 1] * (m + m - 1) % mod;
  }
  for (long long i = 1; i <= n; i++) {
    ans = (ans + p1[n - i + 1] * p2[i - 1]) % mod;
  }
  cout << ans;
  return 0;
}
