#include #include using namespace std; #define DEBUG(x) cerr<<#x<<": "< #define vl vector #define vii vector< vector > #define vll vector< vector > #define vs vector #define pii pair #define pis pair #define psi pair #define pll pair template pair operator+(const pair &s, const pair &t) { return pair(s.first + t.first, s.second + t.second); } template pair operator-(const pair &s, const pair &t) { return pair(s.first - t.first, s.second - t.second); } template ostream& operator<<(ostream& os, pair p) { os << "(" << p.first << ", " << p.second << ")"; return os; } #define X first #define Y second #define rep(i,n) for(int i=0;i<(n);i++) #define rep1(i,n) for(int i=1;i<=(n);i++) #define rrep(i,n) for(int i=(n)-1;i>=0;i--) #define rrep1(i,n) for(int i=(n);i>0;i--) #define REP(i,a,b) for(int i=a;i bool chmax(T &a, const T &b) { if (a bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; } #define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end()); const ll inf = 1000000001; const ll INF = (ll)1e18 + 1; const ll MOD = 1000000007; //const ll MOD = 998244353; const double pi = 3.14159265358979323846; #define Sp(p) cout<> n; vl k(n), l(n), d(n); rep (i, n) { cin >> k[i] >> l[i] >> d[i]; } ll ans = 0; rep (bit, 60) { ll mask = 1LL << bit; ll cnt = 0; rep (i, n) { if (d[i] > bit) { if (mask & l[i]) { cnt = (cnt + k[i]) % 2; } } else { ll mask2 = mask; ll l2 = l[i]; l2 >>= d[i]; mask2 >>= d[i]; ll nokori = k[i]; if ((l2 & mask2) == 0) { ll sub = l2 % mask2; l2 -= sub; nokori += sub; } else { ll add = l2 % mask2; add = mask2 - add; if (add <= nokori) { nokori -= add; l2 += add; cnt = (cnt + add) % 2; } else { nokori = 0; cnt = (cnt + nokori) % 2; } } ll temp = nokori / (2*mask); cnt = (cnt + temp * mask) % 2; nokori %= (2*mask); nokori -= mask; if (nokori > 0) { cnt = (cnt + nokori) % 2; } } } if (cnt % 2) ans += mask; } cout << ans << endl; }