#include using namespace std; typedef pair pii; typedef long long int ll; int main() { cin.tie(0); ios::sync_with_stdio(false); ll a, b, c, n; cin >> a >> b >> n; if (n % 3 == 0) cout << a << endl; else if (n % 3 == 1) cout << b << endl; else if (n %3 == 2) cout << (a^b) << endl; }