fn run() { let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); let mut it = s.trim().split_whitespace(); let a: u64 = it.next().unwrap().parse().unwrap(); let b: u64 = it.next().unwrap().parse().unwrap(); let mut n: u64 = it.next().unwrap().parse().unwrap(); const MOD: u64 = 1_000_000_007; let mut t = [[1, 0], [0, 1]]; let mut s = [[a, b], [1, 0]]; while n > 0 { if n & 1 == 1 { let mut c = [[0, 0], [0, 0]]; for i in 0..2 { for j in 0..2 { for k in 0..2 { c[i][j] += t[i][k] * s[k][j]; } } } for i in 0..2 { for j in 0..2 { t[i][j] = c[i][j] % MOD; } } } let mut c = [[0, 0], [0, 0]]; for i in 0..2 { for j in 0..2 { for k in 0..2 { c[i][j] += s[i][k] * s[k][j]; } } } for i in 0..2 { for j in 0..2 { s[i][j] = c[i][j] % MOD; } } n >>= 1; } println!("{}", t[1][0]); } fn main() { run(); }