#include <bits/stdc++.h>
using namespace std;
const int N = 100010, M = 1000010, P = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int INF = 0xcfcfcfcf;
const double eps = 1e-6, pi = asin(1) * 2;
inline long long read();
inline int ADD(int a, int b) { return a + b >= P ? a + b - P : a + b; }
inline int MINUS(int a, int b) { return a - b < 0 ? a - b + P : a - b; }
inline int quickmi(int x, int n) {
  int res = 1;
  for (; n; n >>= 1) {
    if (n & 1) res = 1ll * res * x % P;
    x = 1ll * x * x % P;
  }
  return res;
}
inline long long read() {
  long long s = 0;
  bool flag = false;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') flag = true;
  for (; '0' <= ch && ch <= '9'; ch = getchar())
    s = (s << 3) + (s << 1) + (ch ^ '0');
  if (flag) return -s;
  return s;
}
int main() {
  int n = read(), m = read();
  if (m == 1)
    printf("%d\n", n + 1);
  else
    printf("%d\n", ADD(quickmi(m, n),
                       1ll * m * quickmi(m - 1, P - 2) % P *
                           MINUS(quickmi(m + m - 1, n), quickmi(m, n)) % P));
  return 0;
}

### 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;
const int N = 100010, M = 1000010, P = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int INF = 0xcfcfcfcf;
const double eps = 1e-6, pi = asin(1) * 2;
inline long long read();
inline int ADD(int a, int b) { return a + b >= P ? a + b - P : a + b; }
inline int MINUS(int a, int b) { return a - b < 0 ? a - b + P : a - b; }
inline int quickmi(int x, int n) {
  int res = 1;
  for (; n; n >>= 1) {
    if (n & 1) res = 1ll * res * x % P;
    x = 1ll * x * x % P;
  }
  return res;
}
inline long long read() {
  long long s = 0;
  bool flag = false;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') flag = true;
  for (; '0' <= ch && ch <= '9'; ch = getchar())
    s = (s << 3) + (s << 1) + (ch ^ '0');
  if (flag) return -s;
  return s;
}
int main() {
  int n = read(), m = read();
  if (m == 1)
    printf("%d\n", n + 1);
  else
    printf("%d\n", ADD(quickmi(m, n),
                       1ll * m * quickmi(m - 1, P - 2) % P *
                           MINUS(quickmi(m + m - 1, n), quickmi(m, n)) % P));
  return 0;
}

```