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 { string a = Convert.ToString(N[0], 2); string b = Convert.ToString(N[1], 2); int l = Math.Max(a.Length, b.Length); string f = string.Format("0:D{0}", l); a = string.Format("{"+ f+"}", a); b = string.Format("{"+f+"}", b); string c = ""; for(int i = 0; i < l; i++) { if (a[i] == '1' ^ b[i] == '1') { c += "1"; } else { c += "0"; } } Console.Write(Convert.ToInt64(c,2)); } } }