GCD plus LCM
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

You are given three integers a, b, n. Define a function:

f(x) = \text{lcm}(x,b)+\gcd(x,b)

where \text{lcm}(a,b) denotes the least common multiple of a and b, and \gcd(a,b) denotes the greatest common divisor of a and b. For example, \text{lcm}(6,9)=18, \gcd(6,9)=3.

Let f^{(n)}(x) denote the result of applying the function f(x) for n times. That is: f^{(1)}(x) = f(x), f^{(2)}(x) = f(f(x)), f^{(3)}(x) = f(f(f(x))) and so on.

Your task is to compute the value of f^{(n)}(a) modulo 10^9 + 7.

输入描述:

One line contains three space-separated integers a, b, n (1 \le a, b \le 10^9, 1 \le n \le 10^6).

输出描述:

Print a single integer --- the value of f^{(n)}(a) modulo 10^9 + 7.
示例1

输入

复制
2 2 4

输出

复制
10
示例2

输入

复制
2 2 5

输出

复制
12
示例3

输入

复制
100000 100000 100000

输出

复制
99930