import java.util.*; public class Fib{ public static void main(String[] arg){ Scanner sc = new Scanner(System.in); long f0,f1,f2,n; f0 = sc.nextLong(); f1 = sc.nextLong(); n = sc.nextLong(); 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); } } }