#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void prn(Arg1&& arg1) {
  cout << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void prn(Arg1&& arg1, Args&&... args) {
  cout << arg1 << " ";
  prn(args...);
}
template <typename Arg1>
void prs(Arg1&& arg1) {
  cout << arg1 << " ";
}
template <typename Arg1, typename... Args>
void prs(Arg1&& arg1, Args&&... args) {
  cout << arg1 << " ";
  prs(args...);
}
template <typename Arg1>
void read(Arg1&& arg1) {
  cin >> arg1;
}
template <typename Arg1, typename... Args>
void read(Arg1&& arg1, Args&&... args) {
  cin >> arg1;
  read(args...);
}
const int mod = 1e9 + 7;
long long power(long long x, long long y, long long m = mod) {
  if (y == 0) return 1;
  long long p = power(x, y >> 1, m) % m;
  p = p * p % m;
  return (y & 1) ? (x * p) % m : p;
}
long long modInverse(long long a, long long m = mod) {
  return power(a, m - 2, m);
}
void solve() {
  int n, m;
  read(n, m);
  if (m == 1) {
    prn(n + 1);
    return;
  }
  long long r = (2 * m - 1) * modInverse(m) % mod;
  long long s = (power(r, n) - 1 + mod) * modInverse(r - 1 + mod, mod) % mod;
  prn(power(m, n) * (s + 1) % mod);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  for (int tc = 1; tc <= t; ++tc) {
    solve();
  }
  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;
template <typename Arg1>
void prn(Arg1&& arg1) {
  cout << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void prn(Arg1&& arg1, Args&&... args) {
  cout << arg1 << " ";
  prn(args...);
}
template <typename Arg1>
void prs(Arg1&& arg1) {
  cout << arg1 << " ";
}
template <typename Arg1, typename... Args>
void prs(Arg1&& arg1, Args&&... args) {
  cout << arg1 << " ";
  prs(args...);
}
template <typename Arg1>
void read(Arg1&& arg1) {
  cin >> arg1;
}
template <typename Arg1, typename... Args>
void read(Arg1&& arg1, Args&&... args) {
  cin >> arg1;
  read(args...);
}
const int mod = 1e9 + 7;
long long power(long long x, long long y, long long m = mod) {
  if (y == 0) return 1;
  long long p = power(x, y >> 1, m) % m;
  p = p * p % m;
  return (y & 1) ? (x * p) % m : p;
}
long long modInverse(long long a, long long m = mod) {
  return power(a, m - 2, m);
}
void solve() {
  int n, m;
  read(n, m);
  if (m == 1) {
    prn(n + 1);
    return;
  }
  long long r = (2 * m - 1) * modInverse(m) % mod;
  long long s = (power(r, n) - 1 + mod) * modInverse(r - 1 + mod, mod) % mod;
  prn(power(m, n) * (s + 1) % mod);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  for (int tc = 1; tc <= t; ++tc) {
    solve();
  }
  return 0;
}

```