mod = 10**9 + 7 n = int(input()) b, d = map(int, input().split()) ret = ((d + 1) * (pow(d + 1, b, mod) - 1) * pow(d, mod - 2, mod) - b + mod) % mod while n > 0: ret -= n n /= d + 1 print(ret)