#include <bits/stdc++.h>
#define intceil(a, b) ((a + b - 1) / b)
#define all(_) _.begin(), _.end()
using namespace std;
template <typename T>
inline void read(T &f) {
f = 0; T fu = 1; char c = getchar();
while (c < '0' || c > '9') { if (c == '-') { fu = -1; } c = getchar(); }
while (c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
f *= fu;
}
typedef long long LL;
typedef pair<int, int> PII;
const int N = 100010, M = 100010, INF = 0x3f3f3f3f;
int n, m, k;
int h[N], w[M], e[M], ne[M], idx, d[N], t[N];
void add(int a, int b, int c) {
e[idx] = b, w[idx] = c, ne[idx] = h[a], h[a] = idx++;
}
//请你求出从 1号点到 n号点的最多经过k条边的最短距离
bool bellman_ford(int s) {
memset(d, 0x3f, sizeof d);
d[s] = 0;
for(int i = 1; i <= k; i++) { //k轮
//复制当前状态到t数组
memcpy(t, d, sizeof d);
for(int u = 1; u <= n; u++) { //点
if(d[u] == INF) continue;
for(int i = h[u]; ~i; i = ne[i]) {
int v = e[i];
if(d[v] > t[u] + w[i]) {
d[v] = t[u] + w[i];
}
}
}
}
return d[n] < INF / 2;
}
int main() {
memset(h, -1, sizeof h);
cin >> n >> m >> k;
for(; m--; ) {
int x, y, z;
read(x), read(y), read(z);
add(x, y, z);
}
bellman_ford(1) ? printf("%d\n", d[n]) : puts("impossible");
}