#include #include #include #include #include #include #define N (1000000000+7) typedef long long ll; using namespace std; ll dp[1000010][3]; int main(void){ ll p,k; cin>>p>>k; dp[0][0]=1; dp[0][1]=0; for(ll i=1;i<=k;i++){ dp[i][0]=0; dp[i][1]=0; dp[i][0] = ((p+1)*dp[i-1][0])%N+(2*dp[i-1][1])%N; dp[i][1] = ((p-1)*dp[i-1][0])%N+(2*(p-1)*dp[i-1][1])%N; dp[i][0] = (dp[i][0]+N)%N; dp[i][1] = (dp[i][1]+N)%N; } cout<