fn main() { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let mut f: Vec = s.split_whitespace().flat_map(str::parse).collect(); let n = f.pop().unwrap() as usize; f.push(f[0] ^ f[1]); println!("{}", f[n % 3]) }