#include <bits/stdc++.h>
using namespace std;
long long mul(long long x, long long y, long long mod) {
  long long ans = 0, m = abs(x), s = 0, sgn = (x > 0) xor (y > 0) ? -1 : 1;
  for (x = abs(x), y = abs(y); y; y >>= 1, m <<= 1, m = m >= mod ? m - mod : m)
    if (y & 1) s += m, s = s >= mod ? s - mod : s;
  return (s * sgn % mod + mod) % mod;
}
long long powmod(long long x, long long p, long long mod) {
  long long s = 1, m = x % mod;
  for (; p; m = m * m % mod, p >>= 1)
    if (p & 1) s = s * m % mod;
  return s;
}
const long long mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  long long ans = 0, C = 1;
  for (int k = 1; k <= n; ++k) {
    (ans += C * powmod(m, k, mod) % mod * powmod(m - 1, n - k, mod) % mod) %=
        mod;
    C = C * (n - k + 1) % mod * powmod(k, mod - 2, mod) % mod;
  }
  cout << (ans + powmod(m, n, mod)) % mod << '\n';
}

### Prompt

Your task is to create a Cpp solution 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;
long long mul(long long x, long long y, long long mod) {
  long long ans = 0, m = abs(x), s = 0, sgn = (x > 0) xor (y > 0) ? -1 : 1;
  for (x = abs(x), y = abs(y); y; y >>= 1, m <<= 1, m = m >= mod ? m - mod : m)
    if (y & 1) s += m, s = s >= mod ? s - mod : s;
  return (s * sgn % mod + mod) % mod;
}
long long powmod(long long x, long long p, long long mod) {
  long long s = 1, m = x % mod;
  for (; p; m = m * m % mod, p >>= 1)
    if (p & 1) s = s * m % mod;
  return s;
}
const long long mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  long long ans = 0, C = 1;
  for (int k = 1; k <= n; ++k) {
    (ans += C * powmod(m, k, mod) % mod * powmod(m - 1, n - k, mod) % mod) %=
        mod;
    C = C * (n - k + 1) % mod * powmod(k, mod - 2, mod) % mod;
  }
  cout << (ans + powmod(m, n, mod)) % mod << '\n';
}

```