d=input().split() a=int(d[0]) b=int(d[1]) n=int(d[2]) def func(x,y,n): if n==-1: return x^y else: return func(y,x^y,n-1) print(func(a,b,n))