package yukicoder064; import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner sc=new Scanner(System.in); long f0=sc.nextLong(); long f1=sc.nextLong(); long n=sc.nextLong(); //00 0 00 //01 1 01 //10 1 10 //11 0 11 n=n%3; System.out.println(new long[]{f0,f1,f0^f1}[(int)n]); } }