#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;

typedef vector<ll> Array;
typedef vector<Array> Matrix;

ostream& operator<<(ostream &os, const Array &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
ostream& operator<<(ostream &os, const Matrix &t) {
FOR(it,t)os<<*it<<endl;return os;
}


Matrix mul(const Matrix &a,const Matrix &b){
	Matrix res(a.size(),Array(b[0].size(), -INF));
	REP(i,a.size()){
		REP(j,b[0].size()){
			REP(k,a[0].size()){
				res[i][j] = max(res[i][j], a[i][k]+b[k][j]);
			}
		}
	}
	return res;
}
Matrix pow(const Matrix &a,ll b){
	if(b==0){
		Matrix res(a.size(),Array(a.size(), -INF));
		REP(i,a.size())res[i][i]=0;
		return res;
	}
	Matrix res=pow(mul(a,a),b/2);
	if(b&1)res=mul(res,a);
	return res;
}

int N, M, K;

main(){
	cin >> N >> M >> K;
	Matrix one(N, Array(N, -INF));
	REP(i, N) one[i][i] = 0;
	REP(i, M){
		int u, v;
		ll x;
		cin >> u >> v >> x;
		one[u][v] = max(one[u][v], x);
	}

	int l = 0, r = 1000001;
	while(l<r-1){
		int med=(l+r)/2;
		Matrix res = pow(one, med);
		int f = 0;
		REP(i, N)REP(j, N) f |= res[i][j] >= K;
		if(f) r = med;
		else l = med;
	}
	
	if(r == 1000001) puts("-1");
	else printf("%d\n", r);
	if(r <= 100){
		vector<Matrix> Mats(r+1, Matrix(N, Array(N, -INF)));
		Mats[1] = one;
		REP(i, N) Mats[0][i][i] = 0;
		REP(i, r) Mats[i+1] = mul(Mats[i], Mats[1]);
		int st=0, ed=0, mx=Mats[r][0][0];
		REP(i, N)REP(j, N) if(Mats[r][i][j] > Mats[r][st][ed]) st=i,ed=j,mx=Mats[r][i][j];
		printf("%d", st);
		REP(i, r){
			int k = 0;
			REP(j, N) if(one[st][j] + Mats[r-i-1][j][ed] == mx){
				printf(" %d", j);
				mx -= one[st][j];
				st = j;
				break;
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 9560