# coding: utf-8 f0,f1,n = map(int,input().split(" ")) res = 0 for i in range(2,n+1): res = f1 ^ f0 f0 = f1 f1 = res print(res)