#include #define rep(i, n) for(long long i = 0; i < (long long)n; i++) #define ALL(v) (v).begin(), (v).end() #define rALL(v) (v).rbegin(), (v).rend() using namespace std; using lint = long long; int main() { lint f0, f1, n; cin >> f0 >> f1 >> n; lint ans = 0; rep(i, 62) { lint x = (f0 & (1LL << i) ? 1 : 0), y = (f1 & (1LL << i) ? 1 : 0); if (x == 0 && y == 1) { if (n % 3 != 0) { ans |= (1LL << i); } } else if (x == 1 && y == 0) { if (n % 3 != 1) { ans |= (1LL << i); } } else if (x == 1 && y == 1) { if (n % 3 != 2) { ans |= (1LL << i); } } } cout << ans << endl; }