def I():return int(input()) def MAP():return map(int,input().split()) def MAPs():return map(str,input().split()) def LI(): return list(map(int,input().split())) def TPL(): return tuple(map(int,input().split())) def S():return input() from collections import defaultdict,Counter,deque from copy import deepcopy from heapq import heapify,heappop,heappush from bisect import bisect_left,bisect_right from itertools import accumulate,product,permutations,combinations from math import gcd,ceil,floor,sqrt inf=float('inf');mod=998244353;Mod=10**9+7 f0,f1,n=MAP() if n%3==0: print(f0) elif n%3==1: print(f1) else: print(f0^f1)