import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); while(sc.hasNext()){ long f0=sc.nextLong(); long f1=sc.nextLong(); long f2=f0^f1; 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(f2); } } }