fn main() { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let mut n: Vec = s.split_whitespace().flat_map(str::parse).collect(); (2..=n[2]).for_each(|_| (n[0], n[1]) = (n[1], n[0] ^ n[1])); println!("{}", n[1.min(n[2] as usize)]) }