read n k 'b?a**(b%2)*(a=a*a%m,b/=2,_)%m:1' echo $[k%=m=10**9+7,a=j=-~k*k/2%m,b=n,(m-_+(a=j+k,b=n,_))%m]