import sys def input(): return sys.stdin.readline()[:-1] n, v, l = map(int, input().split()) dp = [[10**15 for _ in range(v+1)] for _ in range(n+1)] gas = [[0, 0, 10**15]] + [list(map(int, input().split())) for _ in range(n)] dp[0][v] = 0 for i in range(1, n+1): for j in range(v - gas[i][0] + gas[i-1][0] + 1): dp[i][j] = dp[i-1][j + gas[i][0] - gas[i-1][0]] for j in range(v, gas[i][1]-1, -1): dp[i][j] = min(dp[i][j], dp[i][j - gas[i][1]] + gas[i][2]) ans = 10**15 for j in range(v, l - gas[n][0] - 1, -1): ans = min(ans, dp[n][j]) if ans > 10**14: print(-1) else: print(ans)