import copy
n, m, k = map(int, input().strip().split(' '))
edges = [list(map(int, input().split(' '))) for _ in range(m)]
p = [1e11] * (n+1)
p[1] = 0
for i in range(k):
t = copy.deepcopy(p)
for a, b, w in edges:
p[b] = min(p[b], t[a] + w)
print('impossible' if p[-1] > 1e10 else p[-1])