#include using namespace std; int main() { unsigned long long F0, F1, N; cin >> F0 >> F1 >> N; if (N % 3 == 0) { cout << F0 << endl; } else if (N % 3 == 1) { cout << F1 << endl; } else { unsigned long long ans; ans = F0 ^ F1; cout << ans << endl; } return 0; }