#include #define rep(i, a) for (int i = 0; i < (a); i++) #define rep2(i, a, b) for (int i = (a); i < (b); i++) #define repr(i, a) for (int i = (a) - 1; i >= 0; i--) #define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--) using namespace std; typedef long long ll; const ll inf = 1e9; const ll mod = 1e9 + 7; int main() { ll F0, F1, N; cin >> F0 >> F1 >> N; ll F2 = F0 ^ F1; if (N % 3 == 0) { cout << F0 << endl; } else if (N % 3 == 1) { cout << F1 << endl; } else { cout << F2 << endl; } return 0; }