c,t,m=map(int,input().split()) M=10**9+7 x=pow(c,M-2,M) l=4 def seki(a,b): c=[[0]*l for i in range(l)] for i in range(l): for j in range(l): for k in range(l): c[i][j]+=a[i][k]*b[k][j] c[i][j]%=M return c A=[ [x,0,0,x], [0,x,(c-1)*x,(c-2)*x], [1,0,0,0], [0,1,0,0], ] B=[ [1,0,0,0], [0,1,0,0], [0,0,1,0], [0,0,0,1], ] for i in range(30): if (t>>i)&1: B=seki(A,B) A=seki(A,A) print((1-pow(1-B[0][0],m,M))%M)