#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
const int maxm = maxn * 4 + 10;
const int inf = 1e9;
const long long mod = 1e9 + 7;
int getint() {
  char c;
  while ((c = getchar()) && !(c >= '0' && c <= '9') && c != '-')
    ;
  int ret = c - '0', sgn = 0;
  if (c == '-') sgn = 1, ret = 0;
  while ((c = getchar()) && c >= '0' && c <= '9') ret = ret * 10 + c - '0';
  if (sgn) ret = -ret;
  return ret;
}
long long c[maxn];
long long xpow(long long x, long long k) {
  long long ret = 1;
  while (k) {
    if (k & 1) ret = ret * x % mod;
    x = x * x % mod;
    k >>= 1;
  }
  return ret;
}
int main() {
  int n = getint(), m = getint();
  c[0] = 1;
  long long ans = xpow(m, n);
  for (int i = 1; i <= n; i++) {
    c[i] = c[i - 1] * (n - i + 1) % mod * xpow(i, mod - 2) % mod;
  }
  for (int i = 1; i <= n; i++) {
    ans = (ans + xpow(m, i) * xpow(m - 1, n - i) % mod * c[i - 1] % mod) % mod;
  }
  cout << ans << endl;
  return 0;
}

### Prompt

Develop a solution in Cpp to the problem described below:

For a sequence a of n integers between 1 and m, inclusive, denote f(a) as the number of distinct subsequences of a (including the empty subsequence).

You are given two positive integers n and m. Let S be the set of all sequences of length n consisting of numbers from 1 to m. Compute the sum f(a) over all a in S modulo 109 + 7.

Input

The only line contains two integers n and m (1 ≤ n, m ≤ 106) — the number of elements in arrays and the upper bound for elements.

Output

Print the only integer c — the desired sum modulo 109 + 7.

Examples

Input

1 3


Output

6


Input

2 2


Output

14


Input

3 3


Output

174

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
const int maxm = maxn * 4 + 10;
const int inf = 1e9;
const long long mod = 1e9 + 7;
int getint() {
  char c;
  while ((c = getchar()) && !(c >= '0' && c <= '9') && c != '-')
    ;
  int ret = c - '0', sgn = 0;
  if (c == '-') sgn = 1, ret = 0;
  while ((c = getchar()) && c >= '0' && c <= '9') ret = ret * 10 + c - '0';
  if (sgn) ret = -ret;
  return ret;
}
long long c[maxn];
long long xpow(long long x, long long k) {
  long long ret = 1;
  while (k) {
    if (k & 1) ret = ret * x % mod;
    x = x * x % mod;
    k >>= 1;
  }
  return ret;
}
int main() {
  int n = getint(), m = getint();
  c[0] = 1;
  long long ans = xpow(m, n);
  for (int i = 1; i <= n; i++) {
    c[i] = c[i - 1] * (n - i + 1) % mod * xpow(i, mod - 2) % mod;
  }
  for (int i = 1; i <= n; i++) {
    ans = (ans + xpow(m, i) * xpow(m - 1, n - i) % mod * c[i - 1] % mod) % mod;
  }
  cout << ans << endl;
  return 0;
}

```