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