#include <bits/stdc++.h> using namespace std; const int N = 550, M = 10010; struct Edges{int a, b, w;}edges[M]; int dist[N], pre[N]; int m, n, k; int bellman_ford() { memset(dist,0x3f,sizeof dist); dist[1] = 0; for(int i = 0; i < k; i++) { // 循环k次 memcpy(pre,dist,sizeof dist); // 备份数组 for(int j = 0; j < m; j++) { int a = edges[j].a, b = edges[j].b, w = edges[j].w; dist[b] = min(dist[b],pre[a] + w); } } if(dist[n] > 0x3f3f3f3f / 2 ) return -1; return dist[n]; } int main() { scanf("%d%d%d",&n,&m,&k); for(int i = 0; i < m; i++) { int a, b , c; scanf("%d%d%d",&a,&b,&c); edges[i] = {a,b,c}; } int t = bellman_ford(); if(t == -1) puts("impossible"); else printf("%d ",t); return 0; }