N, V, L = map(int, input().split()) x = [] for i in range(N): t, m, p = map(int, input().split()) if m == 0: continue x.append([t, m, p]) dp = [[float('inf') for i in range(V + 1)] for j in range(L + 1)] dp[0][V] = 0 for i in range(L): for j in range(1, V + 1): if dp[i][j] != float('inf'): for k in range(len(x)): if x[k][0] == i + 1: dp[i + 1][min(j - 1 + x[k][1], V)] = min(dp[i + 1][min(j - 1 + x[k][1], V)], dp[i][j] + x[k][2]) dp[i + 1][j - 1] = dp[i][j] ans = float('inf') for i in dp[L]: ans = min(ans, i) print(ans if ans != float('inf') else -1)