fn main() { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let mut s = s.trim().split_whitespace(); let f: u64 = s.next().unwrap().parse().unwrap(); let ff: u64 = s.next().unwrap().parse().unwrap(); let n: u64 = s.next().unwrap().parse().unwrap(); let ans = match n % 3 { 0 => f, 1 => ff, 2 => f ^ ff, _ => unreachable!(), }; println!("{}", ans); }