def xor(n): mod = n % 4 if mod == 0: return n elif mod == 1: return 1 elif mod == 2: return n + 1 else: return 0 def main(): import sys input = sys.stdin.read().split() ptr = 0 N = int(input[ptr]) ptr += 1 x = 0 for _ in range(N): K = int(input[ptr]) L = int(input[ptr+1]) D = int(input[ptr+2]) ptr += 3 s = 1 << D H = L // s a = H b = H + K - 1 if a == 0: higher = xor(b) else: higher = xor(b) ^ xor(a - 1) if K % 2 == 1: lower = L % s else: lower = 0 contribution = lower | (higher << D) x ^= contribution print(x) if __name__ == "__main__": main()