#include using namespace std; using ll = long long; constexpr long long MOD = 1000000007; int main(){ ll p, k; cin >> p >> k; ll dp[k + 1]; dp[0] = 1; for (ll i = 0; i < k; i++) { dp[i + 1]+=p; dp[i + 1] += dp[i]; dp[i + 1] %= MOD; } cout << dp[k] << endl; }