# -*- coding:utf-8 -*- if __name__ == '__main__': f0, f1, n = map(int, input().split()) f = (f0, f1) while 2 <= n: f = (f[1], f[0] ^ f[1]) n -= 1 print(f[n])