#include using namespace std; using ll = long long; #define rep(i, s, e) for (int i = (int)s; i < (int)e; i++) int main() { cin.tie(nullptr); ll F0, F1, N; cin >> F0 >> F1 >> N; if (N % 3 == 0) cout << F0 << '\n'; else if (N % 3 == 1) cout << F1 << '\n'; else cout << (F0 ^ F1) << '\n'; }