#coding: utf-8 ##yuki_64 s=map(int,raw_input().split()) f0=s[0] f1=s[1] n=s[2] if n % 3 == 0: print(f0) elif n % 3 == 1: print(f1) else: print(f0^f1)