N,V,L=map(int,input().split()) inf=1<<60 dp=[inf]*(V+1) dp[V]=0 cur=0 for i in range(N): x,v,w=map(int,input().split()) prev=dp dp=[inf]*(V+1) for c in range(x-cur,V+1): dp[c-(x-cur)]=prev[c] prev=dp dp=[inf]*(V+1) for c in range(V+1): dp[c]=min(dp[c],prev[c]) dp[min(c+v,V)]=min(dp[min(c+v,V)],prev[c]+w) cur=x ans=inf for v in range(V+1): if v>=L-cur: ans=min(ans,dp[v]) if ans==inf: ans=-1 print(ans)