#include using namespace std; typedef long long LL; int n, d; LL ans, l, k; LL Calc() { LL ret = 0LL; LL ll = l >> d, kk = k, pw = 1LL << d; for (LL i = ll; (i % 4 != 0 || i == 0) && i < ll + k; ++i) { ret ^= l + pw * (i - ll); --kk; } for (LL i = ll + k - kk % 4; i < ll + k; ++i) ret ^= l + pw * (i - ll); return ret; } int main() { // freopen("card.in", "r", stdin); // freopen("card.out", "w", stdout); scanf("%d", &n); while (n--) { scanf("%lld%lld%d", &k, &l, &d); ans ^= Calc(); } printf("%lld\n", ans); return 0; }