#include <bits/stdc++.h>
using namespace std;
const int iinf = 1e9 + 7;
const long long linf = 1ll << 60;
const double dinf = 1e10;
inline long long read() {
  bool f = 0;
  long long x = 0;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') {
    f = 1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  if (f) x = -x;
  return x;
}
inline void scf(int &x) {
  bool f = 0;
  x = 0;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') {
    f = 1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  if (f) x = -x;
  return;
}
void scf(int &x, int &y) {
  scf(x);
  return scf(y);
}
void scf(int &x, int &y, int &z) {
  scf(x);
  scf(y);
  return scf(z);
}
const int N = 1e6 + 100;
const long long MOD = 1e9 + 7;
long long _pow[N], _inv[N];
long long fa[N], fb[N];
long long ans;
long long kiss_me(long long x, long long n = MOD - 2) {
  long long ret = 1ll;
  while (n) {
    if (n & 1) ret = ret * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return ret;
}
void init() {
  _pow[0] = _inv[0] = 1ll;
  for (int i = (1); i <= (N - 1); i++)
    _pow[i] = _pow[i - 1] * (long long)i % MOD, _inv[i] = kiss_me(_pow[i]);
  return;
}
inline long long C(int n, int m) {
  return _pow[n] * _inv[m] % MOD * _inv[n - m] % MOD;
}
int main() {
  init();
  int n;
  long long m;
  cin >> n >> m;
  fa[0] = fb[0] = 1ll;
  for (int i = (1); i <= (N - 1); i++)
    fa[i] = fa[i - 1] * m % MOD, fb[i] = fb[i - 1] * (m - 1) % MOD;
  ans = fa[n];
  for (int i = (1); i <= (n); i++) {
    long long tmp = fa[i] * fb[n - i] % MOD * C(n, i - 1) % MOD;
    ans = (ans + tmp) % MOD;
  }
  cout << ans << endl;
  return 0;
}
