#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  long long a = 1;
  long long b = 1;
  long long c = 1000000007;
  for (int i = 0; i < n; i++) {
    b = b * (2 * m - 1);
    b = b + a;
    b = b % c;
    a = a * m;
    a = a % c;
  }
  cout << b;
  return 0;
}
