using System; using System.Text; using System.Collections.Generic; using System.Linq; class Program { static void Main() { long[] n = Console.ReadLine().Split().Select(a => long.Parse(a)).ToArray(); if(n[2] % 3 == 0) { Console.WriteLine($"{n[0]}"); } else if(n[2] % 3 == 1) { Console.WriteLine($"{n[1]}"); } else { Console.WriteLine($"{n[0] ^ n[1]}"); } } }