P,K=map(int,input().split()) p = 1 MOD= 10**9+7 for i in range(K): p=(p*(P+1)+(pow(2*P,i,MOD)-p)*2)%MOD print(p)