fn main() { let mut ffn = String::new(); std::io::stdin().read_line(&mut ffn).ok(); let ffn: Vec = ffn.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let n = ffn[2]; let mut ff: Vec = vec![0; 3]; ff[1] = ffn[0]; ff[2] = ffn[1]; ff[0] = ff[1] ^ ff[2]; println!("{}", ff[(n+1) % 3]); }