#include <bits/stdc++.h>
using namespace std;
vector<string> split(const string& s, char c) {
  vector<string> v;
  stringstream ss(s);
  string x;
  while (getline(ss, x, c)) v.push_back(move(x));
  return v;
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cerr << it->substr((*it)[0] == ' ', it->length()) << " = " << a << '\n';
  err(++it, args...);
}
int N, M;
long long T;
map<int, long long> adj[5013];
int dist[5013][5013];
bool visited[5013][5013];
int prevn[5013][5013];
priority_queue<pair<int, pair<int, int> >, vector<pair<int, pair<int, int> > >,
               greater<pair<int, pair<int, int> > > >
    pq;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M >> T;
  for (int i = 0; i < M; i++) {
    int u, v;
    long long t;
    cin >> u >> v >> t;
    adj[u - 1][v - 1] = t;
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= N; j++) {
      dist[i][j] = 1000000013;
      prevn[i][j] = -1;
    }
  }
  dist[0][1] = 0;
  pq.push(pair<int, pair<int, int> >{0, {0, 1}});
  while (!pq.empty()) {
    auto p = pq.top();
    pq.pop();
    int d = p.first;
    int v = p.second.first;
    int n = p.second.second;
    if (visited[v][n]) continue;
    visited[v][n] = true;
    for (auto p : adj[v]) {
      int u = p.first;
      if (d + adj[v][u] < dist[u][n + 1]) {
        dist[u][n + 1] = d + adj[v][u];
        pq.push(pair<int, pair<int, int> >{dist[u][n + 1], {u, n + 1}});
        prevn[u][n + 1] = v;
      }
    }
  }
  int k = N;
  while (k) {
    if (dist[N - 1][k] <= T) {
      break;
    }
    k--;
  }
  if (!k) {
    cout << -1 << endl;
    return 0;
  }
  cout << k << '\n';
  int c = N - 1;
  vector<int> ans;
  ans.push_back(c);
  while (prevn[c][k] != -1) {
    c = prevn[c][k];
    ans.push_back(c);
    k--;
  }
  for (int i = ans.size() - 1; i >= 0; i--) {
    cout << ans[i] + 1 << ' ';
  }
  cout << endl;
  return 0;
}
