import java.util.*; import java.util.stream.Stream; import java.time.*; import java.time.format.*; public class No64 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long f0 = sc.nextLong(); long f1 = sc.nextLong(); long n = sc.nextLong(); if(n%3 == 0) { System.out.println(f0); }else if(n%3 == 1) { System.out.println(f1); }else { System.out.println(f0 ^ f1); } } }