N, V, L = map(int, input().split()) cx = 0 d = {} d[V] = 0 for _ in range(N): x, v, w = map(int, input().split()) nd = {} for k in d: t = k - (x - cx) if t < 0: continue if t not in nd or nd[t] > d[k]: nd[t] = d[k] t = min(t + v, V) if t not in nd or nd[t] > d[k] + w: nd[t] = d[k] + w if len(nd) == 0: print(-1) exit() d = nd cx = x result = float('inf') for k in d: if k - (L - cx) >= 0: result = min(result, d[k]) print(result)