#include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;
const long long INF = 1ll << 60;
const int maxn = 1e6 + 10;
const int maxl = 5e3 + 10;
int dp[maxl][maxl];
int n, m, times;
vector<pair<int, int>> g[maxl];
pair<short, short> p[maxl][maxl];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m >> times;
  while (m--) {
    int u, v, d;
    cin >> u >> v >> d;
    --u, --v;
    g[u].push_back({v, d});
  }
  memset(dp, 0x3f, sizeof(dp));
  dp[0][1] = 0;
  for (int cnt = 1; cnt < n; ++cnt) {
    for (int i = (0); i < (n); ++i) {
      if (dp[i][cnt] < times) {
        for (auto& nx : g[i]) {
          int yy = dp[i][cnt] + nx.second;
          if (yy <= times) {
            int& ans = dp[nx.first][cnt + 1];
            if (ans > yy) {
              ans = yy;
              p[nx.first][cnt + 1] = {i, cnt};
            }
          }
        }
      }
    }
  }
  int k = -1;
  for (int i = 1; i <= n; ++i) {
    if (dp[n - 1][i] <= times) {
      k = i;
    }
  }
  vector<int> road;
  int city = n - 1, tt = k;
  while (city) {
    road.push_back(city);
    city = p[city][tt].first, --tt;
  }
  road.push_back(0);
  assert(road.size() == k);
  cout << k << "\n";
  for (int i = road.size() - 1; i >= 0; --i) cout << road[i] + 1 << " ";
}
