N, V, L = list(map(int, input().split())) shop_list = [list(map(int, input().split())) for i in range(N)] + [[0, 0, 0]] dis_list = [shop_list[0][0]] + [(shop_list[i + 1][0] - shop_list[i][0]) for i in range(len(shop_list) - 2)] + [L - shop_list[-2][0]] dp_list = [[float("inf") for i in range(V + 1)] for j in range(N + 2)] dp_list[0][V] = 0 for n in range(N + 1): for v in range(dis_list[n], V + 1): print(n, v) dp_list[n + 1][v - dis_list[n]] = min([dp_list[n + 1][v - dis_list[n]], dp_list[n][v]]) dp_list[n + 1][min([V, v - dis_list[n] + shop_list[n][1]]) ] = min([dp_list[n + 1][min([V, v - dis_list[n] + shop_list[n][1]])], dp_list[n][v] + shop_list[n][2]]) print(min(dp_list[N + 1]) if min(dp_list[N + 1]) != float("inf") else -1)