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