import java.util.Scanner; public class No64 { public static void main(String[] args) { Scanner s = new Scanner(System.in); long f0 = s.nextLong() , f1 = s.nextLong() , N = s.nextLong(); s.close(); long f2 = f0 ^ f1; if(N % 3 == 0){ System.out.println(f0); }else if(N % 3 ==1){ System.out.println(f1); }else{ System.out.println(f2); } } }