#include int main(){ long long int a,b,c; scanf("%lld%lld%lld",&a,&b,&c); printf("%lld\n",c%3?c%3-1?a^b:b:a); return 0; }