import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long a = sc.nextLong(), b = sc.nextLong(), c = a^b, n = sc.nextLong(); if(n%3 == 0){ System.out.println(a); } else if(n%3 == 1){ System.out.println(b); } else { System.out.println(c); } } }