a,b,N = list(map(int,input().split())) l = [a,b,a^b] N = N % 3 print(l[N])