#define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define MT make_tuple #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)<; using vi = vector; using vll = vector; long long A003815(long long n) { long long mod = n % 4; if (mod == 1) { return 1; } else if (mod == 2) { return n + 1; } else if (mod == 3) { return 0; } else { return n; } } void solve() { int N; cin >> N; ll ans = 0; rep(i, N) { ll K, L; int D; cin >> K >> L >> D; ll xum = 0; if (K % 2)xum = L & ((1ll << D) - 1); ll M = L >> D; ll yum = A003815(M + K - 1); if (M > 0)yum ^= A003815(M - 1); ans ^= xum + (yum << D); } cout << ans << endl; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15); solve(); return 0; }