use std::io::*; use std::str::*; const MOD: i32 = 1000000007; fn read() -> Option { let stdin = stdin(); let s = stdin .bytes() .map(|c| c.unwrap() as char) .take_while(|c| !c.is_whitespace()) .collect::(); s.parse::().ok() } fn main() { let mut f0: u64 = read().unwrap(); let mut f1: u64 = read().unwrap(); let mut n: u64 = read().unwrap(); if n == 1 { println!("{}", f1); return; } if n == 0 { println!("{}", f0); return; } if n == 2 { println!("{}", (f0 ^ f1)); return; } n = (n - 2) % 3; let mut f2: u64 = 0; for _ in 0..n + 1 { f2 = f0 ^ f1; f0 = f1; f1 = f2; // println!("{} {} {}", f0, f1, f2); } println!("{}", f2); }