#include using namespace std; void solve() { unsigned long long N; vector v(3); cin >> v[0] >> v[1]; v[2] = v[0] ^ v[1]; cin >> N; cout << v[(N % 3)] << endl; } int main() { ios::sync_with_stdio(false); cin.tie(0); solve(); getchar(); }