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(); long n=sc.nextLong(); 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); }}