#include using namespace std; int main() { long long f[3] = {}; long long n; cin >> f[0] >> f[1] >> n; f[2] = f[0] ^ f[1]; cout << f[n % 3] << endl; return 0; }