#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
const int INF = 1e9 + 7;
inline int qpow(int x, int y) {
  int ret = 1;
  for (; y; y >>= 1) {
    if (y & 1) ret = 1ll * ret * x % INF;
    x = 1ll * x * x % INF;
  }
  return ret;
}
int n, m;
int fac[maxn], ifac[maxn];
inline int binom(int x, int y) {
  return 1ll * fac[x] * ifac[y] % INF * ifac[x - y] % INF;
}
int main() {
  scanf("%d%d", &n, &m);
  fac[0] = 1;
  for (int i = (1); i <= (n); ++i) fac[i] = 1ll * fac[i - 1] * i % INF;
  ifac[n] = qpow(fac[n], INF - 2);
  for (int i = n - 1; i >= 0; --i) ifac[i] = 1ll * ifac[i + 1] * (i + 1) % INF;
  int ans = 0;
  for (int t = (1); t <= (n); ++t) {
    int res = 1ll * qpow(m, n - t + 1) % INF * qpow(2 * m - 1, t - 1) % INF;
    (ans += res) %= INF;
  }
  (ans += qpow(m, n)) %= INF;
  printf("%d\n", ans);
  return 0;
}

### Prompt

Please create a solution in Cpp to the following problem:

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 + 5;
const int INF = 1e9 + 7;
inline int qpow(int x, int y) {
  int ret = 1;
  for (; y; y >>= 1) {
    if (y & 1) ret = 1ll * ret * x % INF;
    x = 1ll * x * x % INF;
  }
  return ret;
}
int n, m;
int fac[maxn], ifac[maxn];
inline int binom(int x, int y) {
  return 1ll * fac[x] * ifac[y] % INF * ifac[x - y] % INF;
}
int main() {
  scanf("%d%d", &n, &m);
  fac[0] = 1;
  for (int i = (1); i <= (n); ++i) fac[i] = 1ll * fac[i - 1] * i % INF;
  ifac[n] = qpow(fac[n], INF - 2);
  for (int i = n - 1; i >= 0; --i) ifac[i] = 1ll * ifac[i + 1] * (i + 1) % INF;
  int ans = 0;
  for (int t = (1); t <= (n); ++t) {
    int res = 1ll * qpow(m, n - t + 1) % INF * qpow(2 * m - 1, t - 1) % INF;
    (ans += res) %= INF;
  }
  (ans += qpow(m, n)) %= INF;
  printf("%d\n", ans);
  return 0;
}

```