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