#include using namespace std; using ll = long long; int main() { ll f0, f1, n; cin >> f0 >> f1 >> n; if (n == 2)cout << (f0 ^ f1) << endl; else if (n % 2 == 0)cout << f0 << endl; else cout << f1 << endl; }