#include using namespace std; int main() { long long int N, F0, F1; cin >> F0 >> F1 >> N; switch( N % 3 ) { case 0: cout << F0 << endl; break; case 1: cout << F1 << endl; break; case 2: cout << (F1^F0) << endl; break; } return 0; }