import heapq N,Y,Z = map(int,input().split()) A = sorted([list(map(int,input().split())) for _ in range(N)],key=lambda x:x[1]) cur = Y iLev = -1 heap = [] for i in range(N): c,l,x = A[i] if cur>=l: heapq.heappush(heap,(-x,c)) iLev = i if iLev<0: print(-1) else: ans = 0 flag = -1 if iLev=Z: flag = ans break if c>0: heapq.heappush(heap,(-x,c)) iLev += 1 if iLev