#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define INF (1 << 30) #define INFLL (1LL << 60) int main() { long long f0,f1,n,x; cin >> f0 >> f1 >> n; if(n % 3 == 2) x = f0^f1; else if(n % 3 == 1) x = f1; else x = f0; cout << x << endl; return 0; }