N, V, L = map(int, input().split()) x = [[0, 0] for i in range(L + 1)] # 容量 かかる費用 for i in range(N): t, m, p = map(int, input().split()) x[t] = [m, p] dp = [[[float('inf'), True] for i in range(V + 1)] for j in range(L + 1)] dp[0][V] = [0, True] for i in range(L): for j in range(V + 1): if dp[i][j][0] != float('inf'): if dp[i][j][1]: dp[i][min(x[i][0] + j, V)][0] = min(dp[i][j][0] + x[i][1], dp[i][min(x[i][0] + j, V)][0]) dp[i][min(x[i][0] + j, V)][1] = False if j > 0: dp[i + 1][j - 1][0] = min(dp[i + 1][j - 1][0], dp[i][j][0]) ans = float('inf') for i in dp[L]: ans = min(ans, i[0]) print(ans if ans != float('inf') else -1)