#include <bits/stdc++.h>   using namespace std;   int parent[5001][5001];   int dp[5001][5001];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     long long n, m, t;     cin >> n >> m >> t;     vector<int> u(m + 1), v(m + 1), tm(m + 1);     for (int i = 1; i <= m; i++) {       cin >> u[i] >> v[i] >> tm[i];     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         dp[i][j] = 1e9 + 5;       }     }     dp[1][1] = 0;     for (int i = 2; i <= n; i++) {       for (int j = 1; j <= m; j++) {         int p = u[j];         int cur = v[j];         if (dp[p][i - 1] + tm[j] < dp[cur][i]) {           dp[cur][i] = dp[p][i - 1] + tm[j];           parent[cur][i] = p;         }       }     }     int res = 0;     for (int i = n; i > 0; i--) {       if (dp[n][i] <= t) {         res = i;         break;       }     }     cout << res << endl;     int ind = n;     int visit = res;     vector<int> path;     while (ind != 0) {       path.push_back(ind);       ind = parent[ind][visit--];     }     for (int i = path.size() - 1; i >= 0; i--) {       cout << path[i] <<    ;     }     cout << endl;   }   