import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long n = sc.nextLong(); long m=sc.nextLong(); long l=sc.nextLong(); long n2=n^m; if(l%3==0) System.out.println(n); else if(l%3==1) System.out.println(m); else System.out.println(n2); } }