#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, t, a, b, c, ma = -1, ma1;
  pair<int, int> al;
  cin >> n >> m >> t;
  bool used[m + 2][n];
  vector<pair<int, int>> spis[n];
  vector<int> ans;
  for (int i = 0; i < m; ++i) {
    cin >> a >> b >> c;
    spis[a - 1].push_back(make_pair(b - 1, c));
  }
  int dp[m + 2][n];
  int pr[m + 2][n];
  for (int i = 0; i <= m + 1; ++i) {
    for (int j = 0; j < n; ++j) {
      dp[i][j] = 1e9 + 7;
      ;
      pr[i][j] = -1;
      used[i][j] = false;
    }
  }
  queue<pair<int, int>> bfs;
  dp[1][0] = 0;
  bfs.push(make_pair(1, 0));
  while (!bfs.empty()) {
    al = bfs.front();
    if (al.second == n - 1) {
      if (dp[al.first][al.second] <= t) {
        ma = max(ma, al.first);
        if (ma == al.first) {
          ma1 = al.second;
        }
      }
    }
    bfs.pop();
    for (int i = 0; i < spis[al.second].size(); ++i) {
      if (dp[al.first + 1][spis[al.second][i].first] >
          (dp[al.first][al.second] + spis[al.second][i].second)) {
        dp[al.first + 1][spis[al.second][i].first] =
            (dp[al.first][al.second] + spis[al.second][i].second);
        pr[al.first + 1][spis[al.second][i].first] = al.second;
        if (!used[al.first + 1][spis[al.second][i].first]) {
          if (dp[al.first + 1][spis[al.second][i].first] <= t) {
            bfs.push(make_pair(al.first + 1, spis[al.second][i].first));
            used[al.first + 1][spis[al.second][i].first] = true;
          }
        }
      }
    }
  }
  cout << ma << endl;
  while (ma != 1) {
    ans.push_back(ma1);
    ma1 = pr[ma][ma1];
    --ma;
  }
  ans.push_back(0);
  for (int i = ans.size() - 1; i >= 0; --i) {
    cout << ans[i] + 1 << " ";
  }
  cout << endl;
  return 0;
}
