#!/usr/bin/env python3 #fileencoding: utf-8 f0, f1, N = [int(i) for i in input().strip().split(" ")] if N <= 2: print([f0,f1,f0^f1][N]) else: fk_1 = f0 ^ f1 fk_2 = f1 f = 0 for i in range(N-2): fk_1, fk_2 = fk_1^fk_2, fk_1 f = fk_1 print(f)