#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; dp[1] = p + 1; for (ll i = 0; i < k + 1; i++) { dp[i + 1]+=2*p; dp[i + 1] %= MOD; } cout << dp[k] << endl; }