using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Magatro { static void Main() { long[] N = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray(); if (N[2] % 3 == 0) { Console.WriteLine(N[0]); } else if (N[2] % 3 == 1) { Console.WriteLine(N[1]); } else { long ans = N[1] ^ N[0]; Console.WriteLine(ans); } } }