#include #include using namespace std; int main(void) { 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 printf("%lld\n", f0^f1); return 0; }