#include typedef long long ll; int main() { ll f[3], N; scanf( "%lld%lld%lld", f, f+1, &N ); f[2] = f[0]^f[1]; printf( "%lld\n", f[N%3] ); return 0; }