#include <array>
#include <cassert>
#include <cstdio>
#include <stack>
#include <vector>
#ifndef _TJYTLXWXHYZQFW_COMMON_H
#define _TJYTLXWXHYZQFW_COMMON_H
#include <climits>
#define ULL1 ((unsigned long long )1)
#define LL(x) ((long long)(x))
#define IOF(p) ((p) = ((p) < 0 ? INT_MAX : (p)))
#define LLOF(p) ((p) = ((p) < 0 ? LLONG_MAX :(p)))
#define ir(x, start, end) ((x) >= (start) && (x) < (end))
#define ire(x, start, end) ((x) >= (start) && (x) <= (end))
#define odd(x) ((x) & 1UL)
#define even(x) (!odd((x)))
#define sgn(n) (odd((n)) ? (-1) : (1))
#define abv(x) ((x) < 0 ? (x) * (-1) : (x))
#define forn(i, n) for ((i) = 0; (i) < (n); (i) += 1)
#define fore(i, n) for ((i) = 0; (i) <= (n); (i) += 1)
#define forr(i, s, e) for((i) = (s); (i) < (e); (i) += 1)
#define forre(i, s, e) for((i) = (s); (i) <= (e); (i) += 1)
#define rforre(i, b, e) for ((i) = (b); (i) >= (e); (i) -= 1)
#define tailer(i, j) ((i) == (j) ? "\n" : " ")
#define access(_a, _i, _n, _obv) (ir((_i), 0, (_n)) ? (_a)[(_i)] : (_obv))
#define vecsize(t) vector<t>::size_type
#define veciter(t) vector<t>::iterator
#endif
#define foreach(_i, _c) for((_i) = (_c).begin(); (_i) != (_c).end(); ++(_i))
using namespace std;
#define T 1000000001
#define N 5000
struct succer {
	int id;
	int cost;
	succer(int idx, int cst) {
		id = idx;
		cost = cst;
	}
};
int n, m, t;
array<array<int, N+1>, N> dp;
array<array<int, N+1>, N> path;
array<vector<succer>, N> nexts;
array<int, N> top;
void topsort(void)
{
	array<int, N> indg;
	stack<int> stk;
	veciter(succer) it;
	int topi, i, next;
	forn(i, n) foreach(it, nexts[i]) indg[it->id] = 0;
	forn(i, n) foreach(it, nexts[i]) indg[it->id] += 1;
	forn(i, n) if (indg[i] == 0) stk.push(i);
	topi = 0;
	while (not stk.empty()) {
		i = stk.top();
		stk.pop();
		top[topi++] = i;
		foreach(it, nexts[i]) {
			next = it->id;
			--indg[next];
			if (indg[next] == 0)
				stk.push(next);
		}
	}
	assert(topi == n);
	forn(i, n) printf("%d%s", top[i], tailer(i, n-1));
}
int main(void)
{
	int i, j, k, ti, to;
	int left, right;
	int cost;
	veciter(succer) it;
	freopen("Inputs/721C", "r", stdin);
	scanf("%d%d%d", &n, &m, &t);
	forn(i, m) {
		scanf("%d%d%d", &left, &right, &cost);
		--left, --right;
		nexts[left].push_back(succer(right, cost));
	}
	topsort();
	//while (1);
	rforre(ti, n-1, 0) {
		i = top[ti];
		dp[i][1] = (i == n-1 ? 0 : T);
		forre(j, 2, n) {
			dp[i][j] = T;
			foreach(it, nexts[i]) {
				k = it->id;
				if (dp[k][j-1] < T) {
					dp[i][j] = min(dp[i][j], it->cost + dp[k][j-1]);
					to = k;
				}
			}
			path[i][j] = to;
		}
	}
	while (1);
	i = 0;
	for (j = n; j >= 1; --j)
		if (dp[i][j] <= t) break;
	assert(j >= 1);
	printf("%d\n", j);
	while (1);
	while (i != n-1) {
		printf("%d ", i+1);
		i = path[i][j];
		--j;
	}
	printf("%d\n", n);
	return 0;
}


#include <array>
#include <cassert>
#include <cstdio>
#include <stack>
#include <vector>
#ifndef _TJYTLXWXHYZQFW_COMMON_H
#define _TJYTLXWXHYZQFW_COMMON_H
#include <climits>
#define ULL1 ((unsigned long long )1)
#define LL(x) ((long long)(x))
#define IOF(p) ((p) = ((p) < 0 ? INT_MAX : (p)))
#define LLOF(p) ((p) = ((p) < 0 ? LLONG_MAX :(p)))
#define ir(x, start, end) ((x) >= (start) && (x) < (end))
#define ire(x, start, end) ((x) >= (start) && (x) <= (end))
#define odd(x) ((x) & 1UL)
#define even(x) (!odd((x)))
#define sgn(n) (odd((n)) ? (-1) : (1))
#define abv(x) ((x) < 0 ? (x) * (-1) : (x))
#define forn(i, n) for ((i) = 0; (i) < (n); (i) += 1)
#define fore(i, n) for ((i) = 0; (i) <= (n); (i) += 1)
#define forr(i, s, e) for((i) = (s); (i) < (e); (i) += 1)
#define forre(i, s, e) for((i) = (s); (i) <= (e); (i) += 1)
#define rforre(i, b, e) for ((i) = (b); (i) >= (e); (i) -= 1)
#define tailer(i, j) ((i) == (j) ? "\n" : " ")
#define access(_a, _i, _n, _obv) (ir((_i), 0, (_n)) ? (_a)[(_i)] : (_obv))
#define vecsize(t) vector<t>::size_type
#define veciter(t) vector<t>::iterator
#endif
#define foreach(_i, _c) for((_i) = (_c).begin(); (_i) != (_c).end(); ++(_i))
using namespace std;
#define T 1000000001
#define N 5000
struct succer {
	int id;
	int cost;
	succer(int idx, int cst) {
		id = idx;
		cost = cst;
	}
};
int n, m, t;
array<array<int, N+1>, N> dp;
array<array<int, N+1>, N> path;
array<vector<succer>, N> nexts;
array<int, N> top;
void topsort(void)
{
	array<int, N> indg;
	stack<int> stk;
	veciter(succer) it;
	int topi, i, next;
	forn(i, n) foreach(it, nexts[i]) indg[it->id] = 0;
	forn(i, n) foreach(it, nexts[i]) indg[it->id] += 1;
	forn(i, n) if (indg[i] == 0) stk.push(i);
	topi = 0;
	while (not stk.empty()) {
		i = stk.top();
		stk.pop();
		top[topi++] = i;
		foreach(it, nexts[i]) {
			next = it->id;
			--indg[next];
			if (indg[next] == 0)
				stk.push(next);
		}
	}
	assert(topi == n);
}
int main(void)
{
	int i, j, k, ti, to;
	int left, right;
	int cost;
	veciter(succer) it;
	scanf("%d%d%d", &n, &m, &t);
	forn(i, m) {
		scanf("%d%d%d", &left, &right, &cost);
		--left, --right;
		nexts[left].push_back(succer(right, cost));
	}
	topsort();
	while (1);
	printf("after topsort: n: %d\n", n);
	rforre(ti, n-1, 0) {
		i = top[ti];
		dp[i][1] = (i == n-1 ? 0 : T);
		forre(j, 2, n) {
			dp[i][j] = T;
			foreach(it, nexts[i]) {
				k = it->id;
				if (dp[k][j-1] < T) {
					dp[i][j] = min(dp[i][j], it->cost + dp[k][j-1]);
					to = k;
				}
			}
			path[i][j] = to;
		}
	}
	printf("after dp: n: %d\n", n);
	i = 0;
	rforre(j, 4, 1)
		if (dp[i][j] <= t) break;
	assert(j >= 1);
	return 0;
}


#include <algorithm>
#include <cassert>
#include <cstdio>
#include <map>
#include <stack>
#include <string>
#include <vector>
#ifndef _TJYTLXWXHYZQFW_COMMON_H
#define _TJYTLXWXHYZQFW_COMMON_H
#include <algorithm>
#include <climits>
#define ULL1 ((unsigned long long )1)
#define LL(x) ((long long)(x))
#define IOF(p) ((p) = ((p) < 0 ? INT_MAX : (p)))
#define LLOF(p) ((p) = ((p) < 0 ? LLONG_MAX :(p)))
#define ir(x, start, end) ((x) >= (start) && (x) < (end))
#define ire(x, start, end) ((x) >= (start) && (x) <= (end))
#define odd(x) ((x) & 1UL)
#define even(x) (!odd((x)))
#define sgn(n) (odd((n)) ? (-1) : (1))
#define max3(a, b, c) std::max(std::max((a),(b)), (c))
#define abv(x) ((x) < 0 ? (x) * (-1) : (x))
#define forn(_i, _n) for ((_i) = 0; (_i) < (_n); (_i) += 1)
#define fore(_i, _n) for ((_i) = 0; (_i) <= (_n); (_i) += 1)
#define forr(_i, _s, _e) for((_i) = (_s); (_i) < (_e); (_i) += 1)
#define forre(_i, _s, _e) for((_i) = (_s); (_i) <= (_e); (_i) += 1)
#define rfor(_i, _n) for((_i)=(_n)-1; ((_i) >= 0); (_i) -= 1)
#define rfore(_i, _n) for((_i)=(_n); (_i) >= 0; (_i) -= 1)
#define rforre(_i, _b, _e) for ((_i) = (_b); (_i) >= (_e); (_i) -= 1)
#define tailer(i, j) ((i) == (j) ? "\n" : " ")
#define access(_a, _i, _n, _obv) (ir((_i), 0, (_n)) ? (_a)[(_i)] : (_obv))
#define vecsize(t) vector<t>::size_type
#define veciter(t) vector<t>::iterator
#define foriter(_i, _c) for((_i) = (_c).begin(); (_i) != (_c).end(); ++(_i))
#endif
using namespace std;
#define N 5000
const int large = 1000000001;
struct append {
	int id, cost;
	append(int i, int c) {
		id = i;
		cost = c;
	}
};
int n, m, t;
vector<vector<append>> graph(N);
vector<int> top;
int s[N][N+1], x[N][N+1];
void topsort(void) {
	int i, inds[N];
	stack<int> stk;
	vector<append>::iterator nxt;
	vector<append> *nxts;
	forn(i, n) inds[i] = 0;
	forn(i, n) {
		nxts = &graph[i];
		for (nxt = nxts->begin(); nxt != nxts->end(); ++nxt) ++inds[nxt->id];
	}
	forn(i, n) if (inds[i] == 0) stk.push(i);
	while (!stk.empty()) {
		i = stk.top();
		stk.pop();
		top.push_back(i);
		nxts = &graph[i];
		for (nxt = nxts->begin(); nxt != nxts->end(); ++nxt) {
			--inds[nxt->id];
			if (inds[nxt->id] == 0) stk.push(nxt->id);
		}
	}
	assert((int)top.size() == n);
}
bool read(void) {
	int i, j, left, rght, cost;
	forn(i, n) fore(j, m) x[i][j] = -1;
	forn(i, N) graph[i].clear();
	top.clear();
	if (scanf("%d%d%d", &n, &m, &t) != 3)
		return false;
	forn(i, m) {
		scanf("%d%d%d", &left, &rght, &cost);
		--left, --rght;
		graph[left].push_back(append(rght, cost));
	}
	return true;
}
void print_path(int i, int j) {
	if (i == -1 || j <= 0) {
		printf("\n");
		return;
	}
	printf("%d ", i+1);
	print_path(x[i][j], j-1);
}
inline void print_s(int i, int j) {
	//printf("s[%2d][%2d]: %d\n", i+1, j, s[i][j]);
}
void solve(void) {
	int i, j, u, c;
	vector<append>::iterator v;
	vector<append> *nxts;
	s[n-1][1] = 0;
	forre(j, 2, m) s[n-1][j] = large;
	forre(j, 1, m) print_s(n-1, j);
	topsort();
	rfor(i, n) {
		u = top[i];
		if (u == n-1) continue;
		s[u][1] = large;
		print_s(u, 1);
		forre(j, 2, m) {
			s[u][j] = large;
			nxts = &graph[u];
			for (v = nxts->begin(); v != nxts->end(); ++v) {
				c = v->cost + s[v->id][j-1];
				if (s[u][j] > c) s[u][j] = c, x[u][j] = v->id;
			}
			print_s(u, j);
		}
	}
	rforre(j, m, 1) {
		if (n == 1000 && m == 999) {
			forn(i, n) {
				forre(j, 1, m) {
					if (s[i][j] != large)
						printf("%2d, %2d: %d\n", i+1, j, s[i][j]);
				}
			}
		}
		print_s(0, j);
		if (s[0][j] <= t) break;
	}
	printf("%d\n", j);
	if (j >= 0) print_path(0, j);
}
int main(void) {
	while (read()) solve();
	return 0;
}


#include <array>
#include <cassert>
#include <cstdio>
#include <stack>
#include <vector>
#ifndef _TJYTLXWXHYZQFW_COMMON_H
#define _TJYTLXWXHYZQFW_COMMON_H
#include <climits>
#define ULL1 ((unsigned long long )1)
#define LL(x) ((long long)(x))
#define IOF(p) ((p) = ((p) < 0 ? INT_MAX : (p)))
#define LLOF(p) ((p) = ((p) < 0 ? LLONG_MAX :(p)))
#define ir(x, start, end) ((x) >= (start) && (x) < (end))
#define ire(x, start, end) ((x) >= (start) && (x) <= (end))
#define odd(x) ((x) & 1UL)
#define even(x) (!odd((x)))
#define sgn(n) (odd((n)) ? (-1) : (1))
#define abv(x) ((x) < 0 ? (x) * (-1) : (x))
#define forn(i, n) for ((i) = 0; (i) < (n); (i) += 1)
#define fore(i, n) for ((i) = 0; (i) <= (n); (i) += 1)
#define forr(i, s, e) for((i) = (s); (i) < (e); (i) += 1)
#define forre(i, s, e) for((i) = (s); (i) <= (e); (i) += 1)
#define rforre(i, b, e) for ((i) = (b); (i) >= (e); (i) -= 1)
#define tailer(i, j) ((i) == (j) ? "\n" : " ")
#define access(_a, _i, _n, _obv) (ir((_i), 0, (_n)) ? (_a)[(_i)] : (_obv))
#define vecsize(t) vector<t>::size_type
#define veciter(t) vector<t>::iterator
#endif
#define foreach(_i, _c) for((_i) = (_c).begin(); (_i) != (_c).end(); ++(_i))
using namespace std;
#define T 1000000001
#define N 5000
struct succer {
	int id;
	int cost;
	succer(int idx, int cst) {
		id = idx;
		cost = cst;
	}
};
int n, m, t;
array<array<int, N+1>, N> dp;
array<array<int, N+1>, N> path;
array<vector<succer>, N> nexts;
array<int, N> top;
void topsort(void)
{
	array<int, N> indg;
	stack<int> stk;
	veciter(succer) it;
	int topi, i, next;
	forn(i, n) foreach(it, nexts[i]) indg[it->id] = 0;
	forn(i, n) foreach(it, nexts[i]) indg[it->id] += 1;
	forn(i, n) if (indg[i] == 0) stk.push(i);
	topi = 0;
	while (not stk.empty()) {
		i = stk.top();
		stk.pop();
		top[topi++] = i;
		foreach(it, nexts[i]) {
			next = it->id;
			--indg[next];
			if (indg[next] == 0)
				stk.push(next);
		}
	}
	assert(topi == n);
	forn(i, n) printf("%d%s", top[i], tailer(i, n-1));
}
int main(void)
{
	int i, j, k, ti, to;
	int left, right;
	int cost;
	veciter(succer) it;
	freopen("Inputs/721C", "r", stdin);
	scanf("%d%d%d", &n, &m, &t);
	forn(i, m) {
		scanf("%d%d%d", &left, &right, &cost);
		--left, --right;
		nexts[left].push_back(succer(right, cost));
	}
	topsort();
	//while (1);
	rforre(ti, n-1, 0) {
		i = top[ti];
		dp[i][1] = (i == n-1 ? 0 : T);
		forre(j, 2, n) {
			dp[i][j] = T;
			foreach(it, nexts[i]) {
				k = it->id;
				if (dp[k][j-1] < T) {
					dp[i][j] = min(dp[i][j], it->cost + dp[k][j-1]);
					to = k;
				}
			}
			path[i][j] = to;
		}
	}
	//while (1);
	i = 0;
	for (j = n; j >= 1; --j)
		if (dp[i][j] <= t) break;
	assert(j >= 1);
	printf("%d\n", j);
	while (1);
	while (i != n-1) {
		printf("%d ", i+1);
		i = path[i][j];
		--j;
	}
	printf("%d\n", n);
	return 0;
}


#include <algorithm>
#include <cassert>
#include <cstdio>
#include <map>
#include <stack>
#include <string>
#include <vector>
#ifndef _TJYTLXWXHYZQFW_COMMON_H
#define _TJYTLXWXHYZQFW_COMMON_H
#include <algorithm>
#include <climits>
#define ULL1 ((unsigned long long )1)
#define LL(x) ((long long)(x))
#define IOF(p) ((p) = ((p) < 0 ? INT_MAX : (p)))
#define LLOF(p) ((p) = ((p) < 0 ? LLONG_MAX :(p)))
#define ir(x, start, end) ((x) >= (start) && (x) < (end))
#define ire(x, start, end) ((x) >= (start) && (x) <= (end))
#define odd(x) ((x) & 1UL)
#define even(x) (!odd((x)))
#define sgn(n) (odd((n)) ? (-1) : (1))
#define max3(a, b, c) std::max(std::max((a),(b)), (c))
#define abv(x) ((x) < 0 ? (x) * (-1) : (x))
#define forn(_i, _n) for ((_i) = 0; (_i) < (_n); (_i) += 1)
#define fore(_i, _n) for ((_i) = 0; (_i) <= (_n); (_i) += 1)
#define forr(_i, _s, _e) for((_i) = (_s); (_i) < (_e); (_i) += 1)
#define forre(_i, _s, _e) for((_i) = (_s); (_i) <= (_e); (_i) += 1)
#define rfor(_i, _n) for((_i)=(_n)-1; ((_i) >= 0); (_i) -= 1)
#define rfore(_i, _n) for((_i)=(_n); (_i) >= 0; (_i) -= 1)
#define rforre(_i, _b, _e) for ((_i) = (_b); (_i) >= (_e); (_i) -= 1)
#define tailer(i, j) ((i) == (j) ? "\n" : " ")
#define access(_a, _i, _n, _obv) (ir((_i), 0, (_n)) ? (_a)[(_i)] : (_obv))
#define vecsize(t) vector<t>::size_type
#define veciter(t) vector<t>::iterator
#define foriter(_i, _c) for((_i) = (_c).begin(); (_i) != (_c).end(); ++(_i))
#endif
using namespace std;
#define N 5000
#define foreachp(_i, _p, _c) for (_p = &(_c), _i = _p->begin(); _i != _p->end(); ++_i)
const int large = 1000000001;
struct append {
	int id, cost;
	append(int i, int c) {
		id = i;
		cost = c;
	}
};
int n, m, t;
vector<vector<append>> graph(N);
vector<int> top;
int s[N][N+1], x[N][N+1];
void topsort(void) {
	int i, inds[N];
	stack<int> stk;
	vector<append>::iterator nxt;
	vector<append> *nxts;
	forn(i, n) inds[i] = 0;
	forn(i, n) {
		nxts = &graph[i];
		for (nxt = nxts->begin(); nxt != nxts->end(); ++nxt) ++inds[nxt->id];
	}
	forn(i, n) if (inds[i] == 0) stk.push(i);
	while (!stk.empty()) {
		i = stk.top();
		stk.pop();
		top.push_back(i);
		nxts = &graph[i];
		for (nxt = nxts->begin(); nxt != nxts->end(); ++nxt) {
			--inds[nxt->id];
			if (inds[nxt->id] == 0) stk.push(nxt->id);
		}
	}
	assert((int)top.size() == n);
}
bool read(void) {
	int i, j, left, rght, cost;
	forn(i, n) fore(j, m) x[i][j] = -1;
	forn(i, N) graph[i].clear();
	top.clear();
	if (scanf("%d%d%d", &n, &m, &t) != 3)
		return false;
	forn(i, m) {
		scanf("%d%d%d", &left, &rght, &cost);
		--left, --rght;
		graph[left].push_back(append(rght, cost));
	}
	return true;
}
void print_path(int i, int j) {
	if (i == -1 || j <= 0) {
		printf("\n");
		return;
	}
	printf("%d ", i+1);
	print_path(x[i][j], j-1);
}
inline void print_s(int i, int j) {
	//printf("s[%2d][%2d]: %d\n", i+1, j, s[i][j]);
}
void solve(void) {
	int i, j, u, c;
	vector<append>::iterator v;
	vector<append> *nxts;
	s[n-1][1] = 0;
	forre(j, 2, m) s[n-1][j] = large;
	forre(j, 1, m) print_s(n-1, j);
	topsort();
	rfor(i, n) {
		u = top[i];
		if (u == n-1) continue;
		s[u][1] = large;
		print_s(u, 1);
		forre(j, 2, m) {
			s[u][j] = large;
			nxts = &graph[u];
			for (v = nxts->begin(); v != nxts->end(); ++v) {
				c = v->cost + s[v->id][j-1];
				if (s[u][j] > c) s[u][j] = c, x[u][j] = v->id;
			}
			print_s(u, j);
		}
	}
	rforre(j, m, 1) {
		if (n == 1000 && m == 999) {
			vector<int> debug;
			printf("%d -> %d: cost: %d\n", 0, graph[0][0].id, graph[0][0].cost);
			forre(j, 1, m) if (s[982][j] <= t) debug.push_back(j);
			printf("%d, %d: %d\n", 982, debug[0], s[982][debug[0]]);
		}
		print_s(0, j);
		if (s[0][j] <= t) break;
	}
	printf("%d\n", j);
	if (j >= 0) print_path(0, j);
}
int main(void) {
	while (read()) solve();
	return 0;
}


#include <array>
#include <cassert>
#include <cstdio>
#include <stack>
#include <vector>
#ifndef _TJYTLXWXHYZQFW_COMMON_H
#define _TJYTLXWXHYZQFW_COMMON_H
#include <climits>
#define ULL1 ((unsigned long long )1)
#define LL(x) ((long long)(x))
#define IOF(p) ((p) = ((p) < 0 ? INT_MAX : (p)))
#define LLOF(p) ((p) = ((p) < 0 ? LLONG_MAX :(p)))
#define ir(x, start, end) ((x) >= (start) && (x) < (end))
#define ire(x, start, end) ((x) >= (start) && (x) <= (end))
#define odd(x) ((x) & 1UL)
#define even(x) (!odd((x)))
#define sgn(n) (odd((n)) ? (-1) : (1))
#define abv(x) ((x) < 0 ? (x) * (-1) : (x))
#define forn(i, n) for ((i) = 0; (i) < (n); (i) += 1)
#define fore(i, n) for ((i) = 0; (i) <= (n); (i) += 1)
#define forr(i, s, e) for((i) = (s); (i) < (e); (i) += 1)
#define forre(i, s, e) for((i) = (s); (i) <= (e); (i) += 1)
#define rforre(i, b, e) for ((i) = (b); (i) >= (e); (i) -= 1)
#define tailer(i, j) ((i) == (j) ? "\n" : " ")
#define access(_a, _i, _n, _obv) (ir((_i), 0, (_n)) ? (_a)[(_i)] : (_obv))
#define vecsize(t) vector<t>::size_type
#define veciter(t) vector<t>::iterator
#endif
#define foreach(_i, _c) for((_i) = (_c).begin(); (_i) != (_c).end(); ++(_i))
using namespace std;
#define T 1000000001
#define N 5000
struct succer {
	int id;
	int cost;
	succer(int idx, int cst) {
		id = idx;
		cost = cst;
	}
};
int n, m, t;
array<array<int, N+1>, N> dp;
array<array<int, N+1>, N> path;
array<vector<succer>, N> nexts;
array<int, N> top;
void topsort(void)
{
	array<int, N> indg;
	stack<int> stk;
	veciter(succer) it;
	int topi, i, next;
	forn(i, n) foreach(it, nexts[i]) indg[it->id] = 0;
	forn(i, n) foreach(it, nexts[i]) indg[it->id] += 1;
	forn(i, n) if (indg[i] == 0) stk.push(i);
	topi = 0;
	while (not stk.empty()) {
		i = stk.top();
		stk.pop();
		top[topi++] = i;
		foreach(it, nexts[i]) {
			next = it->id;
			--indg[next];
			if (indg[next] == 0)
				stk.push(next);
		}
	}
	assert(topi == n);
}
int main(void)
{
	int i, j, k, ti, to;
	int left, right;
	int cost;
	veciter(succer) it;
	scanf("%d%d%d", &n, &m, &t);
	forn(i, m) {
		scanf("%d%d%d", &left, &right, &cost);
		--left, --right;
		nexts[left].push_back(succer(right, cost));
	}
	topsort();
	printf("after topsort: n: %d\n", n);
	rforre(ti, n-1, 0) {
		i = top[ti];
		dp[i][1] = (i == n-1 ? 0 : T);
		forre(j, 2, n) {
			dp[i][j] = T;
			foreach(it, nexts[i]) {
				k = it->id;
				if (dp[k][j-1] < T) {
					dp[i][j] = min(dp[i][j], it->cost + dp[k][j-1]);
					to = k;
				}
			}
			path[i][j] = to;
		}
	}
	printf("after dp: n: %d\n", n);
	i = 0;
	rforre(j, 4, 1)
		if (dp[i][j] <= t) break;
	assert(j >= 1);
	return 0;
}


#include <array>
#include <cassert>
#include <cstdio>
#include <stack>
#include <vector>
#ifndef _TJYTLXWXHYZQFW_COMMON_H
#define _TJYTLXWXHYZQFW_COMMON_H
#include <climits>
#define ULL1 ((unsigned long long )1)
#define LL(x) ((long long)(x))
#define IOF(p) ((p) = ((p) < 0 ? INT_MAX : (p)))
#define LLOF(p) ((p) = ((p) < 0 ? LLONG_MAX :(p)))
#define ir(x, start, end) ((x) >= (start) && (x) < (end))
#define ire(x, start, end) ((x) >= (start) && (x) <= (end))
#define odd(x) ((x) & 1UL)
#define even(x) (!odd((x)))
#define sgn(n) (odd((n)) ? (-1) : (1))
#define abv(x) ((x) < 0 ? (x) * (-1) : (x))
#define forn(i, n) for ((i) = 0; (i) < (n); (i) += 1)
#define fore(i, n) for ((i) = 0; (i) <= (n); (i) += 1)
#define forr(i, s, e) for((i) = (s); (i) < (e); (i) += 1)
#define forre(i, s, e) for((i) = (s); (i) <= (e); (i) += 1)
#define rforre(i, b, e) for ((i) = (b); (i) >= (e); (i) -= 1)
#define tailer(i, j) ((i) == (j) ? "\n" : " ")
#define access(_a, _i, _n, _obv) (ir((_i), 0, (_n)) ? (_a)[(_i)] : (_obv))
#define vecsize(t) vector<t>::size_type
#define veciter(t) vector<t>::iterator
#endif
#define foreach(_i, _c) for((_i) = (_c).begin(); (_i) != (_c).end(); ++(_i))
using namespace std;
#define T 1000000001
#define N 5000
struct succer {
	int id;
	int cost;
	succer(int idx, int cst) {
		id = idx;
		cost = cst;
	}
};
int n, m, t;
array<array<int, N+1>, N> dp;
array<array<int, N+1>, N> path;
array<vector<succer>, N> nexts;
array<int, N> top;
void topsort(void)
{
	array<int, N> indg;
	stack<int> stk;
	veciter(succer) it;
	int topi, i, next;
	printf("before topsort: n: %d\n", n);
	forn(i, n) foreach(it, nexts[i]) indg[it->id] = 0;
	forn(i, n) foreach(it, nexts[i]) indg[it->id] += 1;
	forn(i, n) if (indg[i] == 0) stk.push(i);
	printf("after 3 forn: n: %d\n", n);
	topi = 0;
	while (not stk.empty()) {
		i = stk.top();
		stk.pop();
		top[topi++] = i;
		foreach(it, nexts[i]) {
			next = it->id;
			--indg[next];
			if (indg[next] == 0)
				stk.push(next);
		}
	}
	//assert(topi == n);
}
int main(void)
{
	int i, j, k, ti, to;
	int left, right;
	int cost;
	veciter(succer) it;
	scanf("%d%d%d", &n, &m, &t);
	forn(i, m) {
		scanf("%d%d%d", &left, &right, &cost);
		--left, --right;
		nexts[left].push_back(succer(right, cost));
	}
	topsort();
	printf("after topsort: n: %d\n", n);
	rforre(ti, n-1, 0) {
		i = top[ti];
		dp[i][1] = (i == n-1 ? 0 : T);
		forre(j, 2, n) {
			dp[i][j] = T;
			foreach(it, nexts[i]) {
				k = it->id;
				if (dp[k][j-1] < T) {
					dp[i][j] = min(dp[i][j], it->cost + dp[k][j-1]);
					to = k;
				}
			}
			path[i][j] = to;
		}
	}
	printf("after dp: n: %d\n", n);
	i = 0;
	rforre(j, 4, 1)
		if (dp[i][j] <= t) break;
	assert(j >= 1);
	return 0;
}


#include <algorithm>
#include <cassert>
#include <cstdio>
#include <map>
#include <stack>
#include <string>
#include <vector>
#ifndef _TJYTLXWXHYZQFW_COMMON_H
#define _TJYTLXWXHYZQFW_COMMON_H
#include <algorithm>
#include <climits>
#define ULL1 ((unsigned long long )1)
#define LL(x) ((long long)(x))
#define IOF(p) ((p) = ((p) < 0 ? INT_MAX : (p)))
#define LLOF(p) ((p) = ((p) < 0 ? LLONG_MAX :(p)))
#define ir(x, start, end) ((x) >= (start) && (x) < (end))
#define ire(x, start, end) ((x) >= (start) && (x) <= (end))
#define odd(x) ((x) & 1UL)
#define even(x) (!odd((x)))
#define sgn(n) (odd((n)) ? (-1) : (1))
#define max3(a, b, c) std::max(std::max((a),(b)), (c))
#define abv(x) ((x) < 0 ? (x) * (-1) : (x))
#define forn(_i, _n) for ((_i) = 0; (_i) < (_n); (_i) += 1)
#define fore(_i, _n) for ((_i) = 0; (_i) <= (_n); (_i) += 1)
#define forr(_i, _s, _e) for((_i) = (_s); (_i) < (_e); (_i) += 1)
#define forre(_i, _s, _e) for((_i) = (_s); (_i) <= (_e); (_i) += 1)
#define rfor(_i, _n) for((_i)=(_n)-1; ((_i) >= 0); (_i) -= 1)
#define rfore(_i, _n) for((_i)=(_n); (_i) >= 0; (_i) -= 1)
#define rforre(_i, _b, _e) for ((_i) = (_b); (_i) >= (_e); (_i) -= 1)
#define tailer(i, j) ((i) == (j) ? "\n" : " ")
#define access(_a, _i, _n, _obv) (ir((_i), 0, (_n)) ? (_a)[(_i)] : (_obv))
#define vecsize(t) vector<t>::size_type
#define veciter(t) vector<t>::iterator
#define foriter(_i, _c) for((_i) = (_c).begin(); (_i) != (_c).end(); ++(_i))
#endif
using namespace std;
#define N 5000
#define foreachp(_i, _p, _c) for (_p = &(_c), _i = _p->begin(); _i != _p->end(); ++_i)
const int large = 1000000001;
struct append {
	int id, cost;
	append(int i, int c) {
		id = i;
		cost = c;
	}
};
int n, m, t;
vector<vector<append>> graph(N);
vector<int> top;
int s[N][N+1], x[N][N+1];
void topsort(void) {
	int i, inds[N];
	stack<int> stk;
	vector<append>::iterator nxt;
	vector<append> *nxts;
	forn(i, n) inds[i] = 0;
	forn(i, n) {
		nxts = &graph[i];
		for (nxt = nxts->begin(); nxt != nxts->end(); ++nxt) ++inds[nxt->id];
	}
	forn(i, n) if (inds[i] == 0) stk.push(i);
	while (!stk.empty()) {
		i = stk.top();
		stk.pop();
		top.push_back(i);
		nxts = &graph[i];
		for (nxt = nxts->begin(); nxt != nxts->end(); ++nxt) {
			--inds[nxt->id];
			if (inds[nxt->id] == 0) stk.push(nxt->id);
		}
	}
	assert((int)top.size() == n);
}
bool read(void) {
	int i, j, left, rght, cost;
	forn(i, n) fore(j, m+1) x[i][j] = -1;
	forn(i, N) graph[i].clear();
	top.clear();
	if (scanf("%d%d%d", &n, &m, &t) != 3)
		return false;
	forn(i, m) {
		scanf("%d%d%d", &left, &rght, &cost);
		--left, --rght;
		graph[left].push_back(append(rght, cost));
	}
	return true;
}
void print_path(int i, int j) {
	if (i == -1 || j <= 0) {
		printf("\n");
		return;
	}
	printf("%d ", i+1);
	print_path(x[i][j], j-1);
}
inline void print_s(int i, int j) {
	//printf("s[%2d][%2d]: %d\n", i+1, j, s[i][j]);
}
void solve(void) {
	int i, j, u, c;
	vector<append>::iterator v;
	vector<append> *nxts;
	s[n-1][1] = 0;
	forre(j, 2, m+1) s[n-1][j] = large;
	forre(j, 1, m+1) print_s(n-1, j);
	topsort();
	rfor(i, n) {
		u = top[i];
		if (u == n-1) continue;
		s[u][1] = large;
		print_s(u, 1);
		forre(j, 2, m+1) {
			s[u][j] = large;
			nxts = &graph[u];
			for (v = nxts->begin(); v != nxts->end(); ++v) {
				c = v->cost + s[v->id][j-1];
				if (s[u][j] > c) s[u][j] = c, x[u][j] = v->id;
			}
			print_s(u, j);
		}
	}
	rforre(j, m+1, 1) {
		print_s(0, j);
		if (s[0][j] <= t) break;
	}
	printf("%d\n", j);
	if (j >= 0) print_path(0, j);
}
int main(void) {
	while (read()) solve();
	return 0;
}


#include <algorithm>
#include <cassert>
#include <cstdio>
#include <map>
#include <stack>
#include <string>
#include <vector>
#ifndef _TJYTLXWXHYZQFW_COMMON_H
#define _TJYTLXWXHYZQFW_COMMON_H
#include <algorithm>
#include <climits>
#define ULL1 ((unsigned long long )1)
#define LL(x) ((long long)(x))
#define IOF(p) ((p) = ((p) < 0 ? INT_MAX : (p)))
#define LLOF(p) ((p) = ((p) < 0 ? LLONG_MAX :(p)))
#define ir(x, start, end) ((x) >= (start) && (x) < (end))
#define ire(x, start, end) ((x) >= (start) && (x) <= (end))
#define odd(x) ((x) & 1UL)
#define even(x) (!odd((x)))
#define sgn(n) (odd((n)) ? (-1) : (1))
#define max3(a, b, c) std::max(std::max((a),(b)), (c))
#define abv(x) ((x) < 0 ? (x) * (-1) : (x))
#define forn(_i, _n) for ((_i) = 0; (_i) < (_n); (_i) += 1)
#define fore(_i, _n) for ((_i) = 0; (_i) <= (_n); (_i) += 1)
#define forr(_i, _s, _e) for((_i) = (_s); (_i) < (_e); (_i) += 1)
#define forre(_i, _s, _e) for((_i) = (_s); (_i) <= (_e); (_i) += 1)
#define rfor(_i, _n) for((_i)=(_n)-1; ((_i) >= 0); (_i) -= 1)
#define rfore(_i, _n) for((_i)=(_n); (_i) >= 0; (_i) -= 1)
#define rforre(_i, _b, _e) for ((_i) = (_b); (_i) >= (_e); (_i) -= 1)
#define tailer(i, j) ((i) == (j) ? "\n" : " ")
#define access(_a, _i, _n, _obv) (ir((_i), 0, (_n)) ? (_a)[(_i)] : (_obv))
#define vecsize(t) vector<t>::size_type
#define veciter(t) vector<t>::iterator
#define foriter(_i, _c) for((_i) = (_c).begin(); (_i) != (_c).end(); ++(_i))
#endif
using namespace std;
#define N 5000
#define foreachp(_i, _p, _c) for (_p = &(_c), _i = _p->begin(); _i != _p->end(); ++_i)
const int large = 1000000001;
struct append {
	int id, cost;
	append(int i, int c) {
		id = i;
		cost = c;
	}
};
int n, m, t;
vector<vector<append>> graph(N);
vector<int> top;
int s[N][N+1], x[N][N+1];
void topsort(void) {
	int i, inds[N];
	stack<int> stk;
	vector<append>::iterator nxt;
	vector<append> *nxts;
	forn(i, n) inds[i] = 0;
	forn(i, n) {
		nxts = &graph[i];
		for (nxt = nxts->begin(); nxt != nxts->end(); ++nxt) ++inds[nxt->id];
	}
	forn(i, n) if (inds[i] == 0) stk.push(i);
	while (!stk.empty()) {
		i = stk.top();
		stk.pop();
		top.push_back(i);
		nxts = &graph[i];
		for (nxt = nxts->begin(); nxt != nxts->end(); ++nxt) {
			--inds[nxt->id];
			if (inds[nxt->id] == 0) stk.push(nxt->id);
		}
	}
	assert((int)top.size() == n);
}
bool read(void) {
	int i, j, left, rght, cost;
	forn(i, n) fore(j, m) x[i][j] = -1;
	forn(i, N) graph[i].clear();
	top.clear();
	if (scanf("%d%d%d", &n, &m, &t) != 3)
		return false;
	forn(i, m) {
		scanf("%d%d%d", &left, &rght, &cost);
		--left, --rght;
		graph[left].push_back(append(rght, cost));
	}
	return true;
}
void print_path(int i, int j) {
	if (i == -1 || j <= 0) {
		printf("\n");
		return;
	}
	printf("%d ", i+1);
	print_path(x[i][j], j-1);
}
inline void print_s(int i, int j) {
	//printf("s[%2d][%2d]: %d\n", i+1, j, s[i][j]);
}
void solve(void) {
	int i, j, u, c;
	vector<append>::iterator v;
	vector<append> *nxts;
	s[n-1][1] = 0;
	forre(j, 2, m) s[n-1][j] = large;
	forre(j, 1, m) print_s(n-1, j);
	topsort();
	rfor(i, n) {
		u = top[i];
		if (u == n-1) continue;
		s[u][1] = large;
		print_s(u, 1);
		forre(j, 2, m) {
			s[u][j] = large;
			nxts = &graph[u];
			for (v = nxts->begin(); v != nxts->end(); ++v) {
				c = v->cost + s[v->id][j-1];
				if (s[u][j] > c) s[u][j] = c, x[u][j] = v->id;
			}
			print_s(u, j);
		}
	}
	rforre(j, m, 1) {
		if (n == 1000 && m == 999) {
			vector<int> debug;
			forre(j, 1, m) if (s[982][j] <= t) debug.push_back(j);
			printf("%d, %d: %d\n", 982, debug[0], s[982][debug[0]]);
		}
		print_s(0, j);
		if (s[0][j] <= t) break;
	}
	printf("%d\n", j);
	if (j >= 0) print_path(0, j);
}
int main(void) {

	while (read()) solve();
	return 0;
}


#include <array>
#include <cassert>
#include <cstdio>
#include <stack>
#include <vector>
#ifndef _TJYTLXWXHYZQFW_COMMON_H
#define _TJYTLXWXHYZQFW_COMMON_H
#include <climits>
#define ULL1 ((unsigned long long )1)
#define LL(x) ((long long)(x))
#define IOF(p) ((p) = ((p) < 0 ? INT_MAX : (p)))
#define LLOF(p) ((p) = ((p) < 0 ? LLONG_MAX :(p)))
#define ir(x, start, end) ((x) >= (start) && (x) < (end))
#define ire(x, start, end) ((x) >= (start) && (x) <= (end))
#define odd(x) ((x) & 1UL)
#define even(x) (!odd((x)))
#define sgn(n) (odd((n)) ? (-1) : (1))
#define abv(x) ((x) < 0 ? (x) * (-1) : (x))
#define forn(i, n) for ((i) = 0; (i) < (n); (i) += 1)
#define fore(i, n) for ((i) = 0; (i) <= (n); (i) += 1)
#define forr(i, s, e) for((i) = (s); (i) < (e); (i) += 1)
#define forre(i, s, e) for((i) = (s); (i) <= (e); (i) += 1)
#define rforre(i, b, e) for ((i) = (b); (i) >= (e); (i) -= 1)
#define tailer(i, j) ((i) == (j) ? "\n" : " ")
#define access(_a, _i, _n, _obv) (ir((_i), 0, (_n)) ? (_a)[(_i)] : (_obv))
#define vecsize(t) vector<t>::size_type
#define veciter(t) vector<t>::iterator
#endif
#define foreach(_i, _c) for((_i) = (_c).begin(); (_i) != (_c).end(); ++(_i))
using namespace std;
#define T 1000000001
#define N 5000
struct succer {
	int id;
	int cost;
	succer(int idx, int cst) {
		id = idx;
		cost = cst;
	}
};
int n, m, t;
array<array<int, N+1>, N> dp;
array<array<int, N+1>, N> path;
array<vector<succer>, N> nexts;
array<int, N> top;
void topsort(void)
{
	array<int, N> indg;
	stack<int> stk;
	veciter(succer) it;
	int topi, i, next;
	forn(i, n) foreach(it, nexts[i]) indg[it->id] = 0;
	forn(i, n) foreach(it, nexts[i]) indg[it->id] += 1;
	forn(i, n) if (indg[i] == 0) stk.push(i);
	topi = 0;
	while (not stk.empty()) {
		i = stk.top();
		stk.pop();
		top[topi++] = i;
		foreach(it, nexts[i]) {
			next = it->id;
			--indg[next];
			if (indg[next] == 0)
				stk.push(next);
		}
	}
	assert(topi == n);
	forn(i, n) printf("%d%s", top[i], tailer(i, n-1));
}
int main(void)
{
	int i, j, k, ti, to;
	int left, right;
	int cost;
	veciter(succer) it;
	freopen("Inputs/721C", "r", stdin);
	scanf("%d%d%d", &n, &m, &t);
	forn(i, m) {
		scanf("%d%d%d", &left, &right, &cost);
		--left, --right;
		nexts[left].push_back(succer(right, cost));
	}
	topsort();
	rforre(ti, n-1, 0) {
		i = top[ti];
		dp[i][1] = (i == n-1 ? 0 : T);
		forre(j, 2, n) {
			dp[i][j] = T;
			foreach(it, nexts[i]) {
				k = it->id;
				if (dp[k][j-1] < T) {
					dp[i][j] = min(dp[i][j], it->cost + dp[k][j-1]);
					to = k;
				}
			}
			path[i][j] = to;
		}
	}
	while (1);
	i = 0;
	rforre(j, n, 1)
		if (dp[i][j] <= t) break;
	assert(j >= 1);
	printf("%d\n", j);
	while (i != n-1) {
		printf("%d ", i+1);
		i = path[i][j];
		--j;
	}
	printf("%d\n", n);
	return 0;
}


#include <algorithm>
#include <cassert>
#include <cstdio>
#include <map>
#include <stack>
#include <string>
#include <vector>
#ifndef _TJYTLXWXHYZQFW_COMMON_H
#define _TJYTLXWXHYZQFW_COMMON_H
#include <algorithm>
#include <climits>
#define ULL1 ((unsigned long long )1)
#define LL(x) ((long long)(x))
#define IOF(p) ((p) = ((p) < 0 ? INT_MAX : (p)))
#define LLOF(p) ((p) = ((p) < 0 ? LLONG_MAX :(p)))
#define ir(x, start, end) ((x) >= (start) && (x) < (end))
#define ire(x, start, end) ((x) >= (start) && (x) <= (end))
#define odd(x) ((x) & 1UL)
#define even(x) (!odd((x)))
#define sgn(n) (odd((n)) ? (-1) : (1))
#define max3(a, b, c) std::max(std::max((a),(b)), (c))
#define abv(x) ((x) < 0 ? (x) * (-1) : (x))
#define forn(_i, _n) for ((_i) = 0; (_i) < (_n); (_i) += 1)
#define fore(_i, _n) for ((_i) = 0; (_i) <= (_n); (_i) += 1)
#define forr(_i, _s, _e) for((_i) = (_s); (_i) < (_e); (_i) += 1)
#define forre(_i, _s, _e) for((_i) = (_s); (_i) <= (_e); (_i) += 1)
#define rfor(_i, _n) for((_i)=(_n)-1; ((_i) >= 0); (_i) -= 1)
#define rfore(_i, _n) for((_i)=(_n); (_i) >= 0; (_i) -= 1)
#define rforre(_i, _b, _e) for ((_i) = (_b); (_i) >= (_e); (_i) -= 1)
#define tailer(i, j) ((i) == (j) ? "\n" : " ")
#define access(_a, _i, _n, _obv) (ir((_i), 0, (_n)) ? (_a)[(_i)] : (_obv))
#define vecsize(t) vector<t>::size_type
#define veciter(t) vector<t>::iterator
#define foriter(_i, _c) for((_i) = (_c).begin(); (_i) != (_c).end(); ++(_i))
#endif
using namespace std;
#define N 5000
const int large = 1000000001;
struct append {
	int id, cost;
	append(int i, int c) {
		id = i;
		cost = c;
	}
};
int n, m, t;
vector<vector<append>> graph(N);
vector<int> top;
int s[N][N+1], x[N][N+1];
void topsort(void) {
	int i, inds[N];
	stack<int> stk;
	vector<append>::iterator nxt;
	vector<append> *nxts;
	forn(i, n) inds[i] = 0;
	forn(i, n) {
		nxts = &graph[i];
		for (nxt = nxts->begin(); nxt != nxts->end(); ++nxt) ++inds[nxt->id];
	}
	forn(i, n) if (inds[i] == 0) stk.push(i);
	while (!stk.empty()) {
		i = stk.top();
		stk.pop();
		top.push_back(i);
		nxts = &graph[i];
		for (nxt = nxts->begin(); nxt != nxts->end(); ++nxt) {
			--inds[nxt->id];
			if (inds[nxt->id] == 0) stk.push(nxt->id);
		}
	}
}
bool read(void) {
	int i, j, left, rght, cost;
	forn(i, n) fore(j, m) x[i][j] = -1;
	forn(i, N) graph[i].clear();
	top.clear();
	if (scanf("%d%d%d", &n, &m, &t) != 3)
		return false;
	forn(i, m) {
		scanf("%d%d%d", &left, &rght, &cost);
		--left, --rght;
		graph[left].push_back(append(rght, cost));
	}
	return true;
}
void print_path(int i, int j) {
	if (i == -1 || j <= 0) {
		printf("\n");
		return;
	}
	printf("%d ", i+1);
	print_path(x[i][j], j-1);
}
inline void print_s(int i, int j) {
}
void solve(void) {
	int i, j, u, c;
	vector<append>::iterator v;
	vector<append> *nxts;
	s[n-1][1] = 0;
	forre(j, 2, m) s[n-1][j] = large;
	forre(j, 1, m) print_s(n-1, j);
	topsort();
	rfor(i, n) {
		u = top[i];
		if (u == n-1) continue;
		s[u][1] = large;
		print_s(u, 1);
		forre(j, 2, m) {
			s[u][j] = large;
			nxts = &graph[u];
			for (v = nxts->begin(); v != nxts->end(); ++v) {
				c = v->cost + s[v->id][j-1];
				if (s[u][j] > c) s[u][j] = c, x[u][j] = v->id;
			}
			print_s(u, j);
		}
	}
	rforre(j, m, 1) {
		if (n == 1000 && m == 999) forn(i, n) printf("%d%s", s[0][j], tailer(i, n-1));
		print_s(0, j);
		if (s[0][j] <= t) break;
	}
	printf("%d\n", j);
	if (j >= 0) print_path(0, j);
}
int main(void) {
	while (read()) solve();
	return 0;
}


#include <array>
#include <cassert>
#include <cstdio>
#include <stack>
#include <vector>
#ifndef _TJYTLXWXHYZQFW_COMMON_H
#define _TJYTLXWXHYZQFW_COMMON_H
#include <climits>
#define ULL1 ((unsigned long long )1)
#define LL(x) ((long long)(x))
#define IOF(p) ((p) = ((p) < 0 ? INT_MAX : (p)))
#define LLOF(p) ((p) = ((p) < 0 ? LLONG_MAX :(p)))
#define ir(x, start, end) ((x) >= (start) && (x) < (end))
#define ire(x, start, end) ((x) >= (start) && (x) <= (end))
#define odd(x) ((x) & 1UL)
#define even(x) (!odd((x)))
#define sgn(n) (odd((n)) ? (-1) : (1))
#define abv(x) ((x) < 0 ? (x) * (-1) : (x))
#define forn(i, n) for ((i) = 0; (i) < (n); (i) += 1)
#define fore(i, n) for ((i) = 0; (i) <= (n); (i) += 1)
#define forr(i, s, e) for((i) = (s); (i) < (e); (i) += 1)
#define forre(i, s, e) for((i) = (s); (i) <= (e); (i) += 1)
#define rforre(i, b, e) for ((i) = (b); (i) >= (e); (i) -= 1)
#define tailer(i, j) ((i) == (j) ? "\n" : " ")
#define access(_a, _i, _n, _obv) (ir((_i), 0, (_n)) ? (_a)[(_i)] : (_obv))
#define vecsize(t) vector<t>::size_type
#define veciter(t) vector<t>::iterator
#endif
#define foreach(_i, _c) for((_i) = (_c).begin(); (_i) != (_c).end(); ++(_i))
using namespace std;
#define T 1000000001
#define N 5000
struct succer {
	int id;
	int cost;
	succer(int idx, int cst) {
		id = idx;
		cost = cst;
	}
};
int n, m, t;
array<array<int, N+1>, N> dp;
array<array<int, N+1>, N> path;
array<vector<succer>, N> nexts;
array<int, N> top;
void topsort(void)
{
	array<int, N> indg;
	stack<int> stk;
	veciter(succer) it;
	int topi, i, next;
	printf("before topsort: n: %d\n", n);
	forn(i, n) foreach(it, nexts[i]) indg[it->id] = 0;
	forn(i, n) foreach(it, nexts[i]) indg[it->id] += 1;
	forn(i, n) printf("%d%s", indg[i], tailer(i, n-1));
	forn(i, n) if (indg[i] == 0) stk.push(i);
	printf("after 3 forn: n: %d\n", n);
	topi = 0;
	while (not stk.empty()) {
		i = stk.top();
		stk.pop();
		top[topi++] = i;
		foreach(it, nexts[i]) {
			next = it->id;
			--indg[next];
			if (indg[next] == 0)
				stk.push(next);
		}
	}
	printf("topi: %d\n", topi);
	//assert(topi == n);
}
int main(void)
{
	int i, j, k, ti, to;
	int left, right;
	int cost;
	veciter(succer) it;
	scanf("%d%d%d", &n, &m, &t);
	forn(i, m) {
		scanf("%d%d%d", &left, &right, &cost);
		--left, --right;
		nexts[left].push_back(succer(right, cost));
	}
	topsort();
	printf("after topsort: n: %d\n", n);
	rforre(ti, n-1, 0) {
		i = top[ti];
		dp[i][1] = (i == n-1 ? 0 : T);
		forre(j, 2, n) {
			dp[i][j] = T;
			foreach(it, nexts[i]) {
				k = it->id;
				if (dp[k][j-1] < T) {
					dp[i][j] = min(dp[i][j], it->cost + dp[k][j-1]);
					to = k;
				}
			}
			path[i][j] = to;
		}
	}
	printf("after dp: n: %d\n", n);
	i = 0;
	rforre(j, 4, 1)
		if (dp[i][j] <= t) break;
	assert(j >= 1);
	return 0;
}


#include <algorithm>
#include <cassert>
#include <cstdio>
#include <map>
#include <stack>
#include <string>
#include <vector>
#ifndef _TJYTLXWXHYZQFW_COMMON_H
#define _TJYTLXWXHYZQFW_COMMON_H
#include <algorithm>
#include <climits>
#define ULL1 ((unsigned long long )1)
#define LL(x) ((long long)(x))
#define IOF(p) ((p) = ((p) < 0 ? INT_MAX : (p)))
#define LLOF(p) ((p) = ((p) < 0 ? LLONG_MAX :(p)))
#define ir(x, start, end) ((x) >= (start) && (x) < (end))
#define ire(x, start, end) ((x) >= (start) && (x) <= (end))
#define odd(x) ((x) & 1UL)
#define even(x) (!odd((x)))
#define sgn(n) (odd((n)) ? (-1) : (1))
#define max3(a, b, c) std::max(std::max((a),(b)), (c))
#define abv(x) ((x) < 0 ? (x) * (-1) : (x))
#define forn(_i, _n) for ((_i) = 0; (_i) < (_n); (_i) += 1)
#define fore(_i, _n) for ((_i) = 0; (_i) <= (_n); (_i) += 1)
#define forr(_i, _s, _e) for((_i) = (_s); (_i) < (_e); (_i) += 1)
#define forre(_i, _s, _e) for((_i) = (_s); (_i) <= (_e); (_i) += 1)
#define rfor(_i, _n) for((_i)=(_n)-1; ((_i) >= 0); (_i) -= 1)
#define rfore(_i, _n) for((_i)=(_n); (_i) >= 0; (_i) -= 1)
#define rforre(_i, _b, _e) for ((_i) = (_b); (_i) >= (_e); (_i) -= 1)
#define tailer(i, j) ((i) == (j) ? "\n" : " ")
#define access(_a, _i, _n, _obv) (ir((_i), 0, (_n)) ? (_a)[(_i)] : (_obv))
#define vecsize(t) vector<t>::size_type
#define veciter(t) vector<t>::iterator
#define foriter(_i, _c) for((_i) = (_c).begin(); (_i) != (_c).end(); ++(_i))
#endif
using namespace std;
#define N 5000
#define foreachp(_i, _p, _c) for (_p = &(_c), _i = _p->begin(); _i != _p->end(); ++_i)
const int large = 1000000001;
struct append {
	int id, cost;
	append(int i, int c) {
		id = i;
		cost = c;
	}
};
int n, m, t;
vector<vector<append>> graph(N);
vector<int> top;
int s[N][N+1], x[N][N+1];
void topsort(void) {
	int i, inds[N];
	stack<int> stk;
	vector<append>::iterator nxt;
	vector<append> *nxts;
	forn(i, n) inds[i] = 0;
	forn(i, n) {
		nxts = &graph[i];
		for (nxt = nxts->begin(); nxt != nxts->end(); ++nxt) ++inds[nxt->id];
	}
	forn(i, n) if (inds[i] == 0) stk.push(i);
	while (!stk.empty()) {
		i = stk.top();
		stk.pop();
		top.push_back(i);
		nxts = &graph[i];
		for (nxt = nxts->begin(); nxt != nxts->end(); ++nxt) {
			--inds[nxt->id];
			if (inds[nxt->id] == 0) stk.push(nxt->id);
		}
	}
	assert((int)top.size() == n);
}
bool read(void) {
	int i, j, left, rght, cost;
	forn(i, n) fore(j, n) x[i][j] = -1;
	forn(i, N) graph[i].clear();
	top.clear();
	if (scanf("%d%d%d", &n, &m, &t) != 3)
		return false;
	forn(i, m) {
		scanf("%d%d%d", &left, &rght, &cost);
		--left, --rght;
		graph[left].push_back(append(rght, cost));
	}
	return true;
}
void print_path(int i, int j) {
	if (i == -1 || j <= 0) {
		printf("\n");
		return;
	}
	printf("%d ", i+1);
	print_path(x[i][j], j-1);
}
inline void print_s(int i, int j) {
	//printf("s[%2d][%2d]: %d\n", i+1, j, s[i][j]);
}
void solve(void) {
	int i, j, u, c;
	vector<append>::iterator v;
	vector<append> *nxts;
	s[n-1][1] = 0;
	forre(j, 2, n) s[n-1][j] = large;
	forre(j, 1, n) print_s(n-1, j);
	topsort();
	rfor(i, n) {
		u = top[i];
		if (u == n-1) continue;
		s[u][1] = large;
		print_s(u, 1);
		forre(j, 2, n) {
			s[u][j] = large;
			nxts = &graph[u];
			for (v = nxts->begin(); v != nxts->end(); ++v) {
				c = v->cost + s[v->id][j-1];
				if (s[u][j] > c) s[u][j] = c, x[u][j] = v->id;
			}
			print_s(u, j);
		}
	}
	rforre(j, n, 1) {
		if (n == 1000 && m == 999) {
			vector<int> debug;
			forr(i, 0, 10) printf("%d%s", top[i], tailer(i, 9));
			printf("%d -> %d: cost: %d\n", 0, graph[0][0].id, graph[0][0].cost);
			forre(j, 1, n) if (s[982][j] <= t) debug.push_back(j);
			printf("%d, %d: %d\n", 982, debug[0], s[982][debug[0]]);
		}
		print_s(0, j);
		if (s[0][j] <= t) break;
	}
	printf("%d\n", j);
	if (j >= 0) print_path(0, j);
}
int main(void) {
	while (read()) solve();
	return 0;
}


#include <array>
#include <cassert>
#include <cstdio>
#include <stack>
#include <vector>
#ifndef _TJYTLXWXHYZQFW_COMMON_H
#define _TJYTLXWXHYZQFW_COMMON_H
#include <climits>
#define ULL1 ((unsigned long long )1)
#define LL(x) ((long long)(x))
#define IOF(p) ((p) = ((p) < 0 ? INT_MAX : (p)))
#define LLOF(p) ((p) = ((p) < 0 ? LLONG_MAX :(p)))
#define ir(x, start, end) ((x) >= (start) && (x) < (end))
#define ire(x, start, end) ((x) >= (start) && (x) <= (end))
#define odd(x) ((x) & 1UL)
#define even(x) (!odd((x)))
#define sgn(n) (odd((n)) ? (-1) : (1))
#define abv(x) ((x) < 0 ? (x) * (-1) : (x))
#define forn(i, n) for ((i) = 0; (i) < (n); (i) += 1)
#define fore(i, n) for ((i) = 0; (i) <= (n); (i) += 1)
#define forr(i, s, e) for((i) = (s); (i) < (e); (i) += 1)
#define forre(i, s, e) for((i) = (s); (i) <= (e); (i) += 1)
#define rforre(i, b, e) for ((i) = (b); (i) >= (e); (i) -= 1)
#define tailer(i, j) ((i) == (j) ? "\n" : " ")
#define access(_a, _i, _n, _obv) (ir((_i), 0, (_n)) ? (_a)[(_i)] : (_obv))
#define vecsize(t) vector<t>::size_type
#define veciter(t) vector<t>::iterator
#endif
#define foreach(_i, _c) for((_i) = (_c).begin(); (_i) != (_c).end(); ++(_i))
using namespace std;
#define T 1000000001
#define N 5000
struct succer {
	int id;
	int cost;
	succer(int idx, int cst) {
		id = idx;
		cost = cst;
	}
};
int n, m, t;
array<array<int, N+1>, N> dp;
array<array<int, N+1>, N> path;
array<vector<succer>, N> nexts;
array<int, N> top;
void topsort(void)
{
	array<int, N> indg;
	stack<int> stk;
	veciter(succer) it;
	int topi, i, next;
	printf("before topsort: n: %d\n", n);
	forn(i, n) foreach(it, nexts[i]) indg[it->id] = 0;
	forn(i, n) foreach(it, nexts[i]) indg[it->id] += 1;
	forn(i, n) if (indg[i] == 0) stk.push(i);
	printf("after 3 forn: n: %d\n", n);
	topi = 0;
	while (not stk.empty()) {
		i = stk.top();
		stk.pop();
		top[topi++] = i;
		foreach(it, nexts[i]) {
			next = it->id;
			--indg[next];
			if (indg[next] == 0)
				stk.push(next);
		}
	}
	printf("topi: %d\n", topi);
	//assert(topi == n);
}
int main(void)
{
	int i, j, k, ti, to;
	int left, right;
	int cost;
	veciter(succer) it;
	scanf("%d%d%d", &n, &m, &t);
	forn(i, m) {
		scanf("%d%d%d", &left, &right, &cost);
		--left, --right;
		nexts[left].push_back(succer(right, cost));
	}
	topsort();
	printf("after topsort: n: %d\n", n);
	rforre(ti, n-1, 0) {
		i = top[ti];
		dp[i][1] = (i == n-1 ? 0 : T);
		forre(j, 2, n) {
			dp[i][j] = T;
			foreach(it, nexts[i]) {
				k = it->id;
				if (dp[k][j-1] < T) {
					dp[i][j] = min(dp[i][j], it->cost + dp[k][j-1]);
					to = k;
				}
			}
			path[i][j] = to;
		}
	}
	printf("after dp: n: %d\n", n);
	i = 0;
	rforre(j, 4, 1)
		if (dp[i][j] <= t) break;
	assert(j >= 1);
	return 0;
}


#include <array>
#include <cassert>
#include <cstdio>
#include <stack>
#include <vector>
#ifndef _TJYTLXWXHYZQFW_COMMON_H
#define _TJYTLXWXHYZQFW_COMMON_H
#include <climits>
#define ULL1 ((unsigned long long )1)
#define LL(x) ((long long)(x))
#define IOF(p) ((p) = ((p) < 0 ? INT_MAX : (p)))
#define LLOF(p) ((p) = ((p) < 0 ? LLONG_MAX :(p)))
#define ir(x, start, end) ((x) >= (start) && (x) < (end))
#define ire(x, start, end) ((x) >= (start) && (x) <= (end))
#define odd(x) ((x) & 1UL)
#define even(x) (!odd((x)))
#define sgn(n) (odd((n)) ? (-1) : (1))
#define abv(x) ((x) < 0 ? (x) * (-1) : (x))
#define forn(i, n) for ((i) = 0; (i) < (n); (i) += 1)
#define fore(i, n) for ((i) = 0; (i) <= (n); (i) += 1)
#define forr(i, s, e) for((i) = (s); (i) < (e); (i) += 1)
#define forre(i, s, e) for((i) = (s); (i) <= (e); (i) += 1)
#define rforre(i, b, e) for ((i) = (b); (i) >= (e); (i) -= 1)
#define tailer(i, j) ((i) == (j) ? "\n" : " ")
#define access(_a, _i, _n, _obv) (ir((_i), 0, (_n)) ? (_a)[(_i)] : (_obv))
#define vecsize(t) vector<t>::size_type
#define veciter(t) vector<t>::iterator
#endif
#define foreach(_i, _c) for((_i) = (_c).begin(); (_i) != (_c).end(); ++(_i))
using namespace std;
#define T 1000000001
#define N 5000
struct succer {
	int id;
	int cost;
	succer(int idx, int cst) {
		id = idx;
		cost = cst;
	}
};
int n, m, t;
array<array<int, N+1>, N> dp;
array<array<int, N+1>, N> path;
array<vector<succer>, N> nexts;
array<int, N> top;
void topsort(void)
{
	array<int, N> indg;
	stack<int> stk;
	veciter(succer) it;
	int topi, i, next;
	forn(i, n) foreach(it, nexts[i]) indg[it->id] = 0;
	forn(i, n) foreach(it, nexts[i]) indg[it->id] += 1;
	forn(i, n) if (indg[i] == 0) stk.push(i);
	topi = 0;
	while (not stk.empty()) {
		i = stk.top();
		stk.pop();
		top[topi++] = i;
		foreach(it, nexts[i]) {
			next = it->id;
			--indg[next];
			if (indg[next] == 0)
				stk.push(next);
		}
	}
	assert(topi == n);
	forn(i, n) printf("%d%s", top[i], tailer(i, n-1));
}
int main(void)
{
	int i, j, k, ti, to;
	int left, right;
	int cost;
	veciter(succer) it;
	freopen("Inputs/721C", "r", stdin);
	scanf("%d%d%d", &n, &m, &t);
	forn(i, m) {
		scanf("%d%d%d", &left, &right, &cost);
		--left, --right;
		nexts[left].push_back(succer(right, cost));
	}
	topsort();
	while(1);
	rforre(ti, n-1, 0) {
		i = top[ti];
		dp[i][1] = (i == n-1 ? 0 : T);
		forre(j, 2, n) {
			dp[i][j] = T;
			foreach(it, nexts[i]) {
				k = it->id;
				if (dp[k][j-1] < T) {
					dp[i][j] = min(dp[i][j], it->cost + dp[k][j-1]);
					to = k;
				}
			}
			path[i][j] = to;
		}
	}
	i = 0;
	rforre(j, n, 1)
		if (dp[i][j] <= t) break;
	assert(j >= 1);
	printf("%d\n", j);
	while (i != n-1) {
		printf("%d ", i+1);
		i = path[i][j];
		--j;
	}
	printf("%d\n", n);
	return 0;
}


#include <algorithm>
#include <cassert>
#include <cstdio>
#include <map>
#include <stack>
#include <string>
#include <vector>
#ifndef _TJYTLXWXHYZQFW_COMMON_H
#define _TJYTLXWXHYZQFW_COMMON_H
#include <algorithm>
#include <climits>
#define ULL1 ((unsigned long long )1)
#define LL(x) ((long long)(x))
#define IOF(p) ((p) = ((p) < 0 ? INT_MAX : (p)))
#define LLOF(p) ((p) = ((p) < 0 ? LLONG_MAX :(p)))
#define ir(x, start, end) ((x) >= (start) && (x) < (end))
#define ire(x, start, end) ((x) >= (start) && (x) <= (end))
#define odd(x) ((x) & 1UL)
#define even(x) (!odd((x)))
#define sgn(n) (odd((n)) ? (-1) : (1))
#define max3(a, b, c) std::max(std::max((a),(b)), (c))
#define abv(x) ((x) < 0 ? (x) * (-1) : (x))
#define forn(_i, _n) for ((_i) = 0; (_i) < (_n); (_i) += 1)
#define fore(_i, _n) for ((_i) = 0; (_i) <= (_n); (_i) += 1)
#define forr(_i, _s, _e) for((_i) = (_s); (_i) < (_e); (_i) += 1)
#define forre(_i, _s, _e) for((_i) = (_s); (_i) <= (_e); (_i) += 1)
#define rfor(_i, _n) for((_i)=(_n)-1; ((_i) >= 0); (_i) -= 1)
#define rfore(_i, _n) for((_i)=(_n); (_i) >= 0; (_i) -= 1)
#define rforre(_i, _b, _e) for ((_i) = (_b); (_i) >= (_e); (_i) -= 1)
#define tailer(i, j) ((i) == (j) ? "\n" : " ")
#define access(_a, _i, _n, _obv) (ir((_i), 0, (_n)) ? (_a)[(_i)] : (_obv))
#define vecsize(t) vector<t>::size_type
#define veciter(t) vector<t>::iterator
#define foriter(_i, _c) for((_i) = (_c).begin(); (_i) != (_c).end(); ++(_i))
#endif
using namespace std;
#define N 5000
const int large = 1000000001;
struct append {
	int id, cost;
	append(int i, int c) {
		id = i;
		cost = c;
	}
};
int n, m, t;
vector<vector<append>> graph(N);
vector<int> top;
int s[N][N+1], x[N][N+1];
void topsort(void) {
	int i, inds[N];
	stack<int> stk;
	vector<append>::iterator nxt;
	vector<append> *nxts;
	forn(i, n) inds[i] = 0;
	forn(i, n) {
		nxts = &graph[i];
		for (nxt = nxts->begin(); nxt != nxts->end(); ++nxt) ++inds[nxt->id];
	}
	forn(i, n) if (inds[i] == 0) stk.push(i);
	while (!stk.empty()) {
		i = stk.top();
		stk.pop();
		top.push_back(i);
		nxts = &graph[i];
		for (nxt = nxts->begin(); nxt != nxts->end(); ++nxt) {
			--inds[nxt->id];
			if (inds[nxt->id] == 0) stk.push(nxt->id);
		}
	}
}
bool read(void) {
	int i, j, left, rght, cost;
	forn(i, n) fore(j, m) x[i][j] = -1;
	forn(i, N) graph[i].clear();
	top.clear();
	if (scanf("%d%d%d", &n, &m, &t) != 3)
		return false;
	forn(i, m) {
		scanf("%d%d%d", &left, &rght, &cost);
		--left, --rght;
		graph[left].push_back(append(rght, cost));
	}
	return true;
}
void print_path(int i, int j) {
	if (i == -1 || j <= 0) {
		printf("\n");
		return;
	}
	printf("%d ", i+1);
	print_path(x[i][j], j-1);
}
void print_s(int i, int j) {
}
void solve(void) {
	int i, j, u, c;
	vector<append>::iterator v;
	vector<append> *nxts;
	s[n-1][1] = 0;
	forre(j, 2, m) s[n-1][j] = large;
	forre(j, 1, m) print_s(n-1, j);
	topsort();
	rfor(i, n) {
		u = top[i];
		if (u == n-1) continue;
		s[u][1] = large;
		print_s(u, 1);
		forre(j, 2, m) {
			s[u][j] = large;
			nxts = &graph[u];
			for (v = nxts->begin(); v != nxts->end(); ++v) {
				c = v->cost + s[v->id][j-1];
				if (s[u][j] > c) s[u][j] = c, x[u][j] = v->id;
			}
			print_s(u, j);
		}
	}
	rforre(j, m, 1) {
		print_s(0, j);
		if (s[0][j] <= t) break;
	}
	printf("%d\n", j);
	if (j >= 0) print_path(0, j);
}
int main(void) {
	while (read()) solve();
	return 0;
}


#include <algorithm>
#include <cassert>
#include <cstdio>
#include <map>
#include <stack>
#include <string>
#include <vector>
#ifndef _TJYTLXWXHYZQFW_COMMON_H
#define _TJYTLXWXHYZQFW_COMMON_H
#include <algorithm>
#include <climits>
#define ULL1 ((unsigned long long )1)
#define LL(x) ((long long)(x))
#define IOF(p) ((p) = ((p) < 0 ? INT_MAX : (p)))
#define LLOF(p) ((p) = ((p) < 0 ? LLONG_MAX :(p)))
#define ir(x, start, end) ((x) >= (start) && (x) < (end))
#define ire(x, start, end) ((x) >= (start) && (x) <= (end))
#define odd(x) ((x) & 1UL)
#define even(x) (!odd((x)))
#define sgn(n) (odd((n)) ? (-1) : (1))
#define max3(a, b, c) std::max(std::max((a),(b)), (c))
#define abv(x) ((x) < 0 ? (x) * (-1) : (x))
#define forn(_i, _n) for ((_i) = 0; (_i) < (_n); (_i) += 1)
#define fore(_i, _n) for ((_i) = 0; (_i) <= (_n); (_i) += 1)
#define forr(_i, _s, _e) for((_i) = (_s); (_i) < (_e); (_i) += 1)
#define forre(_i, _s, _e) for((_i) = (_s); (_i) <= (_e); (_i) += 1)
#define rfor(_i, _n) for((_i)=(_n)-1; ((_i) >= 0); (_i) -= 1)
#define rfore(_i, _n) for((_i)=(_n); (_i) >= 0; (_i) -= 1)
#define rforre(_i, _b, _e) for ((_i) = (_b); (_i) >= (_e); (_i) -= 1)
#define tailer(i, j) ((i) == (j) ? "\n" : " ")
#define access(_a, _i, _n, _obv) (ir((_i), 0, (_n)) ? (_a)[(_i)] : (_obv))
#define vecsize(t) vector<t>::size_type
#define veciter(t) vector<t>::iterator
#define foriter(_i, _c) for((_i) = (_c).begin(); (_i) != (_c).end(); ++(_i))
#endif
using namespace std;
#define N 5000
#define foreachp(_i, _p, _c) for (_p = &(_c), _i = _p->begin(); _i != _p->end(); ++_i)
const int large = 1000000001;
struct append {
	int id, cost;
	append(int i, int c) {
		id = i;
		cost = c;
	}
};
int n, m, t;
vector<vector<append>> graph(N);
vector<int> top;
int s[N][N+1], x[N][N+1];
void topsort(void) {
	int i, inds[N];
	stack<int> stk;
	vector<append>::iterator nxt;
	vector<append> *nxts;
	forn(i, n) inds[i] = 0;
	forn(i, n) {
		nxts = &graph[i];
		for (nxt = nxts->begin(); nxt != nxts->end(); ++nxt) ++inds[nxt->id];
	}
	forn(i, n) if (inds[i] == 0) stk.push(i);
	while (!stk.empty()) {
		i = stk.top();
		stk.pop();
		top.push_back(i);
		nxts = &graph[i];
		for (nxt = nxts->begin(); nxt != nxts->end(); ++nxt) {
			--inds[nxt->id];
			if (inds[nxt->id] == 0) stk.push(nxt->id);
		}
	}
	assert((int)top.size() == n);
}
bool read(void) {
	int i, j, left, rght, cost;
	forn(i, n) fore(j, m+1) x[i][j] = -1;
	forn(i, N) graph[i].clear();
	top.clear();
	if (scanf("%d%d%d", &n, &m, &t) != 3)
		return false;
	forn(i, m) {
		scanf("%d%d%d", &left, &rght, &cost);
		--left, --rght;
		graph[left].push_back(append(rght, cost));
	}
	return true;
}
void print_path(int i, int j) {
	if (i == -1 || j <= 0) {
		printf("\n");
		return;
	}
	printf("%d ", i+1);
	print_path(x[i][j], j-1);
}
inline void print_s(int i, int j) {
	//printf("s[%2d][%2d]: %d\n", i+1, j, s[i][j]);
}
void solve(void) {
	int i, j, u, c;
	vector<append>::iterator v;
	vector<append> *nxts;
	s[n-1][1] = 0;
	forre(j, 2, m+1) s[n-1][j] = large;
	forre(j, 1, m+1) print_s(n-1, j);
	topsort();
	rfor(i, n) {
		u = top[i];
		if (u == n-1) continue;
		s[u][1] = large;
		print_s(u, 1);
		forre(j, 2, m+1) {
			s[u][j] = large;
			nxts = &graph[u];
			for (v = nxts->begin(); v != nxts->end(); ++v) {
				c = v->cost + s[v->id][j-1];
				if (s[u][j] > c) s[u][j] = c, x[u][j] = v->id;
			}
			print_s(u, j);
		}
	}
	rforre(j, m+1, 1) {
		if (n == 1000 && m == 999) {
			vector<int> debug;
			forr(i, 0, 10) printf("%d%s", top[i], tailer(i, 9));
			printf("%d -> %d: cost: %d\n", 0, graph[0][0].id, graph[0][0].cost);
			forre(j, 1, m+1) if (s[982][j] <= t) debug.push_back(j);
			printf("%d, %d: %d\n", 982, debug[0], s[982][debug[0]]);
		}
		print_s(0, j);
		if (s[0][j] <= t) break;
	}
	printf("%d\n", j);
	if (j >= 0) print_path(0, j);
}
int main(void) {
	while (read()) solve();
	return 0;
}


#include <array>
#include <cassert>
#include <cstdio>
#include <stack>
#include <vector>
#ifndef _TJYTLXWXHYZQFW_COMMON_H
#define _TJYTLXWXHYZQFW_COMMON_H
#include <climits>
#define ULL1 ((unsigned long long )1)
#define LL(x) ((long long)(x))
#define IOF(p) ((p) = ((p) < 0 ? INT_MAX : (p)))
#define LLOF(p) ((p) = ((p) < 0 ? LLONG_MAX :(p)))
#define ir(x, start, end) ((x) >= (start) && (x) < (end))
#define ire(x, start, end) ((x) >= (start) && (x) <= (end))
#define odd(x) ((x) & 1UL)
#define even(x) (!odd((x)))
#define sgn(n) (odd((n)) ? (-1) : (1))
#define abv(x) ((x) < 0 ? (x) * (-1) : (x))
#define forn(i, n) for ((i) = 0; (i) < (n); (i) += 1)
#define fore(i, n) for ((i) = 0; (i) <= (n); (i) += 1)
#define forr(i, s, e) for((i) = (s); (i) < (e); (i) += 1)
#define forre(i, s, e) for((i) = (s); (i) <= (e); (i) += 1)
#define rforre(i, b, e) for ((i) = (b); (i) >= (e); (i) -= 1)
#define tailer(i, j) ((i) == (j) ? "\n" : " ")
#define access(_a, _i, _n, _obv) (ir((_i), 0, (_n)) ? (_a)[(_i)] : (_obv))
#define vecsize(t) vector<t>::size_type
#define veciter(t) vector<t>::iterator
#endif
#define foreach(_i, _c) for((_i) = (_c).begin(); (_i) != (_c).end(); ++(_i))
using namespace std;
#define T 1000000001
#define N 5000
struct succer {
	int id;
	int cost;
	succer(int idx, int cst) {
		id = idx;
		cost = cst;
	}
};
int n, m, t;
array<array<int, N+1>, N> dp;
array<array<int, N+1>, N+1> path;
array<vector<succer>, N> nexts;
array<int, N> top;
void topsort(void)
{
	array<int, N> indg;
	stack<int> stk;
	veciter(succer) it;
	int topi, i, next;
	forn(i, n)
		foreach(it, nexts[i])
			indg[it->id] = 0;
	forn(i, n) {
		foreach(it, nexts[i]) {
			indg[it->id] += 1;
		}
	}
	forn(i, n) {
		if (indg[i] == 0)
			stk.push(i);
	}
	topi = 0;
	while (not stk.empty()) {
		i = stk.top();
		stk.pop();
		top[topi++] = i;
		foreach(it, nexts[i]) {
			next = it->id;
			--indg[next];
			if (indg[next] == 0)
				stk.push(next);
		}
	}
	if (topi != n) printf("topi != n");
}
int main(void)
{
	int i, j, k, ti, to;
	int left, right;
	int cost;
	veciter(succer) it;
	scanf("%d%d%d", &n, &m, &t);
	forn(i, m) {
		scanf("%d%d%d", &left, &right, &cost);
		--left, --right;
		nexts[left].push_back(succer(right, cost));
	}
	topsort();
	rforre(ti, n-1, 0) {
		i = top[ti];
		dp[i][1] = (i == n-1 ? 0 : T);
		forre(j, 2, n) {
			dp[i][j] = T;
			foreach(it, nexts[i]) {
				k = it->id;
				if (dp[k][j-1] < T) {
					dp[i][j] = min(dp[i][j], it->cost + dp[k][j-1]);
					to = k;
				}
			}
			path[i][j] = to;
		}
	}
	i = 0;
	rforre(j, n, 1)
		if (dp[i][j] <= t) break;
	if (j < 1)
		printf("j >= 1");
	printf("%d\n", j);
	while (i != n-1) {
		printf("%d ", i+1);
		i = path[i][j];
		--j;
	}
	printf("%d\n", n);
	return 0;
}


#include <algorithm>
#include <cassert>
#include <cstdio>
#include <map>
#include <stack>
#include <string>
#include <vector>
#ifndef _TJYTLXWXHYZQFW_COMMON_H
#define _TJYTLXWXHYZQFW_COMMON_H
#include <algorithm>
#include <climits>
#define ULL1 ((unsigned long long )1)
#define LL(x) ((long long)(x))
#define IOF(p) ((p) = ((p) < 0 ? INT_MAX : (p)))
#define LLOF(p) ((p) = ((p) < 0 ? LLONG_MAX :(p)))
#define ir(x, start, end) ((x) >= (start) && (x) < (end))
#define ire(x, start, end) ((x) >= (start) && (x) <= (end))
#define odd(x) ((x) & 1UL)
#define even(x) (!odd((x)))
#define sgn(n) (odd((n)) ? (-1) : (1))
#define max3(a, b, c) std::max(std::max((a),(b)), (c))
#define abv(x) ((x) < 0 ? (x) * (-1) : (x))
#define forn(_i, _n) for ((_i) = 0; (_i) < (_n); (_i) += 1)
#define fore(_i, _n) for ((_i) = 0; (_i) <= (_n); (_i) += 1)
#define forr(_i, _s, _e) for((_i) = (_s); (_i) < (_e); (_i) += 1)
#define forre(_i, _s, _e) for((_i) = (_s); (_i) <= (_e); (_i) += 1)
#define rfor(_i, _n) for((_i)=(_n)-1; ((_i) >= 0); (_i) -= 1)
#define rfore(_i, _n) for((_i)=(_n); (_i) >= 0; (_i) -= 1)
#define rforre(_i, _b, _e) for ((_i) = (_b); (_i) >= (_e); (_i) -= 1)
#define tailer(i, j) ((i) == (j) ? "\n" : " ")
#define access(_a, _i, _n, _obv) (ir((_i), 0, (_n)) ? (_a)[(_i)] : (_obv))
#define vecsize(t) vector<t>::size_type
#define veciter(t) vector<t>::iterator
#define foriter(_i, _c) for((_i) = (_c).begin(); (_i) != (_c).end(); ++(_i))
#endif
using namespace std;
#define N 5000
const int large = 1000000001;
struct append {
	int id, cost;
	append(int i, int c) {
		id = i;
		cost = c;
	}
};
int n, m, t;
vector<vector<append>> graph(N);
vector<int> top;
int s[N][N+1], x[N][N+1];
void topsort(void) {
	int i, inds[N];
	stack<int> stk;
	vector<append>::iterator nxt;
	vector<append> *nxts;
	forn(i, n) inds[i] = 0;
	forn(i, n) {
		nxts = &graph[i];
		for (nxt = nxts->begin(); nxt != nxts->end(); ++nxt) ++inds[nxt->id];
	}
	forn(i, n) if (inds[i] == 0) stk.push(i);
	while (!stk.empty()) {
		i = stk.top();
		stk.pop();
		top.push_back(i);
		nxts = &graph[i];
		for (nxt = nxts->begin(); nxt != nxts->end(); ++nxt) {
			--inds[nxt->id];
			if (inds[nxt->id] == 0) stk.push(nxt->id);
		}
	}
	assert((int)top.size() == n);
}
bool read(void) {
	int i, j, left, rght, cost;
	forn(i, n) fore(j, m) x[i][j] = -1;
	forn(i, N) graph[i].clear();
	top.clear();
	if (scanf("%d%d%d", &n, &m, &t) != 3)
		return false;
	forn(i, m) {
		scanf("%d%d%d", &left, &rght, &cost);
		--left, --rght;
		graph[left].push_back(append(rght, cost));
	}
	return true;
}
void print_path(int i, int j) {
	if (i == -1 || j <= 0) {
		printf("\n");
		return;
	}
	printf("%d ", i+1);
	print_path(x[i][j], j-1);
}
inline void print_s(int i, int j) {
	//printf("s[%2d][%2d]: %d\n", i+1, j, s[i][j]);
}
void solve(void) {
	int i, j, u, c;
	vector<append>::iterator v;
	vector<append> *nxts;
	s[n-1][1] = 0;
	forre(j, 2, m) s[n-1][j] = large;
	forre(j, 1, m) print_s(n-1, j);
	topsort();
	rfor(i, n) {
		u = top[i];
		if (u == n-1) continue;
		s[u][1] = large;
		print_s(u, 1);
		forre(j, 2, m) {
			s[u][j] = large;
			nxts = &graph[u];
			for (v = nxts->begin(); v != nxts->end(); ++v) {
				c = v->cost + s[v->id][j-1];
				if (s[u][j] > c) s[u][j] = c, x[u][j] = v->id;
			}
			print_s(u, j);
		}
	}
	rforre(j, m, 1) {
		if (n == 1000 && m == 999) {
			nxts = &graph[0];
			for (v = nxts->begin(); v != nxts->end(); ++v) {
				printf("%5d, %5d: cost: %5d\n", 0, v->id, v->cost);
			}
			forn(i, n) {
				forre(j, 1, m) {
					if (s[i][j] != large)
						printf("%2d, %2d: %d\n", i+1, j, s[i][j]);
				}
			}
		}
		print_s(0, j);
		if (s[0][j] <= t) break;
	}
	printf("%d\n", j);
	if (j >= 0) print_path(0, j);
}
int main(void) {
	while (read()) solve();
	return 0;
}


#include <array>
#include <cassert>
#include <cstdio>
#include <stack>
#include <vector>
#ifndef _TJYTLXWXHYZQFW_COMMON_H
#define _TJYTLXWXHYZQFW_COMMON_H
#include <climits>
#define ULL1 ((unsigned long long )1)
#define LL(x) ((long long)(x))
#define IOF(p) ((p) = ((p) < 0 ? INT_MAX : (p)))
#define LLOF(p) ((p) = ((p) < 0 ? LLONG_MAX :(p)))
#define ir(x, start, end) ((x) >= (start) && (x) < (end))
#define ire(x, start, end) ((x) >= (start) && (x) <= (end))
#define odd(x) ((x) & 1UL)
#define even(x) (!odd((x)))
#define sgn(n) (odd((n)) ? (-1) : (1))
#define abv(x) ((x) < 0 ? (x) * (-1) : (x))
#define forn(i, n) for ((i) = 0; (i) < (n); (i) += 1)
#define fore(i, n) for ((i) = 0; (i) <= (n); (i) += 1)
#define forr(i, s, e) for((i) = (s); (i) < (e); (i) += 1)
#define forre(i, s, e) for((i) = (s); (i) <= (e); (i) += 1)
#define rforre(i, b, e) for ((i) = (b); (i) >= (e); (i) -= 1)
#define tailer(i, j) ((i) == (j) ? "\n" : " ")
#define access(_a, _i, _n, _obv) (ir((_i), 0, (_n)) ? (_a)[(_i)] : (_obv))
#define vecsize(t) vector<t>::size_type
#define veciter(t) vector<t>::iterator
#endif
#define foreach(_i, _c) for((_i) = (_c).begin(); (_i) != (_c).end(); ++(_i))
using namespace std;
#define T 1000000001
#define N 5000
struct succer {
	int id;
	int cost;
	succer(int idx, int cst) {
		id = idx;
		cost = cst;
	}
};
int n, m, t;
array<array<int, N+1>, N> dp;
array<array<int, N+1>, N> path;
array<vector<succer>, N> nexts;
array<int, N> top;
void topsort(void)
{
	array<int, N> indg;
	stack<int> stk;
	veciter(succer) it;
	int topi, i, next;
	forn(i, n) foreach(it, nexts[i]) indg[it->id] = 0;
	forn(i, n) foreach(it, nexts[i]) indg[it->id] += 1;
	forn(i, n) if (indg[i] == 0) stk.push(i);
	topi = 0;
	while (not stk.empty()) {
		i = stk.top();
		stk.pop();
		top[topi++] = i;
		foreach(it, nexts[i]) {
			next = it->id;
			--indg[next];
			if (indg[next] == 0)
				stk.push(next);
		}
	}
	assert(topi == n);
}
int main(void)
{
	int i, j, k, ti, to;
	int left, right;
	int cost;
	veciter(succer) it;
	freopen("Inputs/721C", "r", stdin);
	scanf("%d%d%d", &n, &m, &t);
	forn(i, m) {
		scanf("%d%d%d", &left, &right, &cost);
		--left, --right;
		nexts[left].push_back(succer(right, cost));
	}
	topsort();
	printf("after topsort: n: %d\n", n);
	rforre(ti, n-1, 0) {
		i = top[ti];
		dp[i][1] = (i == n-1 ? 0 : T);
		forre(j, 2, n) {
			dp[i][j] = T;
			foreach(it, nexts[i]) {
				k = it->id;
				if (dp[k][j-1] < T) {
					dp[i][j] = min(dp[i][j], it->cost + dp[k][j-1]);
					to = k;
				}
			}
			path[i][j] = to;
		}
	}
	printf("after dp: n: %d\n", n);
	i = 0;
	rforre(j, 4, 1)
		if (dp[i][j] <= t) break;
	assert(j >= 1);
	printf("%d\n", j);
	while (i != n-1) {
		printf("%d ", i+1);
		i = path[i][j];
		--j;
	}
	printf("%d\n", n);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=5000+5;
template<int N,int M>
struct Graph
{
    int top;
    struct Vertex{
        int head;
    }V[N];
    struct Edge{
        int v,next,t;
    }E[M];
    void init(){
        memset(V,-1,sizeof(V));
        top = 0;
    }
    void add_edge(int u,int v,int t){
        E[top].v = v;
        E[top].t=t;
        E[top].next = V[u].head;
        V[u].head = top++;
    }
};
Graph<maxn,maxn> g;

int n,m,T,dp[maxn][maxn],pre[maxn][maxn],vis[maxn];

void dfs(int cur){
   if(vis[cur]!=0) return; vis[cur]=1;
   if(cur==1) dp[cur][1]=0;
   for(int i=g.V[cur].head;i!=-1;i=g.E[i].next){
       int f=g.E[i].v;dfs(f);
       for(int j=1;j<=n;j++){
          if(dp[f][j-1]+g.E[i].t<dp[cur][j]){
             dp[cur][j]=dp[f][j-1]+g.E[i].t;
             pre[cur][j]=f;
          }
       }
   }
}

void print(int t,int x){
   if(t>1) print(t-1,pre[x][t]); printf("%d ",x);
}

int main(){
   while(~scanf("%d%d%d",&n,&m,&T)){
       g.init();
       memset(dp,0x3f,sizeof(dp));
       for(int i=0;i<m;i++){
          int a,b;
          int c;scanf("%d%d%d",&a,&b,&c);
          g.add_edge(b,a,c);
       }
       dfs(n);
       int ans=0;
       for(int i=n;i>=0;i--){
         if(dp[n][i]<=T){
            ans=i;break;
         }
       }
       printf("%d\n",ans);
       print(ans,n);
       printf("\n");
   }
}


#include <fstream>
#include <iostream>
#include <string>
#include <cstring>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <ctime>
#include <assert.h>

#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define eps 1e-8
#define M_PI 3.141592653589793

typedef long long ll;
const ll mod=9973;
const int inf=0x7fffffff;
template<int N,int M>
struct Graph
{
    int top;
    struct Vertex{
        int head;
    }V[N];
    struct Edge{
        int v,next;
        ll t;
    }E[M];
    void init(){
        memset(V,-1,sizeof(V));
        top = 0;
    }
    void add_edge(int u,int v,ll t){
        E[top].v = v;
        E[top].t=t;
        E[top].next = V[u].head;
        V[u].head = top++;
    }
};

ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll extgcd(ll a,ll b,ll &x,ll &y) { ll d=a; if(b!=0){ d=extgcd(b,a%b,y,x); y-=(a/b)*x;} else x=1,y=0; return d;}
ll mod_reverse(ll a,ll n) {ll x,y; ll d=extgcd(a,n,x,y); if(d==1) return (x%n+n)%n; else return -1;}
ll inv(ll a,ll m) {return powmod(a,m-2);}
using namespace std;
Graph<5000+10,5000+10>g;
ll T;
int n,m,ans[5000+10],tem[5000+10],cnt;
void dfs(int cur,ll curt,int r){
   tem[r]=cur;
   if(cur==n){
      if(curt<=T&&r>cnt){
         for(int i=0;i<=r;i++) ans[i]=tem[i];
         cnt=r;
      }
      return;
   }
   for(int i=g.V[cur].head;i!=-1;i=g.E[i].next){
       int son=g.E[i].v;
       if(curt+g.E[i].t<=T) dfs(son,curt+g.E[i].t,r+1);
   }
}

int main(){
   while(~scanf("%d%d%I64d",&n,&m,&T)){
       g.init();
       for(int i=0;i<m;i++){
          int a,b;
          ll c;scanf("%d%d%I64d",&a,&b,&c);
          g.add_edge(a,b,c);
       }
       cnt=0;
       dfs(1,0,0);
       printf("%d\n",cnt+1);
       for(int i=0;i<cnt;i++){
          printf("%d ",ans[i]);
       }
       printf("%d\n",ans[cnt]);
   }
}


/*
#include <fstream>
#include <iostream>
#include <string>
#include <cstring>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <ctime>
#include <assert.h>

#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define eps 1e-8
#define M_PI 3.141592653589793

typedef long long ll;
const ll mod=9973;
const ll inf=0x7fffffff;
template<int N,int M>
struct Graph
{
    int top;
    struct Vertex{
        int head;
    }V[N];
    struct Edge{
        int v,next;
        ll t;
    }E[M];
    void init(){
        memset(V,-1,sizeof(V));
        top = 0;
    }
    void add_edge(int u,int v,ll t){
        E[top].v = v;
        E[top].t=t;
        E[top].next = V[u].head;
        V[u].head = top++;
    }
};

ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll extgcd(ll a,ll b,ll &x,ll &y) { ll d=a; if(b!=0){ d=extgcd(b,a%b,y,x); y-=(a/b)*x;} else x=1,y=0; return d;}
ll mod_reverse(ll a,ll n) {ll x,y; ll d=extgcd(a,n,x,y); if(d==1) return (x%n+n)%n; else return -1;}
ll inv(ll a,ll m) {return powmod(a,m-2);}
using namespace std;
Graph<5000+10,5000+10>g;
ll T;
int n,m,ans[5000+10],tem[5000+10],cnt;
ll limit[5005];

void dfs(int cur,ll curt,int r){
   tem[r]=cur;
   if(limit[cur]==-1) limit[cur]=curt;
   if(num[cur]==-1) num[cur]=r;
   if(curt>limit[cur]&&num[cur]>=r) return;
   if(cur==n){
      if(curt<=T&&r>cnt){
         for(int i=0;i<=r;i++) ans[i]=tem[i];
         cnt=r;
      }
      return;
   }
   for(int i=g.V[cur].head;i!=-1;i=g.E[i].next){
       int son=g.E[i].v;
       if(curt+g.E[i].t<=T){
            dfs(son,curt+g.E[i].t,r+1);
       }
   }
}

int main(){
   while(~scanf("%d%d%I64d",&n,&m,&T)){
       g.init();
       for(int i=1;i<=n;i++) limit[i]=-1,num[i]=-1;
       for(int i=0;i<m;i++){
          int a,b;
          ll c;scanf("%d%d%I64d",&a,&b,&c);
          g.add_edge(a,b,c);
       }
       cnt=0;
       dfs(1,0,0);
       printf("%d\n",cnt+1);
       for(int i=0;i<cnt;i++){
          printf("%d ",ans[i]);
       }
       printf("%d\n",ans[cnt]);
   }
}
*/
#include<bits/stdc++.h>
using namespace std;
const int maxn=5000+5;
template<int N,int M>
struct Graph
{
    int top;
    struct Vertex{
        int head;
    }V[N];
    struct Edge{
        int v,next,t;
    }E[M];
    void init(){
        memset(V,-1,sizeof(V));
        top = 0;
    }
    void add_edge(int u,int v,int t){
        E[top].v = v;
        E[top].t=t;
        E[top].next = V[u].head;
        V[u].head = top++;
    }
};
Graph<maxn,maxn> g;

int n,m,T,dp[maxn][maxn],pre[maxn][maxn],vis[maxn];

void dfs(int cur){
   if(vis[cur]!=0) return; vis[cur]=1;
   if(cur==1) dp[cur][1]=0;
   for(int i=g.V[cur].head;i!=-1;i=g.E[i].next){
       int f=g.E[i].v;dfs(f);
       for(int j=1;j<=n;j++){
          if(dp[f][j-1]+g.E[i].t<dp[cur][j]){
             dp[cur][j]=dp[f][j-1]+g.E[i].t;
             pre[cur][j]=f;
          }
       }
   }
}

void print(int t,int x){
   if(t>1) print(t-1,pre[x][t]); printf("%d ",x);
}

int main(){
   while(~scanf("%d%d%d",&n,&m,&T)){
       g.init();
       memset(vis,0,sizeof(vis));
       memset(dp,0x3f,sizeof(dp));
       for(int i=0;i<m;i++){
          int a,b;
          int c;scanf("%d%d%d",&a,&b,&c);
          g.add_edge(b,a,c);
       }
       dfs(n);
       int ans=0;
       for(int i=n;i>=0;i--){
         if(dp[n][i]<=T){
            ans=i;break;
         }
       }
       printf("%d\n",ans);
       print(ans,n);
       printf("\n");
   }
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=5000+5;
template<int N,int M>
struct Graph
{
    int top;
    struct Vertex{
        int head;
    }V[N];
    struct Edge{
        int v,next,t;
    }E[M];
    void init(){
        memset(V,-1,sizeof(V));
        top = 0;
    }
    void add_edge(int u,int v,int t){
        E[top].v = v;
        E[top].t=t;
        E[top].next = V[u].head;
        V[u].head = top++;
    }
};
Graph<maxn,maxn> g;

int n,m,T,dp[maxn][maxn],pre[maxn][maxn],vis[maxn];

void dfs(int cur){
   if(vis[cur]!=0) return; vis[cur]=1;
   if(cur==1) dp[cur][1]=0;
   for(int i=g.V[cur].head;i!=-1;i=g.E[i].next){
       int f=g.E[i].v;dfs(f);
       for(int j=1;j<=n;j++){
          if(dp[f][j-1]+g.E[i].t<dp[cur][j]){
             dp[cur][j]=dp[f][j-1]+g.E[i].t;
             pre[cur][j]=f;
          }
       }
   }
}

void print(int t,int x){
   if(t>1) print(t-1,pre[x][t]); printf("%d ",x);
}

int main(){
   while(~scanf("%d%d%d",&n,&m,&T)){
       g.init();
       for(int i=1;i<=n;i++){
          vis[i]=0;
          for(int j=0;j<=n;j++){
            dp[i][j]=0x3f;
          }
       }
       for(int i=0;i<m;i++){
          int a,b;
          int c;scanf("%d%d%d",&a,&b,&c);
          g.add_edge(b,a,c);
       }
       dfs(n);
       int ans=0;
       for(int i=n;i>=1;i--){
         if(dp[n][i]<=T){
            ans=i;break;
         }
       }
       printf("%d\n",ans);
       print(ans,n);
       printf("\n");
   }
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=5000+5;
template<int N,int M>
struct Graph
{
    int top;
    struct Vertex{
        int head;
    }V[N];
    struct Edge{
        int v,next,t;
    }E[M];
    void init(){
        memset(V,-1,sizeof(V));
        top = 0;
    }
    void add_edge(int u,int v,int t){
        E[top].v = v;
        E[top].t=t;
        E[top].next = V[u].head;
        V[u].head = top++;
    }
};
Graph<maxn,maxn> g;

int n,m,T,dp[maxn][maxn],pre[maxn][maxn],vis[maxn];

void dfs(int cur){
   if(vis[cur]!=0) return; vis[cur]=1;
   if(cur==1) dp[cur][1]=0;
   for(int i=g.V[cur].head;i!=-1;i=g.E[i].next){
       int f=g.E[i].v;dfs(f);
       for(int j=1;j<=n;j++){
          if(dp[f][j-1]+g.E[i].t<dp[cur][j]){
             dp[cur][j]=dp[f][j-1]+g.E[i].t;
             pre[cur][j]=f;
          }
       }
   }
}

void print(int t,int x){
   if(t>1) print(t-1,pre[x][t]); printf("%d ",x);
}

int main(){
   while(~scanf("%d%d%d",&n,&m,&T)){
       g.init();
       for(int i=1;i<=n;i++){
          vis[i]=0;
          for(int j=0;j<=n;j++){
            dp[i][j]=0x7fffffff;
          }
       }
       for(int i=0;i<m;i++){
          int a,b;
          int c;scanf("%d%d%d",&a,&b,&c);
          g.add_edge(b,a,c);
       }
       dfs(n);
       int ans=0;
       for(int i=n;i>=1;i--){
         if(dp[n][i]<=T){
            ans=i;break;
         }
       }
       printf("%d\n",ans);
       print(ans,n);
       printf("\n");
   }
}


/*
#include <fstream>
#include <iostream>
#include <string>
#include <cstring>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <ctime>
#include <assert.h>

#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define eps 1e-8
#define M_PI 3.141592653589793

typedef long long ll;
const ll mod=9973;
const ll inf=0x7fffffff;
template<int N,int M>
struct Graph
{
    int top;
    struct Vertex{
        int head;
    }V[N];
    struct Edge{
        int v,next;
        ll t;
    }E[M];
    void init(){
        memset(V,-1,sizeof(V));
        top = 0;
    }
    void add_edge(int u,int v,ll t){
        E[top].v = v;
        E[top].t=t;
        E[top].next = V[u].head;
        V[u].head = top++;
    }
};

ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll extgcd(ll a,ll b,ll &x,ll &y) { ll d=a; if(b!=0){ d=extgcd(b,a%b,y,x); y-=(a/b)*x;} else x=1,y=0; return d;}
ll mod_reverse(ll a,ll n) {ll x,y; ll d=extgcd(a,n,x,y); if(d==1) return (x%n+n)%n; else return -1;}
ll inv(ll a,ll m) {return powmod(a,m-2);}
using namespace std;
Graph<5000+10,5000+10>g;
ll T;
int n,m,ans[5000+10],tem[5000+10],cnt;
ll limit[5005];

void dfs(int cur,ll curt,int r){
   tem[r]=cur;
   if(limit[cur]==-1) limit[cur]=curt;
   if(num[cur]==-1) num[cur]=r;
   if(curt>limit[cur]&&num[cur]>=r) return;
   if(cur==n){
      if(curt<=T&&r>cnt){
         for(int i=0;i<=r;i++) ans[i]=tem[i];
         cnt=r;
      }
      return;
   }
   for(int i=g.V[cur].head;i!=-1;i=g.E[i].next){
       int son=g.E[i].v;
       if(curt+g.E[i].t<=T){
            dfs(son,curt+g.E[i].t,r+1);
       }
   }
}

int main(){
   while(~scanf("%d%d%I64d",&n,&m,&T)){
       g.init();
       for(int i=1;i<=n;i++) limit[i]=-1,num[i]=-1;
       for(int i=0;i<m;i++){
          int a,b;
          ll c;scanf("%d%d%I64d",&a,&b,&c);
          g.add_edge(a,b,c);
       }
       cnt=0;
       dfs(1,0,0);
       printf("%d\n",cnt+1);
       for(int i=0;i<cnt;i++){
          printf("%d ",ans[i]);
       }
       printf("%d\n",ans[cnt]);
   }
}
*/
#include<bits/stdc++.h>
using namespace std;
const int maxn=5000+5;
template<int N,int M>
struct Graph
{
    int top;
    struct Vertex{
        int head;
    }V[N];
    struct Edge{
        int v,next,t;
    }E[M];
    void init(){
        memset(V,-1,sizeof(V));
        top = 0;
    }
    void add_edge(int u,int v,int t){
        E[top].v = v;
        E[top].t=t;
        E[top].next = V[u].head;
        V[u].head = top++;
    }
};
Graph<maxn,maxn> g;

int n,m,T,dp[maxn][maxn],pre[maxn][maxn],vis[maxn];

void dfs(int cur){
   if(vis[cur]!=0) return; vis[cur]=1;
   if(cur==1) dp[cur][1]=0;
   for(int i=g.V[cur].head;i!=-1;i=g.E[i].next){
       int f=g.E[i].v;dfs(f);
       for(int j=1;j<=n;j++){
          if(dp[f][j-1]+g.E[i].t<dp[cur][j]){
             dp[cur][j]=dp[f][j-1]+g.E[i].t;
             pre[cur][j]=f;
          }
       }
   }
}

void print(int t,int x){
   if(t>1) print(t-1,pre[x][t]); printf("%d ",x);
}

int main(){
   while(~scanf("%d%d%d",&n,&m,&T)){
       g.init();
       for(int i=1;i<=n;i++){
         vis[i]=0;
         for(int j=0;j<=n;j++) dp[i][j]=0x3f;
       }
       for(int i=0;i<m;i++){
          int a,b;
          int c;scanf("%d%d%d",&a,&b,&c);
          g.add_edge(b,a,c);
       }
       dfs(n);
       int ans=0;
       for(int i=n;i>=0;i--){
         if(dp[n][i]<=T){
            ans=i;break;
         }
       }
       printf("%d\n",ans);
       print(ans,n);
       printf("\n");
   }
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=5000+5;
template<int N,int M>
struct Graph
{
    int top;
    struct Vertex{
        int head;
    }V[N];
    struct Edge{
        int v,next,t;
    }E[M];
    void init(){
        memset(V,-1,sizeof(V));
        top = 0;
    }
    void add_edge(int u,int v,int t){
        E[top].v = v;
        E[top].t=t;
        E[top].next = V[u].head;
        V[u].head = top++;
    }
};
Graph<maxn,maxn> g;

int n,m,T,dp[maxn][maxn],pre[maxn][maxn],vis[maxn];

void dfs(int cur){
   if(vis[cur]!=0) return; vis[cur]=1;
   if(cur==1) dp[cur][1]=0;
   for(int i=g.V[cur].head;i!=-1;i=g.E[i].next){
       int f=g.E[i].v;dfs(f);
       for(int j=1;j<=n;j++){
          if(dp[f][j-1]+g.E[i].t<dp[cur][j]){
             dp[cur][j]=dp[f][j-1]+g.E[i].t;
             pre[cur][j]=f;
          }
       }
   }
}

void print(int t,int x){
   if(t>1) print(t-1,pre[x][t]); printf("%d ",x);
}

int main(){
   while(~scanf("%d%d%d",&n,&m,&T)){
       g.init();
       for(int i=1;i<=n;i++){
          vis[i]=0;
          for(int j=0;j<=n;j++){
            dp[i][j]=0x7ffffff;
          }
       }
       for(int i=0;i<m;i++){
          int a,b;
          int c;scanf("%d%d%d",&a,&b,&c);
          g.add_edge(b,a,c);
       }
       dfs(n);
       int ans=0;
       for(int i=n;i>=1;i--){
         if(dp[n][i]<=T){
            ans=i;break;
         }
       }
       printf("%d\n",ans);
       print(ans,n);
       printf("\n");
   }
}


/*
#include <fstream>
#include <iostream>
#include <string>
#include <cstring>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <ctime>
#include <assert.h>

#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define eps 1e-8
#define M_PI 3.141592653589793

typedef long long ll;
const ll mod=9973;
const ll inf=0x7fffffff;
template<int N,int M>
struct Graph
{
    int top;
    struct Vertex{
        int head;
    }V[N];
    struct Edge{
        int v,next;
        ll t;
    }E[M];
    void init(){
        memset(V,-1,sizeof(V));
        top = 0;
    }
    void add_edge(int u,int v,ll t){
        E[top].v = v;
        E[top].t=t;
        E[top].next = V[u].head;
        V[u].head = top++;
    }
};

ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll extgcd(ll a,ll b,ll &x,ll &y) { ll d=a; if(b!=0){ d=extgcd(b,a%b,y,x); y-=(a/b)*x;} else x=1,y=0; return d;}
ll mod_reverse(ll a,ll n) {ll x,y; ll d=extgcd(a,n,x,y); if(d==1) return (x%n+n)%n; else return -1;}
ll inv(ll a,ll m) {return powmod(a,m-2);}
using namespace std;
Graph<5000+10,5000+10>g;
ll T;
int n,m,ans[5000+10],tem[5000+10],cnt;
ll limit[5005];

void dfs(int cur,ll curt,int r){
   tem[r]=cur;
   if(limit[cur]==-1) limit[cur]=curt;
   if(num[cur]==-1) num[cur]=r;
   if(curt>limit[cur]&&num[cur]>=r) return;
   if(cur==n){
      if(curt<=T&&r>cnt){
         for(int i=0;i<=r;i++) ans[i]=tem[i];
         cnt=r;
      }
      return;
   }
   for(int i=g.V[cur].head;i!=-1;i=g.E[i].next){
       int son=g.E[i].v;
       if(curt+g.E[i].t<=T){
            dfs(son,curt+g.E[i].t,r+1);
       }
   }
}

int main(){
   while(~scanf("%d%d%I64d",&n,&m,&T)){
       g.init();
       for(int i=1;i<=n;i++) limit[i]=-1,num[i]=-1;
       for(int i=0;i<m;i++){
          int a,b;
          ll c;scanf("%d%d%I64d",&a,&b,&c);
          g.add_edge(a,b,c);
       }
       cnt=0;
       dfs(1,0,0);
       printf("%d\n",cnt+1);
       for(int i=0;i<cnt;i++){
          printf("%d ",ans[i]);
       }
       printf("%d\n",ans[cnt]);
   }
}
*/
#include<bits/stdc++.h>
using namespace std;
const int maxn=5000+5;
template<int N,int M>
struct Graph
{
    int top;
    struct Vertex{
        int head;
    }V[N];
    struct Edge{
        int v,next,t;
    }E[M];
    void init(){
        memset(V,-1,sizeof(V));
        top = 0;
    }
    void add_edge(int u,int v,int t){
        E[top].v = v;
        E[top].t=t;
        E[top].next = V[u].head;
        V[u].head = top++;
    }
};
Graph<maxn,maxn> g;

int n,m,T,dp[maxn][maxn],pre[maxn][maxn],vis[maxn];

void dfs(int cur){
   if(vis[cur]!=0) return; vis[cur]=1;
   if(cur==1) dp[cur][1]=0;
   for(int i=g.V[cur].head;i!=-1;i=g.E[i].next){
       int f=g.E[i].v;dfs(f);
       for(int j=1;j<=n;j++){
          if(dp[f][j-1]+g.E[i].t<dp[cur][j]){
             dp[cur][j]=dp[f][j-1]+g.E[i].t;
             pre[cur][j]=f;
          }
       }
   }
}

void print(int t,int x){
   if(t>1) print(t-1,pre[x][t]); printf("%d ",x);
}

int main(){
   while(~scanf("%d%d%d",&n,&m,&T)){
       g.init();
       for(int i=0;i<=n;i++){
         vis[i]=0;
         for(int j=0;j<=n;j++) dp[i][j]=0x3f;
       }
       for(int i=0;i<m;i++){
          int a,b;
          int c;scanf("%d%d%d",&a,&b,&c);
          g.add_edge(b,a,c);
       }
       dfs(n);
       int ans=0;
       for(int i=n;i>=0;i--){
         if(dp[n][i]<=T){
            ans=i;break;
         }
       }
       printf("%d\n",ans);
       print(ans,n);
       printf("\n");
   }
}


/*
#include <fstream>
#include <iostream>
#include <string>
#include <cstring>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <ctime>
#include <assert.h>

#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define eps 1e-8
#define M_PI 3.141592653589793

typedef long long ll;
const ll mod=9973;
const ll inf=0x7fffffff;
template<int N,int M>
struct Graph
{
    int top;
    struct Vertex{
        int head;
    }V[N];
    struct Edge{
        int v,next;
        ll t;
    }E[M];
    void init(){
        memset(V,-1,sizeof(V));
        top = 0;
    }
    void add_edge(int u,int v,ll t){
        E[top].v = v;
        E[top].t=t;
        E[top].next = V[u].head;
        V[u].head = top++;
    }
};

ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll extgcd(ll a,ll b,ll &x,ll &y) { ll d=a; if(b!=0){ d=extgcd(b,a%b,y,x); y-=(a/b)*x;} else x=1,y=0; return d;}
ll mod_reverse(ll a,ll n) {ll x,y; ll d=extgcd(a,n,x,y); if(d==1) return (x%n+n)%n; else return -1;}
ll inv(ll a,ll m) {return powmod(a,m-2);}
using namespace std;
Graph<5000+10,5000+10>g;
ll T;
int n,m,ans[5000+10],tem[5000+10],cnt;
ll limit[5005];

void dfs(int cur,ll curt,int r){
   tem[r]=cur;
   if(limit[cur]==-1) limit[cur]=curt;
   if(num[cur]==-1) num[cur]=r;
   if(curt>limit[cur]&&num[cur]>=r) return;
   if(cur==n){
      if(curt<=T&&r>cnt){
         for(int i=0;i<=r;i++) ans[i]=tem[i];
         cnt=r;
      }
      return;
   }
   for(int i=g.V[cur].head;i!=-1;i=g.E[i].next){
       int son=g.E[i].v;
       if(curt+g.E[i].t<=T){
            dfs(son,curt+g.E[i].t,r+1);
       }
   }
}

int main(){
   while(~scanf("%d%d%I64d",&n,&m,&T)){
       g.init();
       for(int i=1;i<=n;i++) limit[i]=-1,num[i]=-1;
       for(int i=0;i<m;i++){
          int a,b;
          ll c;scanf("%d%d%I64d",&a,&b,&c);
          g.add_edge(a,b,c);
       }
       cnt=0;
       dfs(1,0,0);
       printf("%d\n",cnt+1);
       for(int i=0;i<cnt;i++){
          printf("%d ",ans[i]);
       }
       printf("%d\n",ans[cnt]);
   }
}
*/
#include<bits/stdc++.h>
using namespace std;
const int maxn=5000+5;
template<int N,int M>
struct Graph
{
    int top;
    struct Vertex{
        int head;
    }V[N];
    struct Edge{
        int v,next,t;
    }E[M];
    void init(){
        memset(V,-1,sizeof(V));
        top = 0;
    }
    void add_edge(int u,int v,int t){
        E[top].v = v;
        E[top].t=t;
        E[top].next = V[u].head;
        V[u].head = top++;
    }
};
Graph<maxn,maxn> g;

int n,m,T,dp[maxn][maxn],pre[maxn][maxn],vis[maxn];

void dfs(int cur){
   if(vis[cur]!=0) return; vis[cur]=1;
   if(cur==1) dp[cur][1]=0;
   for(int i=g.V[cur].head;i!=-1;i=g.E[i].next){
       int f=g.E[i].v;dfs(f);
       for(int j=1;j<=n;j++){
          if(dp[f][j-1]+g.E[i].t<dp[cur][j]){
             dp[cur][j]=dp[f][j-1]+g.E[i].t;
             pre[cur][j]=f;
          }
       }
   }
}

void print(int t,int x){
   if(t>1) print(t-1,pre[x][t]); printf("%d ",x);
}

int main(){
   while(~scanf("%d%d%d",&n,&m,&T)){
       g.init();
       for(int i=0;i<=n+3;i++){
         vis[i]=0;
         for(int j=0;j<=n+3;j++) dp[i][j]=0x3f;
       }
       for(int i=0;i<m;i++){
          int a,b;
          int c;scanf("%d%d%d",&a,&b,&c);
          g.add_edge(b,a,c);
       }
       dfs(n);
       int ans=0;
       for(int i=n;i>=0;i--){
         if(dp[n][i]<=T){
            ans=i;break;
         }
       }
       printf("%d\n",ans);
       print(ans,n);
       printf("\n");
   }
}


#include <fstream>
#include <iostream>
#include <string>
#include <cstring>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <ctime>
#include <assert.h>

#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define eps 1e-8
#define M_PI 3.141592653589793

typedef long long ll;
const ll mod=9973;
const ll inf=0x7fffffff;
template<int N,int M>
struct Graph
{
    int top;
    struct Vertex{
        int head;
    }V[N];
    struct Edge{
        int v,next;
        ll t;
    }E[M];
    void init(){
        memset(V,-1,sizeof(V));
        top = 0;
    }
    void add_edge(int u,int v,ll t){
        E[top].v = v;
        E[top].t=t;
        E[top].next = V[u].head;
        V[u].head = top++;
    }
};

ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll extgcd(ll a,ll b,ll &x,ll &y) { ll d=a; if(b!=0){ d=extgcd(b,a%b,y,x); y-=(a/b)*x;} else x=1,y=0; return d;}
ll mod_reverse(ll a,ll n) {ll x,y; ll d=extgcd(a,n,x,y); if(d==1) return (x%n+n)%n; else return -1;}
ll inv(ll a,ll m) {return powmod(a,m-2);}
using namespace std;
Graph<5000+10,5000+10>g;
ll T;
int n,m,ans[5000+10],tem[5000+10],cnt;
ll limit[5005];

void dfs(int cur,ll curt,int r){
   tem[r]=cur;
   if(limit[cur]==-1) limit[cur]=curt;
   if(curt>limit[cur]) return;
   if(cur==n){
      if(curt<=T&&r>cnt){
         for(int i=0;i<=r;i++) ans[i]=tem[i];
         cnt=r;
      }
      return;
   }
   for(int i=g.V[cur].head;i!=-1;i=g.E[i].next){
       int son=g.E[i].v;
       if(curt+g.E[i].t<=T){
            dfs(son,curt+g.E[i].t,r+1);
       }
   }
}

int main(){
   while(~scanf("%d%d%I64d",&n,&m,&T)){
       g.init();
       for(int i=1;i<=n;i++) limit[i]=-1;
       for(int i=0;i<m;i++){
          int a,b;
          ll c;scanf("%d%d%I64d",&a,&b,&c);
          g.add_edge(a,b,c);
       }
       cnt=0;
       dfs(1,0,0);
       printf("%d\n",cnt+1);
       for(int i=0;i<cnt;i++){
          printf("%d ",ans[i]);
       }
       printf("%d\n",ans[cnt]);
   }
}


#include <fstream>
#include <iostream>
#include <string>
#include <cstring>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <ctime>
#include <assert.h>

#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define eps 1e-8
#define M_PI 3.141592653589793

typedef long long ll;
const ll mod=9973;
const ll inf=0x7fffffff;
template<int N,int M>
struct Graph
{
    int top;
    struct Vertex{
        int head;
    }V[N];
    struct Edge{
        int v,next;
        ll t;
    }E[M];
    void init(){
        memset(V,-1,sizeof(V));
        top = 0;
    }
    void add_edge(int u,int v,ll t){
        E[top].v = v;
        E[top].t=t;
        E[top].next = V[u].head;
        V[u].head = top++;
    }
};

ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll extgcd(ll a,ll b,ll &x,ll &y) { ll d=a; if(b!=0){ d=extgcd(b,a%b,y,x); y-=(a/b)*x;} else x=1,y=0; return d;}
ll mod_reverse(ll a,ll n) {ll x,y; ll d=extgcd(a,n,x,y); if(d==1) return (x%n+n)%n; else return -1;}
ll inv(ll a,ll m) {return powmod(a,m-2);}
using namespace std;
Graph<5000+10,5000+10>g;
ll T;
int n,m,ans[5000+10],tem[5000+10],cnt,num[5000+10];
ll limit[5005];

void dfs(int cur,ll curt,int r){
   tem[r]=cur;
   if(limit[cur]==-1) limit[cur]=curt;
   if(num[cur]==-1) num[cur]=r;
   if(curt>limit[cur]&&num[cur]>=r) return;
   if(cur==n){
      if(curt<=T&&r>cnt){
         for(int i=0;i<=r;i++) ans[i]=tem[i];
         cnt=r;
      }
      return;
   }
   for(int i=g.V[cur].head;i!=-1;i=g.E[i].next){
       int son=g.E[i].v;
       if(curt+g.E[i].t<=T){
            dfs(son,curt+g.E[i].t,r+1);
       }
   }
}

int main(){
   while(~scanf("%d%d%I64d",&n,&m,&T)){
       g.init();
       for(int i=1;i<=n;i++) limit[i]=-1,num[i]=-1;
       for(int i=0;i<m;i++){
          int a,b;
          ll c;scanf("%d%d%I64d",&a,&b,&c);
          g.add_edge(a,b,c);
       }
       cnt=0;
       dfs(1,0,0);
       printf("%d\n",cnt+1);
       for(int i=0;i<cnt;i++){
          printf("%d ",ans[i]);
       }
       printf("%d\n",ans[cnt]);
   }
}


/*
#include <fstream>
#include <iostream>
#include <string>
#include <cstring>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <ctime>
#include <assert.h>

#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define eps 1e-8
#define M_PI 3.141592653589793

typedef long long ll;
const ll mod=9973;
const ll inf=0x7fffffff;
template<int N,int M>
struct Graph
{
    int top;
    struct Vertex{
        int head;
    }V[N];
    struct Edge{
        int v,next;
        ll t;
    }E[M];
    void init(){
        memset(V,-1,sizeof(V));
        top = 0;
    }
    void add_edge(int u,int v,ll t){
        E[top].v = v;
        E[top].t=t;
        E[top].next = V[u].head;
        V[u].head = top++;
    }
};

ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll extgcd(ll a,ll b,ll &x,ll &y) { ll d=a; if(b!=0){ d=extgcd(b,a%b,y,x); y-=(a/b)*x;} else x=1,y=0; return d;}
ll mod_reverse(ll a,ll n) {ll x,y; ll d=extgcd(a,n,x,y); if(d==1) return (x%n+n)%n; else return -1;}
ll inv(ll a,ll m) {return powmod(a,m-2);}
using namespace std;
Graph<5000+10,5000+10>g;
ll T;
int n,m,ans[5000+10],tem[5000+10],cnt;
ll limit[5005];

void dfs(int cur,ll curt,int r){
   tem[r]=cur;
   if(limit[cur]==-1) limit[cur]=curt;
   if(num[cur]==-1) num[cur]=r;
   if(curt>limit[cur]&&num[cur]>=r) return;
   if(cur==n){
      if(curt<=T&&r>cnt){
         for(int i=0;i<=r;i++) ans[i]=tem[i];
         cnt=r;
      }
      return;
   }
   for(int i=g.V[cur].head;i!=-1;i=g.E[i].next){
       int son=g.E[i].v;
       if(curt+g.E[i].t<=T){
            dfs(son,curt+g.E[i].t,r+1);
       }
   }
}

int main(){
   while(~scanf("%d%d%I64d",&n,&m,&T)){
       g.init();
       for(int i=1;i<=n;i++) limit[i]=-1,num[i]=-1;
       for(int i=0;i<m;i++){
          int a,b;
          ll c;scanf("%d%d%I64d",&a,&b,&c);
          g.add_edge(a,b,c);
       }
       cnt=0;
       dfs(1,0,0);
       printf("%d\n",cnt+1);
       for(int i=0;i<cnt;i++){
          printf("%d ",ans[i]);
       }
       printf("%d\n",ans[cnt]);
   }
}
*/
#include<bits/stdc++.h>
using namespace std;
const int maxn=5000+5;
template<int N,int M>
struct Graph
{
    int top;
    struct Vertex{
        int head;
    }V[N];
    struct Edge{
        int v,next,t;
    }E[M];
    void init(){
        memset(V,-1,sizeof(V));
        top = 0;
    }
    void add_edge(int u,int v,int t){
        E[top].v = v;
        E[top].t=t;
        E[top].next = V[u].head;
        V[u].head = top++;
    }
};
Graph<maxn,maxn> g;

int n,m,T,dp[maxn][maxn],pre[maxn][maxn],vis[maxn];

void dfs(int cur){
   if(vis[cur]!=0) return; vis[cur]=1;
   if(cur==1) dp[cur][1]=0;
   for(int i=g.V[cur].head;i!=-1;i=g.E[i].next){
       int f=g.E[i].v;dfs(f);
       for(int j=1;j<=n;j++){
          if(dp[f][j-1]+g.E[i].t<dp[cur][j]){
             dp[cur][j]=dp[f][j-1]+g.E[i].t;
             pre[cur][j]=f;
          }
       }
   }
}

void print(int t,int x){
   if(t>1) print(t-1,pre[x][t]); printf("%d ",x);
}

int main(){
   while(~scanf("%d%d%d",&n,&m,&T)){
       g.init();
       for(int i=1;i<=n;i++){

         for(int j=0;j<=n;j++) dp[i][j]=0x7ffffff;
       }
       for(int i=0;i<m;i++){
          int a,b;
          int c;scanf("%d%d%d",&a,&b,&c);
          g.add_edge(b,a,c);
       }
       dfs(n);
       int ans=0;
       for(int i=n;i>=0;i--){
         if(dp[n][i]<=T){
            ans=i;break;
         }
       }
       printf("%d\n",ans);
       print(ans,n);
       printf("\n");
   }
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=5000+5;
template<int N,int M>
struct Graph
{
    int top;
    struct Vertex{
        int head;
    }V[N];
    struct Edge{
        int v,next,t;
    }E[M];
    void init(){
        memset(V,-1,sizeof(V));
        top = 0;
    }
    void add_edge(int u,int v,int t){
        E[top].v = v;
        E[top].t=t;
        E[top].next = V[u].head;
        V[u].head = top++;
    }
};
Graph<maxn,maxn> g;

int n,m,T,dp[maxn][maxn],pre[maxn][maxn],vis[maxn];

void dfs(int cur){
   if(vis[cur]!=0) return; vis[cur]=1;
   if(cur==n) dp[cur][1]=0;
   for(int i=g.V[cur].head;i!=-1;i=g.E[i].next){
      int s=g.E[i].v;dfs(s);
      for(int j=1;j<=n;j++){
        if(dp[s][j-1]+g.E[i].t<dp[cur][j]){
            dp[cur][j]=dp[s][j-1]+g.E[i].t;
            pre[cur][j]=s;
        }
      }
   }
}

void print(int t,int x){
    printf("%d ",x);
    if(t>1) print(t-1,pre[x][t]);
}

int main(){
    while(~scanf("%d%d%d",&n,&m,&T)){
       g.init();
       memset(vis,0,sizeof(vis));
       memset(dp,0x3f,sizeof(dp));
       for(int i=0;i<m;i++){
          int a,b;
          int c;scanf("%d%d%d",&a,&b,&c);
          g.add_edge(a,b,c);
       }
       dfs(1);
       int ans=0;
       for(int i=n;i>=0;i--){
         if(dp[1][i]<=T){
            ans=i;break;
         }
       }
       printf("%d\n",ans);
       print(ans,1);
       printf("\n");
   }
}


/*
#include <fstream>
#include <iostream>
#include <string>
#include <cstring>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <ctime>
#include <assert.h>

#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define eps 1e-8
#define M_PI 3.141592653589793

typedef long long ll;
const ll mod=9973;
const ll inf=0x7fffffff;
template<int N,int M>
struct Graph
{
    int top;
    struct Vertex{
        int head;
    }V[N];
    struct Edge{
        int v,next;
        ll t;
    }E[M];
    void init(){
        memset(V,-1,sizeof(V));
        top = 0;
    }
    void add_edge(int u,int v,ll t){
        E[top].v = v;
        E[top].t=t;
        E[top].next = V[u].head;
        V[u].head = top++;
    }
};

ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll extgcd(ll a,ll b,ll &x,ll &y) { ll d=a; if(b!=0){ d=extgcd(b,a%b,y,x); y-=(a/b)*x;} else x=1,y=0; return d;}
ll mod_reverse(ll a,ll n) {ll x,y; ll d=extgcd(a,n,x,y); if(d==1) return (x%n+n)%n; else return -1;}
ll inv(ll a,ll m) {return powmod(a,m-2);}
using namespace std;
Graph<5000+10,5000+10>g;
ll T;
int n,m,ans[5000+10],tem[5000+10],cnt;
ll limit[5005];

void dfs(int cur,ll curt,int r){
   tem[r]=cur;
   if(limit[cur]==-1) limit[cur]=curt;
   if(num[cur]==-1) num[cur]=r;
   if(curt>limit[cur]&&num[cur]>=r) return;
   if(cur==n){
      if(curt<=T&&r>cnt){
         for(int i=0;i<=r;i++) ans[i]=tem[i];
         cnt=r;
      }
      return;
   }
   for(int i=g.V[cur].head;i!=-1;i=g.E[i].next){
       int son=g.E[i].v;
       if(curt+g.E[i].t<=T){
            dfs(son,curt+g.E[i].t,r+1);
       }
   }
}

int main(){
   while(~scanf("%d%d%I64d",&n,&m,&T)){
       g.init();
       for(int i=1;i<=n;i++) limit[i]=-1,num[i]=-1;
       for(int i=0;i<m;i++){
          int a,b;
          ll c;scanf("%d%d%I64d",&a,&b,&c);
          g.add_edge(a,b,c);
       }
       cnt=0;
       dfs(1,0,0);
       printf("%d\n",cnt+1);
       for(int i=0;i<cnt;i++){
          printf("%d ",ans[i]);
       }
       printf("%d\n",ans[cnt]);
   }
}
*/
#include<bits/stdc++.h>
using namespace std;
const int maxn=5000+5;
template<int N,int M>
struct Graph
{
    int top;
    struct Vertex{
        int head;
    }V[N];
    struct Edge{
        int v,next,t;
    }E[M];
    void init(){
        memset(V,-1,sizeof(V));
        top = 0;
    }
    void add_edge(int u,int v,int t){
        E[top].v = v;
        E[top].t=t;
        E[top].next = V[u].head;
        V[u].head = top++;
    }
};
Graph<maxn,maxn> g;

int n,m,T,dp[maxn][maxn],pre[maxn][maxn],vis[maxn];

void dfs(int cur){
   if(vis[cur]!=0) return; vis[cur]=1;
   if(cur==1) dp[cur][1]=0;
   for(int i=g.V[cur].head;i!=-1;i=g.E[i].next){
       int f=g.E[i].v;dfs(f);
       for(int j=1;j<=n;j++){
          if(dp[f][j-1]+g.E[i].t<dp[cur][j]){
             dp[cur][j]=dp[f][j-1]+g.E[i].t;
             pre[cur][j]=f;
          }
       }
   }
}

void print(int t,int x){
   if(t>1) print(t-1,pre[x][t]); printf("%d ",x);
}

int main(){
   while(~scanf("%d%d%d",&n,&m,&T)){
       g.init();
       for(int i=1;i<=n;i++) vis[i]=0;
       memset(dp,0x3f,sizeof(dp));

       for(int i=0;i<m;i++){
          int a,b;
          int c;scanf("%d%d%d",&a,&b,&c);
          g.add_edge(b,a,c);
       }
       dfs(n);
       int ans=0;
       for(int i=n;i>=0;i--){
         if(dp[n][i]<=T){
            ans=i;break;
         }
       }
       printf("%d\n",ans);
       print(ans,n);
       printf("\n");
   }
}