class ModInt @@mod = 1_000_000_007 def initialize(n) @n = n.to_i % @@mod end def self.zero ModInt.new(0) end def self.mod @@mod end def self.mod=(m) @@mod = m.to_i end def +@ self end def -@ ModInt.new(n != 0 ? @@mod - @n : 0) end def +(m) ModInt.new(@n + m.to_i % @@mod) end def -(m) ModInt.new(@n - m.to_i % @@mod) end def *(m) ModInt.new(@n * m.to_i % @@mod) end def /(m) raise DivisionByZeroError.new if m == 0 a, b, u, v = m.to_i, @@mod, 1, 0 while b != 0 t = a / b a -= t * b a, b = b, a u -= t * v u, v = v, u end ModInt.new(@n * u) end def **(m) t, res = self, ModInt.new(1) while m > 0 res *= t if m.odd? t *= t m >>= 1 end res end def ==(m) @n == m.to_i end def !=(m) @n != m.to_i end def succ self + 1 end def pred self - 1 end def to_i @n end def to_s @n.to_s end end b, c, d = gets.split.map(&:to_i) if c == 1 puts b * d else puts (ModInt.new(c) ** d.succ - c) / (c - 1) * b end