N,V,L = map(int,input().split()) A = [(0,0,0)]+[list(map(int,input().split())) for _ in range(N)]+[(L,0,0)] INFTY = 10**13 dp = [[INFTY for _ in range(V+1)] for _ in range(N+2)] for j in range(V+1): dp[0][j] = 0 for i in range(1,N+2): x0,v0,w0 = A[i-1] x1,v1,w1 = A[i] dx = x1-x0 for j in range(V-dx+1): dp[i][j] = dp[i-1][j+dx] if j+dx>=v0: dp[i][j] = min(dp[i][j],dp[i-1][j+dx-v0]+w0) ans = min(dp[N+1]) if ans>=INFTY: print(-1) else: print(ans)