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