#!/usr/bin/python # -*- coding: utf-8 -*- F0, F1 , N = map(int, raw_input().split()) if N == 0: print F0 exit() elif N == 1: print F1 exit() for i in xrange(2,N+1): tmp = F1 ^ F0 F1 ,F0 = tmp,F1 print F1