f0,f1,n = list(map(int,input().split())) f2 = f0^f1 f = [f0,f1,f2] print(f[n%3])