n,V,l = map(int,input().split()) XVW = [list(map(int,input().split())) for i in range(n)] inf = 10**15 dp = [inf]*(V+1) dp[V] = 0 now = 0 for x,v,w in XVW: dif = x-now now = x ndp = [inf]*(V+1) mi = inf for j in range(dif,V+1)[::-1]: if dp[j] == inf: continue mi = min(mi,dp[j]) ndp[j-dif] = min(ndp[j-dif],dp[j]) ndp[min(j-dif+v,V)] = min(ndp[min(j-dif+v,V)],dp[j]+w) dp = ndp dif = l-now ans = inf for i in range(dif,V+1): ans = min(ans,dp[i]) if ans == inf: ans = -1 print(ans)