Xtreme NP-hard Problem?!

Find the minimum-weight simple path from vertex 1 to vertex n that uses exactly k edges, or report -1; with n, m, k up to 10^6 this is explicitly NP-hard.

Hard9GraphShortest pathDynamic programmingBrute forceNo attempts yetTime limit5sMemory limit1024 MB

Problem

Careful! This problem turned out to be NP-hard. No rule forbade setting an NP-hard problem, so it was left as it is.

You are given an undirected graph with nn vertices and mm edges. The vertices are numbered 1 to nn, the edges are numbered 1 to mm, and edge ii has weight wiw_i.

Given a natural number kk, find the length of the shortest simple path that starts at vertex 1, ends at vertex nn, and uses exactly kk edges.

A simple path is a path that never visits the same vertex twice, and the length of a path is the sum of the weights of the edges on it.

Input

The first line contains three integers nn, mm, kk separated by spaces.

The ii-th of the next mm lines contains three integers xix_i, yiy_i, wiw_i separated by spaces. This means edge ii joins vertex xix_i and vertex yiy_i and has weight wiw_i.

The graph contains no loops and no multiple edges.

Output

Print the length of the shortest simple path that starts at vertex 1, ends at vertex nn, and uses exactly kk edges. If no such path exists, print -1.

Constraints

  • 2n<1062 \le n < 10^6
  • 1m,k<1061 \le m, k < 10^6
  • 1xi,yin1 \le x_i, y_i \le n
  • xiyix_i \ne y_i (1im)(1 \le i \le m)
  • ij{xi,yi}{xj,yj}i \ne j \Rightarrow \{x_i, y_i\} \ne \{x_j, y_j\} (1i,jm)(1 \le i, j \le m)
  • 1wi1081 \le w_i \le 10^8