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(); 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()); 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)); } }