#include #include #include #include #include #include #include #include #include using namespace std; int main(){ long long F[2]; long long N; cin >> F[0] >> F[1] >> N; if(N%3LL == 0){ cout << F[0] << endl; }else if(N%3LL == 1){ cout << F[1] << endl; }else{ cout << (F[0] ^ F[1]) << endl; } return 0; }