#include using namespace std; typedef long long ll; int solve(int f0, int f1, ll N) { if (f0 == 0 && f1 == 0) { return 0; } int idx = 0; if (f0 == 0 && f1 == 1) { idx = 2; } else if (f0 == 1 && f1 == 0) { idx = 1; } int a = (N + idx) % 3; return a == 2 ? 0 : 1; } int main() { ll f0, f1, N; cin >> f0 >> f1 >> N; ll f = 0; for (int i = 0; (1LL << i) <= max(f0, f1); ++i) { int a = (f0 & (1LL << i)) ? 1 : 0; int b = (f1 & (1LL << i)) ? 1 : 0; f |= (ll)solve(a, b, N) << i; } cout << f << endl; }