#include "bits/stdc++.h" using namespace std; long f(long x) { if (x % 4 == 0) { return x; } else if (x % 4 == 1) { return 1L; } else if (x % 4 == 2) { return x + 1; } else { return 0L; } } void solve() { int n; cin >> n; long ans = 0; while(n--) { long k, l, d; cin >> k >> l >> d; long sl = l >> d, res = f(max(sl-1, 0L)) ^ f(sl + k - 1); ans ^= res << d; if (k & 1) { ans ^= l ^ (sl << d); } } cout << ans << endl; } int main() { solve(); //cout << "yui(*-v・)yui" << endl; return 0; }