a,b,n = map(int,raw_input().split()) print [a,b,a^b][n%3]