#include<bits/stdc++.h>
#define ALL(x) (x).begin(),(x).end()
#define ll long long
#define db double
#define ull unsigned long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
int n = 100;
struct Matrix
{
ll mat[100][100];
//Matrix() {memset(mat,0,sizeof(mat));}
/*Matrix operator * (Matrix b)
{
Matrix res;
rep(i,0,n-1) rep(j,0,n-1) rep(k,0,n-1) res.mat[i][j] = (res.mat[i][j] + mat[i][k]*b.mat[k][j]%M)%M;
return res;
}*/
Matrix() {rep(i,0,n-1) rep(j,0,n-1) mat[i][j] = INF;}
Matrix operator * (Matrix b)
{
Matrix res;
rep(k,0,n-1){
rep(i,0,n-1) rep(j,0,n-1) {
res.mat[i][j] = min(res.mat[i][j],mat[i][k]+b.mat[k][j]);
}
}
return res;
}
Matrix operator ^ (ll b)
{
Matrix res,A=*this;
rep(i,0,n-1) rep(j,0,n-1) res.mat[i][j] = (i!=j)*INF;
while(b){
if(b&1) res = res*A;
A = A*A;
b>>=1;
}return res;
}
};
int main()
{
fastio();
int m,k; cin>>n>>m>>k;
Matrix A;
while(m--){ int u,v,w;
cin>>u>>v>>w; u--,v--;
A.mat[u][v] = w;
}
A = A^k;
ll ans = INF;
rep(i,0,n-1) rep(j,0,n-1) ans = min(ans,A.mat[i][j]);
if(ans>1e18) cout<<"IMPOSSIBLE"<<endl;else cout<<ans<<endl;
return 0;
}