# -*- coding: utf-8 -*- """ No.64 XORフィボナッチ数列 https://yukicoder.me/problems/no/64 """ import sys from sys import stdin input = stdin.readline def main(args): F0, F1, N = map(int, input().split()) fibo = [F0, F1, F0^F1] print(fibo[N%3]) if __name__ == '__main__': main(sys.argv[1:])