N, V, L = map(int, input().split()) gas = [list(map(int, input().split())) for _ in range(N)] dp = [[float('inf')]*(V+1) for _ in range(N+1)] dp[0][-1] = 0 posi = 0 for i in range(1,N+1): x, v, w = gas[i-1] use = x-posi for j in range(V,-1,-1): if j-use>=0: dp[i][j-use] = min(dp[i][j-use],dp[i-1][j]) dp[i][min(V,j-use+v)] = min(dp[i][min(V,j-use+v)],dp[i-1][j]+w) posi = x res = float('inf') if L-posi>V: print(-1) else: for i in range(L-posi,V+1): res = min(res, dp[-1][i]) print(-1 if res==float('inf') else res)