eval"P,K="+gets.split*?, t=b=1 M=10**9+7 K.times{t,b=(t*P+b)%M,(2*b+t)*P%M-b} p t