#include <bits/stdc++.h>
using namespace std;
const int N = 3e6 + 5;
const int mod = 1e9 + 7;
void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
int sum(int a, int b) {
  add(a, b);
  return a;
}
int mult(int a, int b) { return (1ll * a * b) % mod; }
int bp(int a, int n) {
  int ans = 1;
  while (n) {
    if (n & 1) ans = mult(ans, a);
    a = mult(a, a);
    n >>= 1;
  }
  return ans;
}
int n, m, first[N], inv[N], cur, ans;
int cnk(int n, int k) {
  int ans = mult(first[n], inv[k]);
  ans = mult(ans, inv[n - k]);
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  first[0] = inv[0] = 1;
  for (int i = 1; i <= n; i++) {
    first[i] = mult(first[i - 1], i);
    inv[i] = bp(first[i], mod - 2);
  }
  ans = bp(m, n);
  for (int second = 1; second <= n; second++) {
    cur = mult(bp(m, second), bp(m - 1, n - second));
    cur = mult(cur, cnk(n, second - 1));
    add(ans, cur);
  }
  cout << ans;
  return 0;
}
