def calc(S, v, w): T = sorted(S[:] + [(min(s[0] + v, V), s[1] + w) for s in S], key = lambda x: -x[0]) U = [] prew = 1 << 100 prev = 1 << 100 for t in T: if t[1] < prew: if t[0] == prev: U.pop() U.append(t) prew = t[1] prev = t[0] return U N, V, L = map(int, input().split()) S = [(V, 0)] prex = 0 for _ in range(N): x, v, w = map(int, input().split()) dx = x - prex prex = x S = [(v - dx, w) for v, w in S if v >= dx] S = calc(S, v, w) dx = L - prex A = [w for v, w in S if v >= dx] print(min(A) if A else -1)