N, V, L = list(map(int, input().split())) shop_list = [list(map(int, input().split())) for i in range(N)] + [[L, 0, 0]] dis_list = [shop_list[0][0]] + [(shop_list[i + 1][0] - shop_list[i][0]) for i in range(len(shop_list) - 1)] dp_list = [[float("inf")] * (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): dp_list[n + 1][v - dis_list[n]] = min([dp_list[n + 1][v - dis_list[n]], dp_list[n][v]]) gas = min([V, v - dis_list[n] + shop_list[n][1]]) dp_list[n + 1][gas] = min([dp_list[n + 1][gas], dp_list[n][v] + shop_list[n][2]]) ans = min(dp_list[-1]) if min(dp_list[-1]) == float("inf"): print(-1) else: print(ans)