#coding:utf-8 F0,F1,N=map(int,raw_input().split()) if N==0: print F0 elif N==1: print F1 else: for i in range(N-1): F=F0^F1 F0,F1=F1,F print F1