#include <bits/stdc++.h>
using namespace std;
long long int modulo = 1e9 + 7;
long long int eleva(long long int b, long long int e) {
  if (e == 0) return 1;
  if (e % 2 == 0) return eleva(b * b % modulo, e / 2);
  return b * eleva(b * b % modulo, e / 2) % modulo;
}
long long int inverso(long long int x) { return eleva(x, modulo - 2); }
long long int n, m;
int main() {
  cin >> n >> m;
  long long int invm = inverso(m);
  long long int f = 1;
  long long int prod = 1;
  for (int i = 1; i <= n; i++) {
    long long int fc = (f - prod) * invm % modulo;
    f = m * (2 * f - fc) % modulo;
    prod = prod * m % modulo;
  }
  cout << ((f % modulo) + modulo) % modulo << endl;
}

### Prompt

Your challenge is to write 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 int modulo = 1e9 + 7;
long long int eleva(long long int b, long long int e) {
  if (e == 0) return 1;
  if (e % 2 == 0) return eleva(b * b % modulo, e / 2);
  return b * eleva(b * b % modulo, e / 2) % modulo;
}
long long int inverso(long long int x) { return eleva(x, modulo - 2); }
long long int n, m;
int main() {
  cin >> n >> m;
  long long int invm = inverso(m);
  long long int f = 1;
  long long int prod = 1;
  for (int i = 1; i <= n; i++) {
    long long int fc = (f - prod) * invm % modulo;
    f = m * (2 * f - fc) % modulo;
    prod = prod * m % modulo;
  }
  cout << ((f % modulo) + modulo) % modulo << endl;
}

```