def main(): f0, f1, n = map(int, input().split()) x = [f0, f1, f0 ^ f1] print(x[n % 3]) if __name__ == '__main__': main()