#include <bits/stdc++.h>
using namespace std;
template <typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
const int M = 1e9 + 7;
int n, m;
long long powmod(long long a, long long b) {
  long long ans = 1;
  while (b > 0) {
    if (b & 1) {
      ans = (ans * a) % M;
    }
    a = (a * a) % M;
    b /= 2;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  long long ans = powmod(m, n);
  for (int j = (0); j < (n); j++) {
    ans = (ans + powmod(m, n - j) * powmod(2 * m - 1, j)) % M;
  }
  cout << ans << '\n';
}

### Prompt

Please formulate 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;
template <typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
const int M = 1e9 + 7;
int n, m;
long long powmod(long long a, long long b) {
  long long ans = 1;
  while (b > 0) {
    if (b & 1) {
      ans = (ans * a) % M;
    }
    a = (a * a) % M;
    b /= 2;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  long long ans = powmod(m, n);
  for (int j = (0); j < (n); j++) {
    ans = (ans + powmod(m, n - j) * powmod(2 * m - 1, j)) % M;
  }
  cout << ans << '\n';
}

```