Journey from Petersburg to Moscow

Find the minimum cost path from city 1 to city n where only the k most expensive edges of the path are paid for, or all edges if the path has k or fewer.

Hard9GraphShortest pathSortingGreedyNo attempts yetTime limit3sMemory limit512 MB

Problem

A network of toll roads was built in the European part of Russia for the World Programming Cup 2112. The network consists of mm bidirectional roads that connect nn cities. Each road connects two distinct cities, no two roads connect the same pair of cities, and you can travel from any city to any other city using only this network. To keep charging simple, no two roads cross outside of the cities.

Every road has its own positive cost. Normally a driver who uses these toll roads pays the sum of the costs of all roads on the trip. To attract more car travel between the two capitals, the operator Radishchev Inc introduced a special offer: on a journey from Saint Petersburg to Moscow you pay only for the kk most expensive roads of your path.

More precisely, suppose a path consists of ll roads. Let c1c_1 be the cost of the most expensive road on the path, c2c_2 the cost of the second most expensive one, and so on, so that c1c2c3clc_1 \ge c_2 \ge c_3 \ge \dots \ge c_l. If lkl \le k, the path is too short for the offer and the driver pays the sum of all costs as usual, that is i=1lci\sum_{i=1}^{l} c_i. If l>kl > k, the driver pays only for the kk most expensive roads, that is i=1kci\sum_{i=1}^{k} c_i.

As the chief analyst of Radishchev Inc, compute the cheapest possible journey from Saint Petersburg to Moscow.

Input

The first line contains three integers nn, mm and kk (2n30002 \le n \le 3000, 1m30001 \le m \le 3000, 1k<n1 \le k < n): the number of cities, the number of roads, and the largest number of roads one pays for on a single journey.

Each of the next mm lines describes one road with three integers uiu_i, viv_i and wiw_i (1ui,vin1 \le u_i, v_i \le n, uiviu_i \ne v_i, 1wi1091 \le w_i \le 10^9): a bidirectional road between cities uiu_i and viv_i that costs wiw_i in either direction. At most one road connects each pair of cities, and the given roads let you reach every city from every other city.

Output

Print one integer, the minimum possible cost of a journey from city 11 (Saint Petersburg) to city nn (Moscow).