Nindra finds themself in a city of nn buildings, with mm connections between them. Nindra is initially at building 00, and wants to reach building n1n-1. However, each of the connections has a weight ww, which refers to how tiring it is for them to traverse that edge. Therefore Nindra wants to travel from building 00 to building n1n-1 with the minimum total cost.

Luckily, Nindra has magic powers! They can ignore up to kk of the edge weights through this journey. As Nindra's ninja teacher, help them figure out the minimum cost they can take on this journey.

Input Format

The first line will consist of three integers, nn, mm and kk. The next mm lines will consist of 3 integers each, ii, jj and ww, representing there is a connection between buildings i and j of cost w.

Output Format

The output should consist of a single integer, the minimum cost. There will always be a possible route from building 00 to n1n-1.

Sample Input

Input 1
3 3 1
0 0 100
0 1 3
1 2 5

Sample Output

3

Sample Explanation

The best path for Nindra to take is 0->1->2, which is cost 3+5 = 8. However, Nindra uses their magical powers on the edge of weight 5, resulting in a total cost of 3.

Constraints

2n1e52 \le n \le 1e5

1k101 \le k \le 10

nm1e5n \le m \le 1e5

0i,jn10 \le i,j \le n-1

1w1e31 \le w \le 1e3

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.