#include using namespace std; typedef long long ll; typedef pair l_l; #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) //const ll mod = 1000000007; ll g(ll K, ll L, ll D) { L = (L >> D); ll ret = 0; if(L % 2 == 1) { L--; K++; } for(ll i = (K / 4) * 4; i < K; i++) { ret ^= (L + i); } return (ret << D); } ll f(ll K, ll L, ll D) { ll buf = g(K, L, D); ll mask = 0; for(int i = 0; i < D; i++) { mask = (mask << 1) | (ll)1; } if(K % 2 == 0) mask = 0; return buf | (mask & L); } int main() { //cout.precision(10); cin.tie(0); ios::sync_with_stdio(false); ll N; cin >> N; ll ans = 0; while(N--) { ll K, L, D; cin >> K >> L >> D; ans = ans ^ f(K, L, D); } cout << ans << endl; return 0; }