1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int n, m;
    cin>>n>>m;
    long long int suma = pow(m, n-1) + (m);
    long long int liczba = pow(10, 9) + 7;
    cout<<suma%liczba;
    return 0;
}