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): if vl-v < 0: continue ndp[vl] = min(ndp[vl], ndp[vl-v]+w) dp = ndp bx = x R = inf for i in range(L-bx, V+1): R = min(R, dp[i]) if R == inf: print(-1) else: print(R)