#include <iostream>
#define ll long long
using namespace std;
void solve(ll a,ll b,ll q)
{
if(q % 3 == 1) cout << a;
else if(q % 3 == 2) cout << b;
else{
cout << (a^b);
}
}
int main() {
ll a,b,q;
cin >> a >> b >> q;
solve(a,b,q);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojZGVmaW5lIGxsIGxvbmcgbG9uZwp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdm9pZCBzb2x2ZShsbCBhLGxsIGIsbGwgcSkKewoJaWYocSAlIDMgPT0gMSkJY291dCA8PCBhOwoJZWxzZSBpZihxICUgMyA9PSAyKQljb3V0IDw8IGI7CgllbHNlewoJCWNvdXQgPDwgKGFeYik7Cgl9Cn0KaW50IG1haW4oKSB7CglsbCBhLGIscTsKCWNpbiA+PiBhID4+IGIgPj4gcTsKCXNvbHZlKGEsYixxKTsKCXJldHVybiAwOwp9