import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().run(); } public void run() { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); if (!(1 <= N && N <= 3 * 100000)) throw new AssertionError(); long x = 0; for (int i = 0; i < N; ++i) { long K = Long.parseLong(sc.next()); long L = Long.parseLong(sc.next()); long D = Long.parseLong(sc.next()); if (!(K >= 1) || !(0 <= D && D <= 59) || !(0 <= L && L + (K - 1) * (1L << D) <= 1e18)) throw new AssertionError(); x ^= K % 2 * (L & ((1L << D) - 1)); L >>= D; for (long j = L; j <= L + K - 1; ++j) { if (j % 4 == 0) { j = (L + K - 1) / 4 * 4; } x ^= j << D; } } System.out.println(x); } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }