N, V, L = map(int, input().split()) inf = 10**18 dp = [inf]*(V+1) dp[V] = 0 bx = 0 for _ in range(N): ndp = [inf] * (V+1) x, v, w = map(int, input().split()) for vl in range(V+1): if vl+(x-bx) > V: continue ndp[vl] = dp[vl+(x-bx)] for vl in range(V, -1, -1): vi = min(vl+v, V) ndp[vi] = min(ndp[vi], ndp[vl]+w) dp = ndp bx = x R = min(dp[L-bx:]) if R >= inf: print(-1) else: print(R)