def xor_upto(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 total_xor = 0 for _ in range(N): K_i = int(input[ptr]) L_i = int(input[ptr+1]) D_i = int(input[ptr+2]) ptr +=3 s = 1 << D_i a_low = L_i & (s -1) a_high = L_i >> D_i K = K_i lower_xor = a_low if K % 2 else 0 higher_start = a_high higher_end = a_high + K -1 if higher_start > higher_end: higher_xor = 0 else: xor_end = xor_upto(higher_end) xor_start = xor_upto(higher_start -1) higher_xor = xor_end ^ xor_start higher_xor_part = higher_xor * s player_xor = lower_xor ^ higher_xor_part total_xor ^= player_xor print(total_xor) if __name__ == "__main__": main()