#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
  x = 0;
  char c = getchar(), f = 0;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') f = 1;
  for (; c >= '0' && c <= '9'; c = getchar())
    x = (x << 1) + (x << 3) + (c ^ 48);
  if (f) x = -x;
}
const int P = 1e9 + 7;
int n, m, res = 0;
inline int ksm(int x, int q = P - 2) {
  int r = 1;
  for (; q; q >>= 1, x = 1ll * x * x % P)
    if (q & 1) r = 1ll * r * x % P;
  return r;
}
int main() {
  read(n), read(m);
  int pw = res = ksm(m, n), dx = (2ll * m - 1) * ksm(m) % P;
  for (int j = 0; j < n; j++) res = (res + pw) % P, pw = 1ll * pw * dx % P;
  return printf("%d\n", res), 0;
}

### Prompt

Please provide a CPP coded solution to the problem described below:

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>
inline void read(T &x) {
  x = 0;
  char c = getchar(), f = 0;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') f = 1;
  for (; c >= '0' && c <= '9'; c = getchar())
    x = (x << 1) + (x << 3) + (c ^ 48);
  if (f) x = -x;
}
const int P = 1e9 + 7;
int n, m, res = 0;
inline int ksm(int x, int q = P - 2) {
  int r = 1;
  for (; q; q >>= 1, x = 1ll * x * x % P)
    if (q & 1) r = 1ll * r * x % P;
  return r;
}
int main() {
  read(n), read(m);
  int pw = res = ksm(m, n), dx = (2ll * m - 1) * ksm(m) % P;
  for (int j = 0; j < n; j++) res = (res + pw) % P, pw = 1ll * pw * dx % P;
  return printf("%d\n", res), 0;
}

```