n,v,l = map(int,input().split()) xvw = [[int(i) for i in input().split()] for j in range(n)] dp = [10**15]*(v+1) dp[v] = 0 pos = 0 #print(dp) for i in range(n): x,vi,wi = xvw[i] dis = x-pos for j in range(v+1): if dis > j: dp[j] = 10**15 else: dp[j-dis] = dp[j] if dis != 0: dp[j] = 10**15 #print(dis) #print(dp,111) for j in range(v+1): dp[min(v,j+vi)] = min(dp[j]+wi,dp[min(v,j+vi)]) pos = x #print(dp,i) #print(dp) #exit() if pos != l: dis = l-pos ans = 10**15 for j in range(v+1): if dis <= j: ans = min(ans,dp[j]) else: ans = min(dp) if ans >= 10**15: print(-1) else: print(ans)