import java.util.*; public class ok{ public static void main(String[] args) { Scanner sc=new Scanner (System.in); long f=sc.nextLong(); long g=sc.nextLong(); int n=sc.nextInt(); long h=f^g; long ans; if(n%3==0)ans=f; else if(n%3==1)ans=g; else ans=h; System.out.println(ans); }}