#include <bits/stdc++.h>
using namespace std;
const long long P = 1000000007;
long long inv(long long a, long long p) {
  if (a == 1) {
    return 1;
  }
  vector<long long> r;
  vector<long long> q;
  r.push_back(p);
  r.push_back(a);
  int i = 0;
  while (1) {
    r.push_back(r[i] % r[i + 1]);
    q.push_back(r[i] / r[i + 1]);
    i++;
    if (r.back() == 1) {
      break;
    }
  }
  i--;
  long long x = 1;
  long long y = -q[i];
  while (i > 0) {
    long long z = y;
    y = x - y * q[i - 1];
    x = z;
    i--;
  }
  return y % p;
}
long long fast_exp(long long a, long long k, long long p) {
  if (k == 0) return 1;
  if (k % 2 == 0) {
    long long q = fast_exp(a, k / 2, p);
    return (q * q) % p;
  } else {
    long long q = fast_exp(a, k - 1, p);
    return (a * q) % p;
  }
}
int main() {
  long long n, m;
  cin >> n >> m;
  if (m == 1) {
    cout << n + 1;
    return 0;
  }
  long long odp = fast_exp(2 * m - 1, n, P) - fast_exp(m, n, P);
  odp = odp * inv(m - 1, P);
  odp = odp % P;
  odp = (odp * m) % P;
  odp = odp + fast_exp(m, n, P);
  odp = odp % P;
  if (odp < 0) {
    odp += P;
  }
  cout << odp;
}

### Prompt

In CPP, your task is to solve 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 long long P = 1000000007;
long long inv(long long a, long long p) {
  if (a == 1) {
    return 1;
  }
  vector<long long> r;
  vector<long long> q;
  r.push_back(p);
  r.push_back(a);
  int i = 0;
  while (1) {
    r.push_back(r[i] % r[i + 1]);
    q.push_back(r[i] / r[i + 1]);
    i++;
    if (r.back() == 1) {
      break;
    }
  }
  i--;
  long long x = 1;
  long long y = -q[i];
  while (i > 0) {
    long long z = y;
    y = x - y * q[i - 1];
    x = z;
    i--;
  }
  return y % p;
}
long long fast_exp(long long a, long long k, long long p) {
  if (k == 0) return 1;
  if (k % 2 == 0) {
    long long q = fast_exp(a, k / 2, p);
    return (q * q) % p;
  } else {
    long long q = fast_exp(a, k - 1, p);
    return (a * q) % p;
  }
}
int main() {
  long long n, m;
  cin >> n >> m;
  if (m == 1) {
    cout << n + 1;
    return 0;
  }
  long long odp = fast_exp(2 * m - 1, n, P) - fast_exp(m, n, P);
  odp = odp * inv(m - 1, P);
  odp = odp % P;
  odp = (odp * m) % P;
  odp = odp + fast_exp(m, n, P);
  odp = odp % P;
  if (odp < 0) {
    odp += P;
  }
  cout << odp;
}

```