/*                                       ----.
     @'      @@@@  `@`    +@         _.'__    `.
    `#@     @'     `##    @@     .--(#)(##)---/#\
    #`#`   :#      `#@   ,.@   .' @          /###\
    @ .#   @`      `#.'  @ @   :         ,   #####
   ,+  @   @`      `# @ `+ @    `-..__.-' _.-\###/
   @@@@@,  #,      `# '.#  @          `;_:    `"'
   @   `@  `@      `#  @@  @        .'"""""`.
   @    @   '@@@@  `#      @       /,  ACM  ,\

    我只是一只每天吃着狗粮，默默刷题的单身狗
*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <vector>
using namespace std;
#define ll long long
#define db double
#define PI acos(-1.0)
#define EI 2.718281828
#define inf ((1ll<<63)-1)
#define INF ((1<<31)-1)
#define T while(1);
#define Frei freopen("input.txt", "r", stdin);
#define Freo freopen("output.txt", "w", stdout);
#define mem(x, y) memset(x, y, sizeof(x));
#define dbg(x) cout << #x << " = " << x << endl
const int MAXN = 100;
const int  MAXM = 100010;
const int  MAXP = 666666;
const int  MAX = 5e3+5;
const int maxn = 1e2+5;
const int mod = 100000007;
const db eps = 1e-7;
const int N = 107;
int ca = 1;

int n, m, t, v, u, q;
vector<int>mp[MAX];
vector<int>p[MAX];
int dp[MAX][MAX];
short pre[MAX][MAX];
int vis[MAX];

void dfs(int c) { // depth-first search from node c
    vis[c]=true;
    if(c==n)
        return;
    for(int i=0;i<mp[c].size();i++) {
        int k=mp[c][i],d=p[c][i];
        if(!vis[k])
            dfs(k);
        for(int j=2;j<=n;j++) {
            if(dp[k][j-1]+d<dp[c][j]) {
                dp[c][j]=dp[k][j-1]+d;
                pre[c][j]=k;
            }
        }
    }
}
int ans[MAX], cnt;

void solve()
{
    memset(pre,0,sizeof(pre));
    memset(vis,0,sizeof(vis));
    memset(dp,0x3f,sizeof(dp));
    scanf("%d%d%d", &n, &m, &t);
    for(int i=0; i<m; i++)
    {
        scanf("%d%d%d", &v, &u, &q);
        mp[v].push_back(u);
        p[v].push_back(q);
    }
    dp[n][1] = 0;
    dfs(1);
    int flag = 0, id = 1;
    for(int i=n; i>=1; i--)
    {
        if(dp[1][i] <= t)
        {
            flag = i;
            break;
        }
    }
    printf("%d\n1 ", flag);
    while(flag > 1)
    {
        id = pre[id][flag--];
        printf("%d%c", id, flag==1?'\n':' ');
    }
}
int main()
{
    //Frei;
    int t = 1;
    //scanf("%d", &t);
    while(t--) solve();
    return 0;
}


/*                                       ----.
     @'      @@@@  `@`    +@         _.'__    `.
    `#@     @'     `##    @@     .--(#)(##)---/#\
    #`#`   :#      `#@   ,.@   .' @          /###\
    @ .#   @`      `#.'  @ @   :         ,   #####
   ,+  @   @`      `# @ `+ @    `-..__.-' _.-\###/
   @@@@@,  #,      `# '.#  @          `;_:    `"'
   @   `@  `@      `#  @@  @        .'"""""`.
   @    @   '@@@@  `#      @       /,  ACM  ,\

    我只是一只每天吃着狗粮，默默刷题的单身狗
*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <vector>
using namespace std;
#define ll long long
#define db double
#define PI acos(-1.0)
#define EI 2.718281828
#define inf ((1ll<<63)-1)
#define INF ((1<<31)-1)
#define T while(1);
#define Frei freopen("input.txt", "r", stdin);
#define Freo freopen("output.txt", "w", stdout);
#define mem(x, y) memset(x, y, sizeof(x));
#define dbg(x) cout << #x << " = " << x << endl
const int MAXN = 100;
const int  MAXM = 100010;
const int  MAXP = 666666;
const int  MAX = 5e3+7;
const int maxn = 1e2+5;
const int mod = 100000007;
const db eps = 1e-7;
const int N = 107;
int ca = 1;

int n, m, t, v, u, q;
vector<int>mp[MAX];
vector<int>p[MAX];
int dp[MAX][MAX];
short pre[MAX][MAX];
int vis[MAX];
pair<int, int>aa;
map<pair<int, int>, int>mm;
map<pair<int, int>, int>::iterator ii;

void dfs(int id, int step)
{
    vis[id] = 1;
    if(id==n || step>n) return;
    for(int i=0; i<mp[id].size(); i++)
    {
        int u = mp[id][i];
        int d = p[id][i];
        if(dp[u][step+1]==0)
        {
            dp[u][step+1] = d+dp[id][step];
            pre[u][step+1] = id;
            dfs(u, step+1);
        }
        else if(dp[u][step+1] > d+dp[id][step])
        {
            dp[u][step+1] = d+dp[id][step];
            pre[u][step+1] = id;
            dfs(u, step+1);
        }
        //if(vis[u]) continue;
    }
}
int ans[MAX], cnt;

void solve()
{

    scanf("%d%d%d", &n, &m, &t);
    for(int i=0; i<m; i++)
    {
        scanf("%d%d%d", &aa.first, &aa.second, &q);
        if(mm[aa]!=0)
        {
            int tt = mm[aa];
            mm[aa] = min(tt, q);
            //cout << aa.x<<" "<<aa.y<<' ' << mm[aa] << endl;
        }
        else mm[aa] = q;
    }
    for(ii=mm.begin(); ii!=mm.end(); ii++)
    {
        v = ii->first.first;
        u = ii->first.second;
        q = ii->second;
        if(v==n)continue;
        mp[v].push_back(u);
        p[v].push_back(q);
    }
    dfs(1, 0);
    int flag, id = n;
    ans[cnt++] = n;
    for(int i=n; i>0; i--)
    {
        if(dp[n][i] <= t && dp[n][i])
        {
            flag = i;
            break;
        }
    }
    //cout << '*'<<flag <<endl;
    while(1)
    {
        id = pre[id][flag--];
        ans[cnt++] = id;
        if(id==1) break;
    }
    cout << cnt << endl;
    for(int i=cnt-1; i>=0; i--)
        printf("%d%c", ans[i], i==0?'\n':' ');
}
int main()
{
    //Frei;
    int t = 1;
    //scanf("%d", &t);
    while(t--) solve();
    return 0;
}


/*                                       ----.
     @'      @@@@  `@`    +@         _.'__    `.
    `#@     @'     `##    @@     .--(#)(##)---/#\
    #`#`   :#      `#@   ,.@   .' @          /###\
    @ .#   @`      `#.'  @ @   :         ,   #####
   ,+  @   @`      `# @ `+ @    `-..__.-' _.-\###/
   @@@@@,  #,      `# '.#  @          `;_:    `"'
   @   `@  `@      `#  @@  @        .'"""""`.
   @    @   '@@@@  `#      @       /,  ACM  ,\

    我只是一只每天吃着狗粮，默默刷题的单身狗
*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <vector>
using namespace std;
#define ll long long
#define db double
#define PI acos(-1.0)
#define EI 2.718281828
#define inf ((1ll<<63)-1)
#define INF ((1<<31)-1)
#define T while(1);
#define Frei freopen("input.txt", "r", stdin);
#define Freo freopen("output.txt", "w", stdout);
#define mem(x, y) memset(x, y, sizeof(x));
#define dbg(x) cout << #x << " = " << x << endl
const int MAXN = 100;
const int  MAXM = 100010;
const int  MAXP = 666666;
const int  MAX = 5e3+5;
const int maxn = 1e2+5;
const int mod = 100000007;
const db eps = 1e-7;
const int N = 107;
int ca = 1;

int n, m, t, v, u, q;
vector<int>mp[MAX];
vector<int>p[MAX];
int dp[MAX][MAX];
short pre[MAX][MAX];
int vis[MAX];

void dfs(int id)
{
    vis[id] = 1;
    if(id==n)return;
    for(int i=0; i<mp[id].size(); i++)
    {
        int u = mp[id][i];
        int d = p[id][i];
        if(!vis[u]);
            dfs(u);
        for(int j=2; j<=n; j++)
        {
            if(dp[u][j-1]+d < dp[id][j])
            {
                dp[id][j] = d+dp[u][j-1];
                pre[id][j] = u;
            }
        }
    }
}
int ans[MAX], cnt;

void solve()
{
    memset(pre,0,sizeof(pre));
    memset(vis,0,sizeof(vis));
    memset(dp,0x3f,sizeof(dp));
    scanf("%d%d%d", &n, &m, &t);
    for(int i=0; i<m; i++)
    {
        scanf("%d%d%d", &v, &u, &q);
        mp[v].push_back(u);
        p[v].push_back(q);
    }
    dp[n][1] = 0;
    dfs(1);
    int flag = 0, id = 1;
    for(int i=n; i>=1; i--)
    {
        if(dp[1][i] <= t)
        {
            flag = i;
            break;
        }
    }
    printf("%d\n1 ", flag);
    while(flag > 1)
    {
        id = pre[id][flag--];
        printf("%d%c", id, flag==1?'\n':' ');
    }
}
int main()
{
    //Frei;
    int t = 1;
    //scanf("%d", &t);
    while(t--) solve();
    return 0;
}


/*                                       ----.
     @'      @@@@  `@`    +@         _.'__    `.
    `#@     @'     `##    @@     .--(#)(##)---/#\
    #`#`   :#      `#@   ,.@   .' @          /###\
    @ .#   @`      `#.'  @ @   :         ,   #####
   ,+  @   @`      `# @ `+ @    `-..__.-' _.-\###/
   @@@@@,  #,      `# '.#  @          `;_:    `"'
   @   `@  `@      `#  @@  @        .'"""""`.
   @    @   '@@@@  `#      @       /,  ACM  ,\

    我只是一只每天吃着狗粮，默默刷题的单身狗
*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <vector>
using namespace std;
#define ll long long
#define db double
#define PI acos(-1.0)
#define EI 2.718281828
#define inf ((1ll<<63)-1)
#define INF ((1<<31)-1)
#define T while(1);
#define Frei freopen("input.txt", "r", stdin);
#define Freo freopen("output.txt", "w", stdout);
#define mem(x, y) memset(x, y, sizeof(x));
#define dbg(x) cout << #x << " = " << x << endl
const int MAXN = 100;
const int  MAXM = 100010;
const int  MAXP = 666666;
const int  MAX = 5e3+7;
const int maxn = 1e2+5;
const int mod = 100000007;
const db eps = 1e-7;
const int N = 107;
int ca = 1;

int n, m, t, v, u, q;
vector<int>mp[MAX];
vector<int>p[MAX];
int dp[MAX][MAX];
short pre[MAX][MAX];
int vis[MAX];

void dfs(int id)
{
    vis[id] = 1;
    if(id==n)return;
    for(int i=0; i<mp[id].size(); i++)
    {
        int u = mp[id][i];
        int d = p[id][i];
        if(!vis[u]);
            dfs(u);
        for(int j=2; j<=n; j++)
        {
            if(dp[u][j-1]+d < dp[id][j])
            {
                dp[id][j] = d+dp[u][j-1];
                pre[id][j] = u;
            }
        }
    }
}
int ans[MAX], cnt;

void solve()
{
    memset(dp,1e6,sizeof(dp));
    scanf("%d%d%d", &n, &m, &t);
    for(int i=0; i<m; i++)
    {
        scanf("%d%d%d", &v, &u, &q);
        mp[v].push_back(u);
        p[v].push_back(q);
    }
    dp[n][1] = 0;
    dfs(1);
    int flag, id = 1;
    for(int i=n; i>0; i--)
    {
        if(dp[1][i] <= t)
        {
            flag = i;
            break;
        }
    }
    ans[cnt++] = 1;

    while(1)
    {
        id = pre[id][flag--];
        ans[cnt++] = id;
        if(flag==1) break;
    }
    cout << cnt << endl;
    for(int i=0; i<cnt; i++)
        printf("%d%c", ans[i], i==cnt-1?'\n':' ');
}
int main()
{
    //Frei;
    int t = 1;
    //scanf("%d", &t);
    while(t--) solve();
    return 0;
}


/*                                       ----.
     @'      @@@@  `@`    +@         _.'__    `.
    `#@     @'     `##    @@     .--(#)(##)---/#\
    #`#`   :#      `#@   ,.@   .' @          /###\
    @ .#   @`      `#.'  @ @   :         ,   #####
   ,+  @   @`      `# @ `+ @    `-..__.-' _.-\###/
   @@@@@,  #,      `# '.#  @          `;_:    `"'
   @   `@  `@      `#  @@  @        .'"""""`.
   @    @   '@@@@  `#      @       /,  ACM  ,\

    我只是一只每天吃着狗粮，默默刷题的单身狗
*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <vector>
using namespace std;
#define ll long long
#define db double
#define PI acos(-1.0)
#define EI 2.718281828
#define inf ((1ll<<63)-1)
#define INF ((1<<31)-1)
#define T while(1);
#define Frei freopen("input.txt", "r", stdin);
#define Freo freopen("output.txt", "w", stdout);
#define mem(x, y) memset(x, y, sizeof(x));
#define dbg(x) cout << #x << " = " << x << endl
const int MAXN = 100;
const int  MAXM = 100010;
const int  MAXP = 666666;
const int  MAX = 5e3+7;
const int maxn = 1e2+5;
const int mod = 100000007;
const db eps = 1e-7;
const int N = 107;
int ca = 1;

int n, m, t, v, u, q;
vector<int>mp[MAX];
vector<int>p[MAX];
int dp[MAX][MAX];
short pre[MAX][MAX];
bool vis[MAX];

void dfs(int id, int step)
{
    if(vis[id])return;
    vis[id] = 1;
    for(int i=0; i<mp[id].size(); i++)
    {
        int u = mp[id][i];
        int d = p[id][i];
        if(dp[u][step+1]==0)
        {
            dp[u][step+1] = d+dp[id][step];
            pre[u][step+1] = id;
        }
        else if(dp[u][step+1] > d+dp[id][step])
        {
            dp[u][step+1] = d+dp[id][step];
            pre[u][step+1] = id;
        }
        if(u==n) continue;
        dfs(u, step+1);
    }
}
int ans[MAX], cnt;

void solve()
{
    scanf("%d%d%d", &n, &m, &t);
    for(int i=0; i<m; i++)
    {
        scanf("%d%d%d", &v, &u, &q);
        mp[v].push_back(u);
        p[v].push_back(q);
    }
    dfs(1, 0);
    int flag, id = n;
    ans[cnt++] = n;
    for(int i=n; i>0; i--)
    {
        if(dp[n][i] <= t && dp[n][i])
        {
            flag = i;
            break;
        }
    }
    //cout << '*'<<flag <<endl;
    while(1)
    {
        id = pre[id][flag--];
        ans[cnt++] = id;
        if(id==1) break;
    }
    cout << cnt << endl;
    for(int i=cnt-1; i>=0; i--)
        printf("%d%c", ans[i], i==0?'\n':' ');
}
int main()
{
    //Frei;
    int t = 1;
    //scanf("%d", &t);
    while(t--) solve();
    return 0;
}


/*                                       ----.
     @'      @@@@  `@`    +@         _.'__    `.
    `#@     @'     `##    @@     .--(#)(##)---/#\
    #`#`   :#      `#@   ,.@   .' @          /###\
    @ .#   @`      `#.'  @ @   :         ,   #####
   ,+  @   @`      `# @ `+ @    `-..__.-' _.-\###/
   @@@@@,  #,      `# '.#  @          `;_:    `"'
   @   `@  `@      `#  @@  @        .'"""""`.
   @    @   '@@@@  `#      @       /,  ACM  ,\

    我只是一只每天吃着狗粮，默默刷题的单身狗
*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <vector>
using namespace std;

const int MAXN = 100;
const int  MAXM = 100010;
const int  MAXP = 666666;
const int  MAX = 5e3+5;
const int maxn = 1e2+5;
const int mod = 100000007;
const int N = 107;
int ca = 1;

int n, m;
vector<int>mp[MAX];
vector<int>p[MAX];
int dp[MAX][MAX];
short pre[MAX][MAX];
int vis[MAX];

void dfs(int id)
{
    vis[id] = 1;
    if(id==n)return;
    for(int i=0; i<mp[id].size(); i++)
    {
        int u = mp[id][i];
        int d = p[id][i];
        if(!vis[u]);
            dfs(u);
        for(int j=2; j<=n; j++)
        {
            if(dp[u][j-1]+d < dp[id][j])
            {
                dp[id][j] = d+dp[u][j-1];
                pre[id][j] = u;
            }
        }
    }
}
int ans[MAX], cnt;

void solve()
{
    int t, v, u, q;
    memset(pre,0,sizeof(pre));
    memset(vis,0,sizeof(vis));
    memset(dp,0x3f,sizeof(dp));
    scanf("%d%d%d", &n, &m, &t);
    for(int i=0; i<m; i++)
    {
        scanf("%d%d%d", &v, &u, &q);
        mp[v].push_back(u);
        p[v].push_back(q);
    }
    dp[n][1] = 0;
    dfs(1);
    int flag = 0, id = 1;
    for(int i=n; i>=1; i--)
    {
        if(dp[1][i] <= t)
        {
            flag = i;
            break;
        }
    }
    printf("%d\n1 ", flag);
    while(flag > 1)
    {
        if(flag!=1) printf("%d ", pre[id][flag]);
        else printf("%d\n", pre[id][flag]);
        id = pre[id][flag--];
        //id = pre[id][flag--];
        //printf("%d%c", id, flag==1?'\n':' ');
    }
}
int main()
{
    //Frei;
    int t = 1;
    //scanf("%d", &t);
    while(t--) solve();
    return 0;
}


/*                                       ----.
     @'      @@@@  `@`    +@         _.'__    `.
    `#@     @'     `##    @@     .--(#)(##)---/#\
    #`#`   :#      `#@   ,.@   .' @          /###\
    @ .#   @`      `#.'  @ @   :         ,   #####
   ,+  @   @`      `# @ `+ @    `-..__.-' _.-\###/
   @@@@@,  #,      `# '.#  @          `;_:    `"'
   @   `@  `@      `#  @@  @        .'"""""`.
   @    @   '@@@@  `#      @       /,  ACM  ,\

    我只是一只每天吃着狗粮，默默刷题的单身狗
*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <vector>
using namespace std;
#define ll long long
#define db double
#define PI acos(-1.0)
#define EI 2.718281828
#define inf ((1ll<<63)-1)
#define INF ((1<<31)-1)
#define T while(1);
#define Frei freopen("input.txt", "r", stdin);
#define Freo freopen("output.txt", "w", stdout);
#define mem(x, y) memset(x, y, sizeof(x));
#define dbg(x) cout << #x << " = " << x << endl
const int MAXN = 100;
const int  MAXM = 100010;
const int  MAXP = 666666;
const int  MAX = 5e3+7;
const int maxn = 1e2+5;
const int mod = 100000007;
const db eps = 1e-7;
const int N = 107;
int ca = 1;

int n, m, t, v, u, q;
vector<int>mp[MAX];
vector<int>p[MAX];
int dp[MAX][MAX];
short pre[MAX][MAX];
int vis[MAX];

void dfs(int id)
{
    vis[id] = 1;
    if(id==n)return;
    for(int i=0; i<mp[id].size(); i++)
    {
        int u = mp[id][i];
        int d = p[id][i];
        if(!vis[u]);
            dfs(u);
        for(int j=2; j<=n; j++)
        {
            if(dp[u][j-1]+d < dp[id][j])
            {
                dp[id][j] = d+dp[u][j-1];
                pre[id][j] = u;
            }
        }
    }
}
int ans[MAX], cnt;

void solve()
{
    memset(dp,1e6,sizeof(dp));
    scanf("%d%d%d", &n, &m, &t);
    for(int i=0; i<m; i++)
    {
        scanf("%d%d%d", &v, &u, &q);
        mp[v].push_back(u);
        p[v].push_back(q);
    }
    dp[n][1] = 0;
    dfs(1);
    int flag, id = 1;
    for(int i=n; i>0; i--)
    {
        if(dp[1][i] <= t)
        {
            flag = i;
            break;
        }
    }
    printf("%d\n1 ", flag);
    while(1)
    {
        id = pre[id][flag--];
        printf("%d%c", id, flag==1?'\n':' ');
        if(flag==1) break;
    }
}
int main()
{
    //Frei;
    int t = 1;
    //scanf("%d", &t);
    while(t--) solve();
    return 0;
}


/*                                       ----.
     @'      @@@@  `@`    +@         _.'__    `.
    `#@     @'     `##    @@     .--(#)(##)---/#\
    #`#`   :#      `#@   ,.@   .' @          /###\
    @ .#   @`      `#.'  @ @   :         ,   #####
   ,+  @   @`      `# @ `+ @    `-..__.-' _.-\###/
   @@@@@,  #,      `# '.#  @          `;_:    `"'
   @   `@  `@      `#  @@  @        .'"""""`.
   @    @   '@@@@  `#      @       /,  ACM  ,\

    我只是一只每天吃着狗粮，默默刷题的单身狗
*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <vector>
using namespace std;
#define ll long long
#define db double
#define PI acos(-1.0)
#define EI 2.718281828
#define inf ((1ll<<63)-1)
#define INF ((1<<31)-1)
#define T while(1);
#define Frei freopen("input.txt", "r", stdin);
#define Freo freopen("output.txt", "w", stdout);
#define mem(x, y) memset(x, y, sizeof(x));
#define dbg(x) cout << #x << " = " << x << endl
const int MAXN = 100;
const int  MAXM = 100010;
const int  MAXP = 666666;
const int  MAX = 5e3+7;
const int maxn = 1e2+5;
const int mod = 100000007;
const db eps = 1e-7;
const int N = 107;
int ca = 1;

int n, m, t, v, u, q;
vector<int>mp[MAX];
vector<int>p[MAX];
int dp[MAX][MAX];
short pre[MAX][MAX];
int vis[MAX];

void dfs(int id)
{
    vis[id] = 1;
    if(id==n)return;
    for(int i=0; i<mp[id].size(); i++)
    {
        int u = mp[id][i];
        int d = p[id][i];
        if(!vis[u]);
            dfs(u);
        for(int j=2; j<=n; j++)
        {
            if(dp[u][j-1]+d < dp[id][j])
            {
                dp[id][j] = d+dp[u][j-1];
                pre[id][j] = u;
            }
        }
    }
}
int ans[MAX], cnt;

void solve()
{
    memset(dp,0x3f,sizeof(dp));
    scanf("%d%d%d", &n, &m, &t);
    for(int i=0; i<m; i++)
    {
        scanf("%d%d%d", &v, &u, &q);
        mp[v].push_back(u);
        p[v].push_back(q);
    }
    dp[n][1] = 0;
    dfs(1);
    int flag, id = 1;
    for(int i=n; i>0; i--)
    {
        if(dp[1][i] <= t)
        {
            flag = i;
            break;
        }
    }
    printf("%d\n1 ", flag);
    while(1)
    {
        id = pre[id][flag--];
        printf("%d%c", id, flag==1?'\n':' ');
        if(flag==1) break;
    }
}
int main()
{
    //Frei;
    int t = 1;
    //scanf("%d", &t);
    while(t--) solve();
    return 0;
}


/*                                       ----.
     @'      @@@@  `@`    +@         _.'__    `.
    `#@     @'     `##    @@     .--(#)(##)---/#\
    #`#`   :#      `#@   ,.@   .' @          /###\
    @ .#   @`      `#.'  @ @   :         ,   #####
   ,+  @   @`      `# @ `+ @    `-..__.-' _.-\###/
   @@@@@,  #,      `# '.#  @          `;_:    `"'
   @   `@  `@      `#  @@  @        .'"""""`.
   @    @   '@@@@  `#      @       /,  ACM  ,\

    我只是一只每天吃着狗粮，默默刷题的单身狗
*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <vector>
using namespace std;
#define ll long long
#define db double
#define PI acos(-1.0)
#define EI 2.718281828
#define inf ((1ll<<63)-1)
#define INF ((1<<31)-1)
#define T while(1);
#define Frei freopen("input.txt", "r", stdin);
#define Freo freopen("output.txt", "w", stdout);
#define mem(x, y) memset(x, y, sizeof(x));
#define dbg(x) cout << #x << " = " << x << endl
const int MAXN = 100;
const int  MAXM = 100010;
const int  MAXP = 666666;
const int  MAX = 5e3+7;
const int maxn = 1e2+5;
const int mod = 100000007;
const db eps = 1e-7;
const int N = 107;
int ca = 1;

int n, m, t, v, u, q;
vector<int>mp[MAX];
vector<int>p[MAX];
int dp[MAX][MAX];
short pre[MAX][MAX];
int vis[MAX];

void dfs(int id, int step)
{
    //vis[id] = 1;
    if(id==n) return;
    for(int i=0; i<mp[id].size(); i++)
    {
        int u = mp[id][i];
        if(vis[u]) continue;
        int d = p[id][i];
        if(dp[u][step+1]==0)
        {
            dp[u][step+1] = d+dp[id][step];
            pre[u][step+1] = id;
        }
        else if(dp[u][step+1] > d+dp[id][step])
        {
            dp[u][step+1] = d+dp[id][step];
            pre[u][step+1] = id;
        }
            dfs(u, step+1);
    }
}
int ans[MAX], cnt;

void solve()
{
    scanf("%d%d%d", &n, &m, &t);
    for(int i=0; i<m; i++)
    {
        scanf("%d%d%d", &v, &u, &q);
        mp[v].push_back(u);
        p[v].push_back(q);
    }
    dfs(1, 0);
    int flag, id = n;
    ans[cnt++] = n;
    for(int i=n; i>0; i--)
    {
        if(dp[n][i] <= t && dp[n][i])
        {
            flag = i;
            break;
        }
    }
    //cout << '*'<<flag <<endl;
    while(1)
    {
        id = pre[id][flag--];
        ans[cnt++] = id;
        if(id==1) break;
    }
    cout << cnt << endl;
    for(int i=cnt-1; i>=0; i--)
        printf("%d%c", ans[i], i==0?'\n':' ');
}
int main()
{
    //Frei;
    int t = 1;
    //scanf("%d", &t);
    while(t--) solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define INF INT_MAX
const int sz=5001;
vector<pair<int,ll> > a[sz];
ll dis[sz]={0};
bool vis[sz]={0};
int s[sz];
unordered_map<int,ll> p[5001];
ll ans[5001]={0};
int t,n;
int dfs(int x)
{

    //if(x==n)
    //cout<<"here";
    if(x==n){
        p[x][x]=1;
        vis[x]=1;
        ans[x]=p[x].size();
    return ans[x];
    }
    vis[x]=1;
    for(auto it=a[x].begin();it!=a[x].end();++it)
    {
            dis[it->first]=it->second+dis[x];
            vis[it->first]=1;
            if(dis[it->first]>t)
            return ans[x];

            int temp=dfs(it->first);
            /*if(it->first==n)
            {
             //   cout<<x<<" ";
            //    if(p[it->first].find(n)!=p[it->first].end())
              //  cout<<"here";
              // cout<<p[n].size()<<" ";
            }*/

            if(p[it->first].find(n)!=p[it->first].end()&&temp>ans[x]){
            ans[x]=temp;
            p[x].clear();
            for(auto it2=p[it->first].begin();it2!=p[it->first].end();++it2)
                p[x][it2->first]=1;

            //p[x][x]=1;

            }

    }

        p[x][x]=1;
    ans[x]=p[x].size();
    return ans[x];
}
bool check(int a,int b)
{
    return dis[a]<dis[b];
}
int main() {
    cin.tie(NULL);
    int i,j,k=0,l,m;
    cin>>n>>m>>t;
    int x,y;
    ll z;
    while(m--)
    {
        cin>>x>>y>>z;
              a[x].push_back(make_pair(y,z));

    }

    dfs(1);
   //for(i=1;i<=n;i++)
    //cout<<p[i].size()<<" ";
    cout<<p[1].size()<<"\n";
    l=0;
     for(auto it2=p[1].begin();it2!=p[1].end();++it2)
          s[l++]=(it2->first);
          //      cout<<it2->first<<" ";

            sort(s,s+l,check);
           for(i=0;i<l;i++)
           cout<<s[i]<<" ";
    // your code goes here
	return 0;
}


#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>
using namespace std;
using namespace __gnu_cxx;

#define EPS      1e-9
#define F        first
#define S        second
#define pi       acos(-1)
#define ll       long long
#define oo       0x3f3f3f3f
#define sz(x)    (int)x.size()
#define sc(x)    scanf("%d",&x)
#define all(x)   x.begin(),x.end()
#define rall(x)  x.rbegin(),x.rend()

int n, m, t;
vector<pair<int, int> > adj[5050];
ll dp[5050][5050];
char vis[5050][5050], visId;

ll solve(int u, int rem) {
  if (u == n)
    return (rem == 0 ? 0 : oo);
  ll &ret = dp[u][rem];
  if (vis[u][rem] == visId)
    return ret;
  vis[u][rem] = visId;
  ret = oo;
  for (int i = 0; i < sz(adj[u]); i++) {
    ret = min(ret, solve(adj[u][i].F, max(0, rem - 1)) + adj[u][i].S);
  }
  return ret;
}

void printAns(int u, int rem) {
  if (u == n)
    return;
  ll &ret = dp[u][rem];
  for (int i = 0; i < sz(adj[u]); i++) {
    if (ret == solve(adj[u][i].F, max(0, rem - 1)) + adj[u][i].S) {
      printf("%d ", adj[u][i].F);
      printAns(adj[u][i].F, max(0, rem - 1));
      return;
    }
  }
}

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
#endif
  scanf("%d%d%d", &n, &m, &t);
  for (int i = 0; i < m; i++) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    adj[u].push_back(make_pair(v, w));
  }
  int l = 2, r = n, mid;
  while (l < r) {
    mid = l + (r - l + 1) / 2;
    visId++;
    if (solve(1, mid - 1) <= t)
      l = mid;
    else
      r = mid - 1;
  }
  visId++;
  solve(1, l - 1);
  printf("%d\n%d ", l, 1);
  printAns(1, l - 1);
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define INF INT_MAX
const int sz=5001;
vector<pair<int,ll> > a[sz];
ll dis[sz]={0};
bool vis[sz]={0};
int s[sz];
//int b[5001][5001];
list<int> p[5001];
ll ans[5001]={0};
ll t,n;
bool dfs(int x)
{

    p[x].push_back(x);
    ans[x]=1;
    if(x==n){
        p[x].clear();

    p[x].push_back(x);
        vis[x]=1;
        ans[x]=p[x].size();
    return 1;
    }
    vis[x]=1;
    bool flag=0,flag2=0;
    for(auto it=a[x].begin();it!=a[x].end();++it)
    {
            dis[it->first]=it->second+dis[x];
            vis[it->first]=1;
            if(dis[it->first]>t)
            return 0;
            flag=0;
            bool temp=dfs(it->first);

            if(ans[it->first]+1>ans[x]&&temp){
            ans[x]=ans[it->first]+1;
            p[x].clear();
            flag2=1;
            p[x].push_back(x);
            for(auto it2=p[it->first].begin();it2!=p[it->first].end();++it2)
                p[x].push_back(*it2);

            }

    }

    ans[x]=p[x].size();
    return flag2;
}
bool check(int a,int b)
{
    return dis[a]<dis[b];
}
int main() {
    cin.tie(NULL);
    int i,j,k=0,l,m;
    cin>>n>>m>>t;
    int x,y;
    ll z;
    while(m--)
    {
        cin>>x>>y>>z;
              a[x].push_back(make_pair(y,z));

    }

    dfs(1);
    cout<<p[1].size()<<"\n";

    //l=0;
     for(auto it2=p[1].begin();it2!=p[1].end();++it2)
     cout<<*it2<<" ";

    // your code goes here
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define INF INT_MAX
const int sz=5001;
vector<pair<int,int> > a[sz];
int dis[sz]={0};
list<int> p[5001];
int ans[5001]={0};
int t,n;
bool dfs(int x)
{

    p[x].push_back(x);
    ans[x]=1;
    if(x==n){
        p[x].clear();

    p[x].push_back(x);
        ans[x]=p[x].size();
    return 1;
    }
    bool flag=0,flag2=0;
    for(auto it=a[x].begin();it!=a[x].end();++it)
    {
            dis[it->first]=it->second+dis[x];
            if(dis[it->first]>t)
            return 0;
            flag=0;
            bool temp=dfs(it->first);

            if(ans[it->first]+1>ans[x]&&temp){
            ans[x]=ans[it->first]+1;
            p[x].clear();
            flag2=1;
            p[x].push_back(x);
            for(auto it2=p[it->first].begin();it2!=p[it->first].end();++it2)
                p[x].push_back(*it2);

            }

    }

    ans[x]=p[x].size();
    return flag2;
}
int main() {
    cin.tie(NULL);
    int i,j,k=0,l,m;
    cin>>n>>m>>t;
    int x,y;
    ll z;
    while(m--)
    {
        cin>>x>>y>>z;
              a[x].push_back(make_pair(y,z));

    }

    dfs(1);
    cout<<p[1].size()<<"\n";

    //l=0;
     for(auto it2=p[1].begin();it2!=p[1].end();++it2)
     cout<<*it2<<" ";

    // your code goes here
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define INF INT_MAX
const int sz=5001;
vector<pair<int,ll> > a[sz];
ll dis[sz]={0};
bool vis[sz]={0};
int s[sz];
//int b[5001][5001];
list<int> p[5001];
ll ans[5001]={0};
ll t,n;
bool dfs(int x)
{

    p[x].push_back(x);
    if(x==n){
        vis[x]=1;
        ans[x]=p[x].size();
    return 1;
    }
    vis[x]=1;
    bool flag=0;
    for(auto it=a[x].begin();it!=a[x].end();++it)
    {
            dis[it->first]=it->second+dis[x];
            vis[it->first]=1;
            if(dis[it->first]>t)
            return 0;
            flag=0;
            bool temp=dfs(it->first);

            if(ans[it->first]+1>ans[x]&&temp){
            ans[x]=ans[it->first]+1;
            p[x].clear();
            flag=1;
            p[x].push_back(x);
            for(auto it2=p[it->first].begin();it2!=p[it->first].end();++it2)
                p[x].push_back(*it2);

            }

    }

    ans[x]=p[x].size();
    return flag;
}
bool check(int a,int b)
{
    return dis[a]<dis[b];
}
int main() {
    cin.tie(NULL);
    int i,j,k=0,l,m;
    cin>>n>>m>>t;
    int x,y;
    ll z;
    while(m--)
    {
        cin>>x>>y>>z;
              a[x].push_back(make_pair(y,z));

    }

    dfs(1);
    cout<<p[1].size()<<"\n";

    //l=0;
     for(auto it2=p[1].begin();it2!=p[1].end();++it2)
     cout<<*it2<<" ";

    // your code goes here
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define INF INT_MAX
const int sz=5001;
vector<pair<int,int> > a[sz];
int dis[sz]={0};
int p[5001][5001];
int ans[5001]={0};
int t,n;
bool dfs(int x)
{

    p[x][0]=x;
    ans[x]=1;
    if(x==n){

    p[x][0]=x;
        ans[x]=1;
    return 1;
    }
    bool flag=0,flag2=0;
    for(auto it=a[x].begin();it!=a[x].end();++it)
    {
            dis[it->first]=it->second+dis[x];
            if(dis[it->first]>t)
            return 0;
            flag=0;
            bool temp=dfs(it->first);

            if(ans[it->first]+1>ans[x]&&temp){
            ans[x]=ans[it->first]+1;
            flag2=1;
            p[x][0]=x;
            for(int it2=0;it2<ans[it->first];++it2)
                p[x][it2+1]=p[it->first][it2];

            }

    }

    return flag2;
}
int main() {
    cin.tie(NULL);
    int i,j,k=0,l,m;
    cin>>n>>m>>t;
    int x,y;
    ll z;
    while(m--)
    {
        cin>>x>>y>>z;
              a[x].push_back(make_pair(y,z));

    }

    dfs(1);
    cout<<ans[1]<<"\n";

    //l=0;
     for(int it2=0;it2<ans[1];++it2)
     cout<<p[1][it2]<<" ";

    // your code goes here
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define INF INT_MAX
const int sz=5001;
vector<pair<int,int> > a[sz];
int dis[sz]={0};
bool vis[sz]={0};
int s[sz];
unordered_map<int,int> p[5001];
int ans[5001]={0};
int t,n;
int dfs(int x)
{

    //if(x==n)
    //cout<<"here";
    if(x==n){
        p[x][x]=1;
        vis[x]=1;
        ans[x]=p[x].size();
    return ans[x];
    }
    vis[x]=1;
    for(auto it=a[x].begin();it!=a[x].end();++it)
    {
        if(!vis[it->first])
        {
            dis[it->first]=it->second+dis[x];
            vis[it->first]=1;
            if(dis[it->first]>t)
            return ans[x];

            int temp=dfs(it->first);
            /*if(it->first==n)
            {
             //   cout<<x<<" ";
            //    if(p[it->first].find(n)!=p[it->first].end())
              //  cout<<"here";
              // cout<<p[n].size()<<" ";
            }*/

            if(p[it->first].find(n)!=p[it->first].end()&&temp>ans[x]){
            ans[x]=temp;
            p[x].clear();
            for(auto it2=p[it->first].begin();it2!=p[it->first].end();++it2)
                p[x][it2->first]=1;

            //p[x][x]=1;

            }

        }
    }

        p[x][x]=1;
    ans[x]=p[x].size();
    return ans[x];
}
bool check(int a,int b)
{
    return dis[a]<dis[b];
}
int main() {
    cin.tie(NULL);
    int i,j,k=0,l,m;
    cin>>n>>m>>t;
    int x,y,z;
    while(m--)
    {
        cin>>x>>y>>z;
              a[x].push_back(make_pair(y,z));

    }

    dfs(1);
   //for(i=1;i<=n;i++)
    //cout<<p[i].size()<<" ";
    cout<<p[1].size()<<"\n";
    l=0;
     for(auto it2=p[1].begin();it2!=p[1].end();++it2)
          s[l++]=(it2->first);
          //      cout<<it2->first<<" ";

            sort(s,s+l,check);
           for(i=0;i<l;i++)
           cout<<s[i]<<" ";
    // your code goes here
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define INF INT_MAX
const int sz=5001;
vector<pair<int,int> > a[sz];
int dis[sz]={0};
int p[5001][5001];
int ans[5001]={0};
int t,n;
bool dfs(int x)
{

    p[x][0]=x;
    ans[x]=1;
    if(x==n){

    p[x][0]=x;
        ans[x]=1;
    return 1;
    }
    bool flag=0,flag2=0;
    for(auto it=a[x].begin();it!=a[x].end();++it)
    {
            dis[it->first]=it->second+dis[x];
            if(dis[it->first]>t)
            return 0;
            flag=0;
            bool temp=dfs(it->first);

            if(ans[it->first]+1>ans[x]&&temp){
            ans[x]=ans[it->first]+1;
            flag2=1;
            p[x][0]=x;
            for(int it2=0;it2<ans[it->first];++it2)
                p[x][it2+1]=p[it->first][it2];

            }

    }

    return flag2;
}
int readInt () {
	bool minus = false;
	int result = 0;
	char ch;
	ch = getchar();
	while (true) {
		if (ch == '-') break;
		if (ch >= '0' && ch <= '9') break;
		ch = getchar();
	}
	if (ch == '-') minus = true; else result = ch-'0';
	while (true) {
		ch = getchar();
		if (ch < '0' || ch > '9') break;
		result = result*10 + (ch - '0');
	}
	if (minus)
		return -result;
	else
		return result;
}

int main() {
    //cin.tie(NULL);
    int i,j,k=0,l,m;
    //cin>>n>>m>>t;
    n=readInt ();
    m=readInt ();
    t=readInt ();
    int x,y;
    ll z;
    while(m--)
    {
        //cin>>x>>y>>z;
          x=readInt ();
          y=readInt ();
          z=readInt ();
          a[x].push_back(make_pair(y,z));

    }

    dfs(1);
    //cout<<ans[1]<<"\n";
    printf("%d\n",ans[1]);
    //l=0;
     for(int it2=0;it2<ans[1];++it2)
     printf("%d ",p[1][it2]);
     //cout<<p[1][it2]<<" ";

    // your code goes here
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define INF INT_MAX
const int sz=5001;
vector<pair<int,ll> > a[sz];
ll dis[sz]={0};
bool vis[sz]={0};
int s[sz];
//int b[5001][5001];
list<int> p[5001];
ll ans[5001]={0};
ll t,n;
bool dfs(int x)
{

    p[x].push_back(x);
    ans[x]=1;
    if(x==n){
        vis[x]=1;
        ans[x]=p[x].size();
    return 1;
    }
    vis[x]=1;
    bool flag=0,flag2=0;
    for(auto it=a[x].begin();it!=a[x].end();++it)
    {
            dis[it->first]=it->second+dis[x];
            vis[it->first]=1;
            if(dis[it->first]>t)
            return 0;
            flag=0;
            bool temp=dfs(it->first);

            if(ans[it->first]+1>ans[x]&&temp){
            ans[x]=ans[it->first]+1;
            p[x].clear();
            flag2=1;
            p[x].push_back(x);
            for(auto it2=p[it->first].begin();it2!=p[it->first].end();++it2)
                p[x].push_back(*it2);

            }

    }

    ans[x]=p[x].size();
    return flag2;
}
bool check(int a,int b)
{
    return dis[a]<dis[b];
}
int main() {
    cin.tie(NULL);
    int i,j,k=0,l,m;
    cin>>n>>m>>t;
    int x,y;
    ll z;
    while(m--)
    {
        cin>>x>>y>>z;
              a[x].push_back(make_pair(y,z));

    }

    dfs(1);
    cout<<p[1].size()<<"\n";

    //l=0;
     for(auto it2=p[1].begin();it2!=p[1].end();++it2)
     cout<<*it2<<" ";

    // your code goes here
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define INF INT_MAX
const int sz=5001;
vector<pair<int,ll> > a[sz];
ll dis[sz]={0};
bool vis[sz]={0};
int s[sz];
unordered_map<int,ll> p[5001];
ll ans[5001]={0};
ll t,n;
ll dfs(int x)
{

    //if(x==n)
    //cout<<"here";
    if(x==n){
        p[x][x]=1;
        vis[x]=1;
        ans[x]=p[x].size();
    return ans[x];
    }
    vis[x]=1;
    for(auto it=a[x].begin();it!=a[x].end();++it)
    {
            dis[it->first]=it->second+dis[x];
            vis[it->first]=1;
            if(dis[it->first]>t)
            return ans[x];

            int temp=dfs(it->first);
            /*if(it->first==n)
            {
             //   cout<<x<<" ";
            //    if(p[it->first].find(n)!=p[it->first].end())
              //  cout<<"here";
              // cout<<p[n].size()<<" ";
            }*/

            if(p[it->first].find(n)!=p[it->first].end()&&temp>ans[x]){
            ans[x]=temp;
            p[x].clear();
            for(auto it2=p[it->first].begin();it2!=p[it->first].end();++it2)
                p[x][it2->first]=1;

            //p[x][x]=1;

            }

    }

        p[x][x]=1;
    ans[x]=p[x].size();
    return ans[x];
}
bool check(int a,int b)
{
    return dis[a]<dis[b];
}
int main() {
    cin.tie(NULL);
    int i,j,k=0,l,m;
    cin>>n>>m>>t;
    int x,y;
    ll z;
    while(m--)
    {
        cin>>x>>y>>z;
              a[x].push_back(make_pair(y,z));

    }

    dfs(1);
   //for(i=1;i<=n;i++)
    //cout<<p[i].size()<<" ";
    if(p[1].size()==1)
    {
        cout<<"2\n";
        cout<<"1 "<<n;
        return 0;
    }
    cout<<p[1].size()<<"\n";

    l=0;
     for(auto it2=p[1].begin();it2!=p[1].end();++it2)
          s[l++]=(it2->first);
          //      cout<<it2->first<<" ";

            sort(s,s+l,check);
           //cout<<l<<""
           for(i=0;i<l;i++)
           cout<<s[i]<<" ";
    // your code goes here
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define INF INT_MAX
const int sz=5001;
vector<pair<int,int> > a[sz];
int dis[sz]={0};
bool vis[sz]={0};
int s[sz];
unordered_map<int,int> p[5001];
int ans[5001]={0};
int t,n;
int dfs(int x)
{

    //if(x==n)
    //cout<<"here";
    if(x==n){
        p[x][x]=1;
        vis[x]=1;
        ans[x]=p[x].size();
    return ans[x];
    }
    vis[x]=1;
    for(auto it=a[x].begin();it!=a[x].end();++it)
    {
            dis[it->first]=it->second+dis[x];
            vis[it->first]=1;
            if(dis[it->first]>t)
            return ans[x];

            int temp=dfs(it->first);
            /*if(it->first==n)
            {
             //   cout<<x<<" ";
            //    if(p[it->first].find(n)!=p[it->first].end())
              //  cout<<"here";
              // cout<<p[n].size()<<" ";
            }*/

            if(p[it->first].find(n)!=p[it->first].end()&&temp>ans[x]){
            ans[x]=temp;
            p[x].clear();
            for(auto it2=p[it->first].begin();it2!=p[it->first].end();++it2)
                p[x][it2->first]=1;

            //p[x][x]=1;

            }

    }

        p[x][x]=1;
    ans[x]=p[x].size();
    return ans[x];
}
bool check(int a,int b)
{
    return dis[a]<dis[b];
}
int main() {
    cin.tie(NULL);
    int i,j,k=0,l,m;
    cin>>n>>m>>t;
    int x,y,z;
    while(m--)
    {
        cin>>x>>y>>z;
              a[x].push_back(make_pair(y,z));

    }

    dfs(1);
   //for(i=1;i<=n;i++)
    //cout<<p[i].size()<<" ";
    cout<<p[1].size()<<"\n";
    l=0;
     for(auto it2=p[1].begin();it2!=p[1].end();++it2)
          s[l++]=(it2->first);
          //      cout<<it2->first<<" ";

            sort(s,s+l,check);
           for(i=0;i<l;i++)
           cout<<s[i]<<" ";
    // your code goes here
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define INF INT_MAX
const int sz=5001;
vector<pair<int,ll> > a[sz];
ll dis[sz]={0};
bool vis[sz]={0};
int s[sz];
//int b[5001][5001];
list<int> p[5001];
ll ans[5001]={0};
ll t,n;
bool dfs(int x)
{

    p[x].push_back(x);
    if(x==n){
        vis[x]=1;
        ans[x]=p[x].size();
    return 1;
    }
    vis[x]=1;
    bool flag=0;
    for(auto it=a[x].begin();it!=a[x].end();++it)
    {
            dis[it->first]=it->second+dis[x];
            vis[it->first]=1;
            if(dis[it->first]>t)
            return 0;

            bool temp=dfs(it->first);

            if(ans[it->first]+1>ans[x]&&temp){
            ans[x]=ans[it->first]+1;
            p[x].clear();
            flag=1;
            p[x].push_back(x);
            for(auto it2=p[it->first].begin();it2!=p[it->first].end();++it2)
                p[x].push_back(*it2);

            }

    }

    ans[x]=p[x].size();
    return flag;
}
bool check(int a,int b)
{
    return dis[a]<dis[b];
}
int main() {
    cin.tie(NULL);
    int i,j,k=0,l,m;
    cin>>n>>m>>t;
    int x,y;
    ll z;
    while(m--)
    {
        cin>>x>>y>>z;
              a[x].push_back(make_pair(y,z));

    }

    dfs(1);
    cout<<p[1].size()<<"\n";

    l=0;
     for(auto it2=p[1].begin();it2!=p[1].end();++it2)
     cout<<*it2<<" ";

    // your code goes here
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#define ll long long int
#define m1 make_pair
#define ll long long int
int dp[5000+1][5000+1];
//dp[1][1]=0;

int dp1[5001][5001];
ll calculate(int i,int j,vector<pair<int,ll>> adj[])
{
    if(dp[i][j]!=-1)
    return dp[i][j];
    else if(j<0)
    return 1100000000;
    else
    {
       dp[i][j]=1100000000;
        for(int v=0;v<adj[i].size();v++)
        {
            ll y=calculate(adj[i][v].first,j-1,adj)+adj[i][v].second;
            if(dp[i][j]>y)
            {
                dp[i][j]=y;
                dp1[i][j]=adj[i][v].first;
            }
        }

    return dp[i][j];
    }

}
int main()
{
 int n,m,t;
 cin>>n>>m>>t;
 vector<pair<int,ll>> adj[n+1];int u,v,t1;
 for(int i=0;i<m;i++)
 {
     cin>>u>>v>>t1;
     adj[v].push_back(m1(u,t1));
 }
 for(int i=0;i<=5000;i++)
for(int j=1;j<=5000;j++)
dp[i][j]=-1;
dp[1][1]=0;
 for(int i=1;i<=n;i++)
 for(int j=1;j<=n;j++)
  dp[i][j]=calculate(i,j,adj);
  int cnt;
  for(int i=1;i<=n;i++)
  {
      if(dp[n][i]<=t)
      cnt=i;
  }
  cout<<cnt<<endl;
  stack<int>st;
int to=dp1[n][cnt];
st.push(n);
cnt--;
  while(cnt>=1)
  {
      cnt--;
      st.push(to);
      to=dp1[to][cnt];

  }
  while(!st.empty())
  {
      cout<<st.top()<<" ";
      st.pop();
  }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#define ll long long int
#define m1 make_pair
#define ll long long int

void dfs(vector<pair<int,ll>> adj[],int u,ll dp[],ll t[],int n,int t1)
{
    //visited[u]=1;
   // int mx=0;
   if(u==n)
   return;
    for(int i=0;i<adj[u].size();i++)
    {
        dfs(adj,adj[u][i].first,dp,t,n,t1);
        if(t[adj[u][i].first]+adj[u][i].second<=t1)
        {
            t[u]=t[adj[u][i].first]+adj[u][i].second;
            dp[u]=max(dp[u],1+dp[adj[u][i].first]);
        }
        else
        {
            dp[adj[u][i].first]=0;
        }
    }
  //  dp[u]=mx+1;
}
void dfs1(vector<pair<int,ll>> adj[],int u,ll dp[],int n)
{
    cout<<u<<" ";
    if(u==n)
    return;
    for(int i=0;i<adj[u].size();i++)
    {
        if(dp[u]==(1+dp[adj[u][i].first]))
        {
            dfs1(adj,adj[u][i].first,dp,n);
            break;
        }

    }
}
struct s
{
    ll l,r;

};
bool compare1(s s1,s s2)
{
    if(s1.l>s2.l)
    return 1;
    else if(s1.l==s2.l)
    return (s1.r<=s2.r);
    else
    return 0;
}
int main()
{
 int n,m,t;
 cin>>n>>m>>t;
 vector<pair<int,ll>> adj[n+1];int u,v,t1;
 for(int i=0;i<m;i++)
 {
     cin>>u>>v>>t1;
     adj[u].push_back(m1(v,t1));
 }
 ll dp[n+1]={0},time[n+1]={0};
 dp[n]=1,time[n]=0;
 dfs(adj,1,dp,time,n,t);
 cout<<dp[1]<<endl;
 dfs1(adj,1,dp,n);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#define ll long long int
#define m1 make_pair
#define ll long long int

void dfs(vector<pair<int,ll>> adj[],int u,ll dp[],ll t[],int n,ll t1,bool visited[])
{
    visited[u]=1;
   // int mx=0;
   if(u==n)
   return;
    for(int i=0;i<adj[u].size();i++)
    {
        if(!visited[adj[u][i].first])
        {
        //t2[adj[u][i].first]=t2[u]+adj[u][i].second;
        dfs(adj,adj[u][i].first,dp,t,n,t1,visited);
        if(t[adj[u][i].first]+adj[u][i].second<=t1)
        {
            t[u]=t[adj[u][i].first]+adj[u][i].second;
            if(dp[adj[u][i].first])
            dp[u]=max(dp[u],1+dp[adj[u][i].first]);
        }
        else
        {
            dp[adj[u][i].first]=0;
           // dp[u]=0;
        }
        }
        else
        {
             if(t[adj[u][i].first]+adj[u][i].second<=t1)
        {
            t[u]=t[adj[u][i].first]+adj[u][i].second;
            if(dp[adj[u][i].first])
            dp[u]=max(dp[u],1+dp[adj[u][i].first]);

        }
        else
        {
           // dp[u]=0;
           dp[adj[u][i].first]=0;
        }
        }
    }
  //  dp[u]=mx+1;
}
void dfs1(vector<pair<int,ll>> adj[],int u,ll dp[],int n,ll t[],ll t1)
{
    cout<<u<<" ";
    if(u==n)
    return;
    for(int i=0;i<adj[u].size();i++)
    {
        if(dp[u]==(1+dp[adj[u][i].first])&&(t[adj[u][i].first]+adj[u][i].second<=t1))
        {
            dfs1(adj,adj[u][i].first,dp,n,t,t1);
            break;
        }

    }
}
struct s
{
    ll l,r;

};
bool compare1(s s1,s s2)
{
    if(s1.l>s2.l)
    return 1;
    else if(s1.l==s2.l)
    return (s1.r<=s2.r);
    else
    return 0;
}
int main()
{
 int n,m,t;
 cin>>n>>m>>t;
 vector<pair<int,ll>> adj[n+1];int u,v,t1;
 for(int i=0;i<m;i++)
 {
     cin>>u>>v>>t1;
     adj[u].push_back(m1(v,t1));
 }
 ll dp[n+1]={0},time[n+1]={0};bool visited[n+1]={0};
 dp[n]=1,time[n]=0;
 dfs(adj,1,dp,time,n,t,visited);
 cout<<dp[1]<<endl;
 dfs1(adj,1,dp,n,time,t);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#define ll long long int
#define m1 make_pair
#define ll long long int
int dp[5000+1][5000+1];
//dp[1][1]=0;

int dp1[5001][5001];
ll calculate(int i,int j,vector<pair<int,ll>> adj[])
{
    if(dp[i][j]!=-1)
    return dp[i][j];
    else if(j<0)
    return 1100000000;
    else
    {
       dp[i][j]=1100000000;
        for(int v=0;v<adj[i].size();v++)
        {
            ll y=calculate(adj[i][v].first,j-1,adj)+adj[i][v].second;
            if(dp[i][j]>y)
            {
                dp[i][j]=y;
                dp1[i][j]=adj[i][v].first;
            }
        }

    return dp[i][j];
    }

}
int main()
{
 int n,m,t;
 cin>>n>>m>>t;
 vector<pair<int,ll>> adj[n+1];int u,v,t1;
 for(int i=0;i<m;i++)
 {
     cin>>u>>v>>t1;
     adj[v].push_back(m1(u,t1));
 }
 for(int i=0;i<=5000;i++)
for(int j=1;j<=5000;j++)
dp[i][j]=-1;
dp[1][1]=0;
 for(int i=1;i<=n;i++)
 for(int j=1;j<=n;j++)
  dp[i][j]=calculate(i,j,adj);
  int cnt;
  for(int i=1;i<=n;i++)
  {
      if(dp[n][i]<=t)
      cnt=i;
  }
  cout<<cnt<<endl;
  stack<int>st;
int to=dp1[n][cnt];
st.push(n);
cnt--;
  while(cnt>=1)
  {
      cnt--;
      st.push(to);
      to=dp1[to][cnt];

  }
  while(!st.empty())
  {
     if(st.top())
      cout<<st.top()<<" ";
      st.pop();
  }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#define ll long long int
#define m1 make_pair
#define ll long long int

void dfs(vector<pair<int,ll>> adj[],int u,ll dp[],ll t[],int n,ll t1,bool visited[])
{
    visited[u]=1;
   // int mx=0;
   if(u==n)
   return;
    for(int i=0;i<adj[u].size();i++)
    {
        if(!visited[adj[u][i].first])
        {
        //t2[adj[u][i].first]=t2[u]+adj[u][i].second;
        dfs(adj,adj[u][i].first,dp,t,n,t1,visited);
        if(t[adj[u][i].first]+adj[u][i].second<=t1)
        {
            t[u]=t[adj[u][i].first]+adj[u][i].second;
            if(dp[adj[u][i].first])
            dp[u]=max(dp[u],1+dp[adj[u][i].first]);
        }
        else
        {
            dp[adj[u][i].first]=0;
           // dp[u]=0;
        }
        }
        else
        {
             if(t[adj[u][i].first]+adj[u][i].second<=t1)
        {
            t[u]=t[adj[u][i].first]+adj[u][i].second;
            if(dp[adj[u][i].first])
            dp[u]=max(dp[u],1+dp[adj[u][i].first]);

        }
        else
        {
           // dp[u]=0;
           dp[adj[u][i].first]=0;
        }
        }
    }
  //  dp[u]=mx+1;
}
void dfs1(vector<pair<int,ll>> adj[],int u,ll dp[],int n,ll t[],ll t1,bool visited[])
{
    cout<<u<<" ";
    visited[u]=1;
    if(u==n)
    return;
    for(int i=0;i<adj[u].size();i++)
    {
        if(!visited[adj[u][i].first])
        if(dp[u]==(1+dp[adj[u][i].first])&&(t[adj[u][i].first]+adj[u][i].second<=t1))
        {
            dfs1(adj,adj[u][i].first,dp,n,t,t1,visited);
            break;
        }

    }
}
struct s
{
    ll l,r;

};
bool compare1(s s1,s s2)
{
    if(s1.l>s2.l)
    return 1;
    else if(s1.l==s2.l)
    return (s1.r<=s2.r);
    else
    return 0;
}
int main()
{
 int n,m,t;
 cin>>n>>m>>t;
 vector<pair<int,ll>> adj[n+1];int u,v,t1;
 for(int i=0;i<m;i++)
 {
     cin>>u>>v>>t1;
     adj[u].push_back(m1(v,t1));
 }
 ll dp[n+1]={0},time[n+1]={0};bool visited[n+1]={0};
 dp[n]=1,time[n]=0;
 dfs(adj,1,dp,time,n,t,visited);
 cout<<dp[1]<<endl;
 for(int i=1;i<=n;i++)
 visited[i]=0;
 dfs1(adj,1,dp,n,time,t,visited);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#define ll long long int
#define m1 make_pair
#define ll long long int
int dp[5000+1][5000+1];
//dp[1][1]=0;

int dp1[5001][5001];
ll calculate(int i,int j,vector<pair<int,ll>> adj[])
{
    if(dp[i][j]!=-1)
    return dp[i][j];
    else if(j<0)
    return 1900000000;
    else
    {
       dp[i][j]=1900000000;
        for(int v=0;v<adj[i].size();v++)
        {
            ll y=calculate(adj[i][v].first,j-1,adj)+adj[i][v].second;
            if(dp[i][j]>y)
            {
                dp[i][j]=y;
                dp1[i][j]=adj[i][v].first;
            }
        }

    return dp[i][j];
    }

}
int main()
{
 int n,m,t;
 cin>>n>>m>>t;
 vector<pair<int,ll>> adj[n+1];int u,v,t1;
 for(int i=0;i<m;i++)
 {
     cin>>u>>v>>t1;
     adj[v].push_back(m1(u,t1));
 }
 for(int i=0;i<=5000;i++)
for(int j=1;j<=5000;j++)
dp[i][j]=-1;
dp[1][1]=0;
 for(int i=1;i<=n;i++)
 for(int j=1;j<=n;j++)
  dp[i][j]=calculate(i,j,adj);
  int cnt;
  for(int i=1;i<=n;i++)
  {
      if(dp[n][i]<=t)
      cnt=i;
  }
  cout<<cnt<<endl;
  stack<int>st;
int to=dp1[n][cnt];
st.push(n);
//cnt--;
  while(cnt>=1)
  {
      cnt--;
      st.push(to);
      to=dp1[to][cnt];

  }
  while(!st.empty())
  {
     if(st.top())
      cout<<st.top()<<" ";
      st.pop();
  }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#define ll long long int
#define m1 make_pair
#define ll long long int
int dp[5000+1][5000+1];
//dp[1][1]=0;

int dp1[5001][5001];
ll calculate(int i,int j,vector<pair<int,ll>> adj[])
{
    if(dp[i][j]!=-1)
    return dp[i][j];
    else if(j<0)
    return 1900000000;
    else
    {
       dp[i][j]=1900000000;
        for(int v=0;v<adj[i].size();v++)
        {
            ll y=calculate(adj[i][v].first,j-1,adj)+adj[i][v].second;
            if(dp[i][j]>y)
            {
                dp[i][j]=y;
                dp1[i][j]=adj[i][v].first;
            }
        }

    return dp[i][j];
    }

}
int main()
{
 int n,m,t;
 cin>>n>>m>>t;
 vector<pair<int,ll>> adj[n+1];int u,v,t1;
 for(int i=0;i<m;i++)
 {
     cin>>u>>v>>t1;
     adj[v].push_back(m1(u,t1));
 }
 for(int i=0;i<=5000;i++)
for(int j=0;j<=5000;j++)
dp[i][j]=-1;
dp[1][1]=0;
 for(int i=1;i<=n;i++)
 for(int j=1;j<=n;j++)
  {dp[i][j]=calculate(i,j,adj);
 // cout<<dp[i][j]<<" ";
  //if(j==n)
  //cout<<endl;
  dp[1][1]=0;
  }

  //cout<<dp[10][3]<<endl;
  int cnt,to;
 //cout<<dp1[10][3]<<" "<<dp1[6][2]<<endl;
  for(int i=n;i>=1;i--)
  {
      if(dp[n][i]!=1900000000&&dp[n][i]<=t)
      {
           stack<int>st;cout<<i<<endl;
           st.push(n);
           cnt=i;
           //cout<<to<<endl;
           while(cnt>=2)
           {

               st.push(dp1[st.top()][cnt]);
               cnt--;
                 //to=dp1[to][cnt];

           }
           //cout<<st.top()<<" "<<i<<endl;
         //  if(!st.top())
           //st.pop();
           if(st.top()==1)
           {
              // cout<<i<<endl;
               while(!st.empty())
               {
                   cout<<st.top()<<" ";
                   st.pop();
               }
               break;
           }
      }
  }

//cnt--;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#define ll long long int
#define m1 make_pair
#define ll long long int

void dfs(vector<pair<int,ll>> adj[],int u,ll dp[],ll t[],int n,ll t1,bool visited[])
{
    visited[u]=1;
   // int mx=0;
   if(u==n)
   return;
    for(int i=0;i<adj[u].size();i++)
    {
        if(!visited[adj[u][i].first])
        {
        //t2[adj[u][i].first]=t2[u]+adj[u][i].second;
        dfs(adj,adj[u][i].first,dp,t,n,t1,visited);
        if(t[adj[u][i].first]+adj[u][i].second<=t1)
        {
            t[u]=t[adj[u][i].first]+adj[u][i].second;
            dp[u]=max(dp[u],1+dp[adj[u][i].first]);
        }
        else
        {
            dp[adj[u][i].first]=0;
        }
        }
        else
        {
             if(t[adj[u][i].first]+adj[u][i].second<=t1)
        {
            t[u]=t[adj[u][i].first]+adj[u][i].second;
            dp[u]=max(dp[u],1+dp[adj[u][i].first]);
        }
        else
        {
            dp[adj[u][i].first]=0;
        }
        }
    }
  //  dp[u]=mx+1;
}
void dfs1(vector<pair<int,ll>> adj[],int u,ll dp[],int n)
{
    cout<<u<<" ";
    if(u==n)
    return;
    for(int i=0;i<adj[u].size();i++)
    {
        if(dp[u]==(1+dp[adj[u][i].first]))
        {
            dfs1(adj,adj[u][i].first,dp,n);
            break;
        }

    }
}
struct s
{
    ll l,r;

};
bool compare1(s s1,s s2)
{
    if(s1.l>s2.l)
    return 1;
    else if(s1.l==s2.l)
    return (s1.r<=s2.r);
    else
    return 0;
}
int main()
{
 int n,m,t;
 cin>>n>>m>>t;
 vector<pair<int,ll>> adj[n+1];int u,v,t1;
 for(int i=0;i<m;i++)
 {
     cin>>u>>v>>t1;
     adj[u].push_back(m1(v,t1));
 }
 ll dp[n+1]={0},time[n+1]={0};bool visited[n+1]={0};
 dp[n]=1,time[n]=0;
 dfs(adj,1,dp,time,n,t,visited);
 cout<<dp[1]<<endl;
 dfs1(adj,1,dp,n);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#define ll long long int
#define m1 make_pair
#define ll long long int
ll dp[5000+1][5000+1];
//dp[1][1]=0;

ll dp1[5001][5001];
ll calculate(int i,int j,vector<pair<int,ll>> adj[])
{
    if(dp[i][j]!=-1)
    return dp[i][j];
    else if(j<0)
    return 100000000000000000;
    else
    {
       dp[i][j]=100000000000000000;
        for(int v=0;v<adj[i].size();v++)
        {
            ll y=calculate(adj[i][v].first,j-1,adj)+adj[i][v].second;
            if(dp[i][j]>y)
            {
                dp[i][j]=y;
                dp1[i][j]=adj[i][v].first;
            }
        }

    return dp[i][j];
    }

}
int main()
{
 int n,m,t;
 cin>>n>>m>>t;
 vector<pair<int,ll>> adj[n+1];int u,v,t1;
 for(int i=0;i<m;i++)
 {
     cin>>u>>v>>t1;
     adj[v].push_back(m1(u,t1));
 }
 for(int i=0;i<=5000;i++)
for(int j=1;j<=5000;j++)
dp[i][j]=-1;
dp[1][1]=0;
 for(int i=1;i<=n;i++)
 for(int j=1;j<=n;j++)
  dp[i][j]=calculate(i,j,adj);
  int cnt;
  for(int i=1;i<=n;i++)
  {
      if(dp[n][i]<=t)
      cnt=i;
  }
  cout<<cnt<<endl;
  stack<int>st;
int to=dp1[n][cnt];
st.push(n);
cnt--;
  while(cnt>=1)
  {
      cnt--;
      st.push(to);
      to=dp1[to][cnt];

  }
  while(!st.empty())
  {
      cout<<st.top()<<" ";
      st.pop();
  }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#define ll long long int
#define m1 make_pair
#define ll long long int
ll dp[1000+1][1000+1];
//dp[1][1]=0;

ll dp1[1001][1001];
ll calculate(int i,int j,vector<pair<int,ll>> adj[])
{
    if(dp[i][j]!=-1)
    return dp[i][j];
    else if(j<0)
    return 100000000000000000;
    else
    {
       dp[i][j]=100000000000000000;
        for(int v=0;v<adj[i].size();v++)
        {
            ll y=calculate(adj[i][v].first,j-1,adj)+adj[i][v].second;
            if(dp[i][j]>y)
            {
                dp[i][j]=y;
                dp1[i][j]=adj[i][v].first;
            }
        }

    return dp[i][j];
    }

}
int main()
{
 int n,m,t;
 cin>>n>>m>>t;
 vector<pair<int,ll>> adj[n+1];int u,v,t1;
 for(int i=0;i<m;i++)
 {
     cin>>u>>v>>t1;
     adj[v].push_back(m1(u,t1));
 }
 for(int i=0;i<=1000;i++)
for(int j=1;j<=1000;j++)
dp[i][j]=-1;
dp[1][1]=0;
 for(int i=1;i<=n;i++)
 for(int j=1;j<=n;j++)
  dp[i][j]=calculate(i,j,adj);
  int cnt;
  for(int i=1;i<=n;i++)
  {
      if(dp[n][i]<=t)
      cnt=i;
  }
  cout<<cnt<<endl;
  stack<int>st;
int to=dp1[n][cnt];
st.push(n);
cnt--;
  while(cnt>=1)
  {
      cnt--;
      st.push(to);
      to=dp1[to][cnt];

  }
  while(!st.empty())
  {
      cout<<st.top()<<" ";
      st.pop();
  }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#define ll long long int
#define m1 make_pair
#define ll long long int

void dfs(vector<pair<int,ll>> adj[],int u,ll dp[],ll t[],int n,int t1,ll t2[])
{
    //visited[u]=1;
   // int mx=0;
   if(u==n||t2[u]>t1)
   return;
    for(int i=0;i<adj[u].size();i++)
    {
        t2[adj[u][i].first]=t2[u]+adj[u][i].second;
        dfs(adj,adj[u][i].first,dp,t,n,t1,t2);
        if(t[adj[u][i].first]+adj[u][i].second<=t1)
        {
            t[u]=t[adj[u][i].first]+adj[u][i].second;
            dp[u]=max(dp[u],1+dp[adj[u][i].first]);
        }
        else
        {
            dp[adj[u][i].first]=0;
        }
    }
  //  dp[u]=mx+1;
}
void dfs1(vector<pair<int,ll>> adj[],int u,ll dp[],int n)
{
    cout<<u<<" ";
    if(u==n)
    return;
    for(int i=0;i<adj[u].size();i++)
    {
        if(dp[u]==(1+dp[adj[u][i].first]))
        {
            dfs1(adj,adj[u][i].first,dp,n);
            break;
        }

    }
}
struct s
{
    ll l,r;

};
bool compare1(s s1,s s2)
{
    if(s1.l>s2.l)
    return 1;
    else if(s1.l==s2.l)
    return (s1.r<=s2.r);
    else
    return 0;
}
int main()
{
 int n,m,t;
 cin>>n>>m>>t;
 vector<pair<int,ll>> adj[n+1];int u,v,t1;
 for(int i=0;i<m;i++)
 {
     cin>>u>>v>>t1;
     adj[u].push_back(m1(v,t1));
 }
 ll dp[n+1]={0},time[n+1]={0},t2[n+1];
 t2[1]=0;
 dp[n]=1,time[n]=0;
 dfs(adj,1,dp,time,n,t,t2);
 cout<<dp[1]<<endl;
 dfs1(adj,1,dp,n);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#define ll long long int
#define m1 make_pair
#define ll long long int

void dfs(vector<pair<int,ll>> adj[],int u,ll dp[],ll t[],int n,ll t1,bool visited[])
{
    visited[u]=1;
   // int mx=0;
   if(u==n)
   return;
    for(int i=0;i<adj[u].size();i++)
    {
        if(!visited[adj[u][i].first])
        {
        //t2[adj[u][i].first]=t2[u]+adj[u][i].second;
        dfs(adj,adj[u][i].first,dp,t,n,t1,visited);
        if(t[adj[u][i].first]+adj[u][i].second<=t1)
        {
            t[u]=t[adj[u][i].first]+adj[u][i].second;
            dp[u]=max(dp[u],1+dp[adj[u][i].first]);
        }
        else
        {
            dp[adj[u][i].first]=0;
        }
        }
        else
        {
             if(t[adj[u][i].first]+adj[u][i].second<=t1)
        {
            t[u]=t[adj[u][i].first]+adj[u][i].second;
            dp[u]=max(dp[u],1+dp[adj[u][i].first]);
        }
        else
        {
            dp[adj[u][i].first]=0;
        }
        }
    }
  //  dp[u]=mx+1;
}
void dfs1(vector<pair<int,ll>> adj[],int u,ll dp[],int n,ll t[],ll t1)
{
    cout<<u<<" ";
    if(u==n)
    return;
    for(int i=0;i<adj[u].size();i++)
    {
        if(dp[u]==(1+dp[adj[u][i].first])&&(t[adj[u][i].first]+adj[u][i].second<=t1))
        {
            dfs1(adj,adj[u][i].first,dp,n,t,t1);
            break;
        }

    }
}
struct s
{
    ll l,r;

};
bool compare1(s s1,s s2)
{
    if(s1.l>s2.l)
    return 1;
    else if(s1.l==s2.l)
    return (s1.r<=s2.r);
    else
    return 0;
}
int main()
{
 int n,m,t;
 cin>>n>>m>>t;
 vector<pair<int,ll>> adj[n+1];int u,v,t1;
 for(int i=0;i<m;i++)
 {
     cin>>u>>v>>t1;
     adj[u].push_back(m1(v,t1));
 }
 ll dp[n+1]={0},time[n+1]={0};bool visited[n+1]={0};
 dp[n]=1,time[n]=0;
 dfs(adj,1,dp,time,n,t,visited);
 cout<<dp[1]<<endl;
 dfs1(adj,1,dp,n,time,t);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long Long;

short n, m, deg[5001], din[5001], mom[5001][5001];
unsigned int T, d[5001][5001];
vector<short> g[5001], c[5001], o, s;
set<short> can[5001];

void main_body() {
    cin >> n >> m >> T;
    for (int i = 0; i < m; ++i) {
        int u, v, w;

        cin >> u >> v >> w;
        g[u].emplace_back(v);
        c[u].emplace_back(w);
        ++din[v];
        ++deg[v];
    }

    for (int i = 1; i <= n; ++i)
        if (din[i] == 0) {
            s.emplace_back(i);
            can[i].insert(1);
        }

    while (!s.empty()) {
        int i = *(s.rbegin());
        s.pop_back();

        o.emplace_back(i);
        for (int j: g[i]) {
            --din[j];
            if (din[j] == 0) {
                s.emplace_back(j);
            }
        }
    }

    for (int i: o) {
        for (int e = 0; e < g[i].size(); ++e) {
            int j = g[i][e], t = c[i][e];
            for (int k: can[i]) {
                if (d[i][k] > T) continue;
                if (can[j].count(k + 1) == 0) {
                    d[j][k + 1] = d[i][k] + t;
                    mom[j][k + 1] = i;
                    can[j].insert(k + 1);
                }
                if (d[j][k + 1] > d[i][k] + t) {
                    d[j][k + 1] = d[i][k] + t;
                    mom[j][k + 1] = i;
                }
            }
        }
    }

    int ans = 0;
    for (int k: can[n]) {
        if (d[n][k] <= T) {
            ans = max(ans, k);
        }
    }

    cout << ans << "\n";
    vector<int> res;
    int i = n, j = ans;
    while (j > 0) {
        res.emplace_back(i);
        i = mom[i][j];--j;
    }
    reverse(begin(res), end(res));
    for(int e: res) {
        cout << e << " ";
    }
}

int main() {
    //freopen("main.in","r",stdin);
    ios::sync_with_stdio(0);
    main_body();
    fclose(stdin);
}


#include <bits/stdc++.h>

using namespace std;
typedef long long Long;

int n, m, T, deg[5005], din[5005], mom[5005][5005];
int d[5005][5005];
vector<int> g[5005], c[5005], o, s;
set<int> can[5005];

void main_body() {
    cin >> n >> m >> T;
    for (int i = 0; i < m; ++i) {
        int u, v, w;

        cin >> u >> v >> w;
        g[u].emplace_back(v);
        c[u].emplace_back(w);
        ++din[v];
        ++deg[v];
    }

    for (int i = 1; i <= n; ++i)
        if (din[i] == 0) {
            s.emplace_back(i);
            can[i].insert(1);
        }

    while (!s.empty()) {
        int i = *(s.rbegin());
        s.pop_back();

        o.emplace_back(i);
        for (int j: g[i]) {
            --din[j];
            if (din[j] == 0) {
                s.emplace_back(j);
            }
        }
    }

    for (int i: o) {
        for (int e = 0; e < g[i].size(); ++e) {
            int j = g[i][e], t = c[i][e];
            for (int k: can[i]) {
                if (d[i][k] > T) continue;
                if (can[j].count(k + 1) == 0) {
                    d[j][k + 1] = d[i][k] + t;
                    mom[j][k + 1] = i;
                    can[j].insert(k + 1);
                }
                if (d[j][k + 1] > d[i][k] + t) {
                    d[j][k + 1] = d[i][k] + t;
                    mom[j][k + 1] = i;
                }
            }
        }
    }

    int ans = 0;
    for (int k: can[n]) {
        if (d[n][k] <= T) {
            ans = max(ans, k);
        }
    }

    cout << ans << "\n";
    vector<int> res;
    int i = n, j = ans;
    while (j > 0) {
        res.emplace_back(i);
        i = mom[i][j];--j;
    }
    reverse(begin(res), end(res));
    for(int e: res) {
        cout << e << " ";
    }
}

int main() {
    //freopen("main.in","r",stdin);
    ios::sync_with_stdio(0);
    main_body();
    fclose(stdin);
}


#include <bits/stdc++.h>

using namespace std;
typedef long long Long;

short n, m, deg[5001], din[5001], mom[5001][5001];
unsigned int T, d[5001][5001];
vector<short> g[5001], c[5001], o, s;
set<short> can[5001];

void main_body() {
    cin >> n >> m >> T;
    for (int i = 0; i < m; ++i) {
        int u, v, w;

        cin >> u >> v >> w;
        g[u].emplace_back(v);
        c[u].emplace_back(w);
        ++din[v];
        ++deg[v];
    }

    for (int i = 1; i <= n; ++i)
        if (din[i] == 0) {
            s.emplace_back(i);
            can[i].insert(1);
        }

    while (!s.empty()) {
        int i = *(s.rbegin());
        s.pop_back();

        o.emplace_back(i);
        for (int j: g[i]) {
            --din[j];
            if (din[j] == 0) {
                s.emplace_back(j);
            }
        }
    }

    for (int i: o) {
        for (int e = 0; e < g[i].size(); ++e) {
            int j = g[i][e], t = c[i][e];
            for (int k: can[i]) {
                if (d[i][k] > 2e9) continue;
                if (can[j].count(k + 1) == 0) {
                    d[j][k + 1] = d[i][k] + t;
                    mom[j][k + 1] = i;
                    can[j].insert(k + 1);
                }
                if (d[j][k + 1] > d[i][k] + t) {
                    d[j][k + 1] = d[i][k] + t;
                    mom[j][k + 1] = i;
                }
            }
        }
    }

    int ans = 0;
    for (int k: can[n]) {
        if (d[n][k] <= T) {
            ans = max(ans, k);
        }
    }

    cout << ans << "\n";
    vector<int> res;
    int i = n, j = ans;
    while (j > 0) {
        res.emplace_back(i);
        i = mom[i][j];--j;
    }
    reverse(begin(res), end(res));
    for(int e: res) {
        cout << e << " ";
    }
}

int main() {
    //freopen("main.in","r",stdin);
    ios::sync_with_stdio(0);
    main_body();
    fclose(stdin);
}


#include <bits/stdc++.h>

using namespace std;
typedef long long Long;

int n, m, T, deg[5001], din[5001], mom[5001][5001];
Long d[5001][5001];
vector<int> g[5001], c[5001], o, s;
set<int> can[5001];

void main_body() {
    cin >> n >> m >> T;
    for (int i = 0; i < m; ++i) {
        int u, v, w;

        cin >> u >> v >> w;
        g[u].emplace_back(v);
        c[u].emplace_back(w);
        ++din[v];
        ++deg[v];
    }

    for (int i = 1; i <= n; ++i)
        if (din[i] == 0) {
            s.emplace_back(i);
            can[i].insert(1);
        }

    while (!s.empty()) {
        int i = *(s.rbegin());
        s.pop_back();

        o.emplace_back(i);
        for (int j: g[i]) {
            --din[j];
            if (din[j] == 0) {
                s.emplace_back(j);
            }
        }
    }

    for (int i: o) {
        for (int e = 0; e < g[i].size(); ++e) {
            int j = g[i][e], t = c[i][e];
            for (int k: can[i]) {
                if (can[j].count(k + 1) == 0) {
                    d[j][k + 1] = d[i][k] + t;
                    mom[j][k + 1] = i;
                    can[j].insert(k + 1);
                }
                if (d[j][k + 1] > d[i][k] + t) {
                    d[j][k + 1] = d[i][k] + t;
                    mom[j][k + 1] = i;
                }
            }
        }
    }

    int ans = 0;
    for (int k: can[n]) {
        if (d[n][k] <= T) {
            ans = max(ans, k);
        }
    }

    cout << ans << "\n";
    vector<int> res;
    int i = n, j = ans;
    while (j > 0) {
        res.emplace_back(i);
        i = mom[i][j];--j;
    }
    reverse(begin(res), end(res));
    for(int e: res) {
        cout << e << " ";
    }
}

int main() {
    //freopen("main.in","r",stdin);
    ios::sync_with_stdio(0);
    main_body();
    fclose(stdin);
}


#include <bits/stdc++.h>

using namespace std;
typedef long long Long;

short n, m, deg[5001], din[5001], mom[5001][5001];
Long T, d[5001][5001];
vector<short> g[5001], o, s;
vector<int> c[5001];

void main_body() {
    cin >> n >> m >> T;
    for (int i = 0; i < m; ++i) {
        int u, v, w;

        cin >> u >> v >> w;
        g[u].emplace_back(v);
        c[u].emplace_back(w);
        ++din[v];
        ++deg[v];
    }

    for (int i = 1; i <= n; ++i)
        if (din[i] == 0) {
            s.emplace_back(i);
        }

    while (!s.empty()) {
        int i = *(s.rbegin());
        s.pop_back();

        o.emplace_back(i);
        for (int j: g[i]) {
            --din[j];
            if (din[j] == 0) {
                s.emplace_back(j);
            }
        }
    }

    for (int i: o) {
        if (deg[i] == 0) {
            for (int e = 0; e < g[i].size(); ++e) {
                int j = g[i][e], t = c[i][e], k = 1;
                if (d[j][k + 1] == 0 || d[j][k + 1] > t) {
                    d[j][k + 1] = t;
                    mom[j][k + 1] = i;
                }
            }
        } else {
            for (int e = 0; e < g[i].size(); ++e) {
                int j = g[i][e], t = c[i][e];
                for (int k = 2; k <= n; ++k)
                    if (d[i][k] > 0 && (d[j][k + 1] == 0 || d[j][k + 1] > d[i][k] + t)) {
                        d[j][k + 1] = d[i][k] + t;
                        mom[j][k + 1] = i;
                    }
            }
        }
    }

    int ans = 0;
    for (int k = 2; k <= n; ++k) {
        if (d[n][k] > 0 && d[n][k] <= T) {
            ans = max(ans, k);
        }
    }

    s.clear();
    cout << ans << "\n";
    int i = n, j = ans;
    while (j > 0) {
        s.emplace_back(i);
        i = mom[i][j];--j;
    }
    reverse(begin(s), end(s));
    for(int e: s) {
        cout << e << " ";
    }
}

int main() {
    //freopen("main.in","r",stdin);
    ios::sync_with_stdio(0);
    main_body();
    fclose(stdin);
}


#include <bits/stdc++.h>

using namespace std;
typedef long long Long;

short n, m, deg[5001], din[5001], mom[5001][5001];
Long T, d[5001][5001];
vector<short> g[5001], c[5001], o, s;
set<short> can[5001];

void main_body() {
    cin >> n >> m >> T;
    for (int i = 0; i < m; ++i) {
        int u, v, w;

        cin >> u >> v >> w;
        g[u].emplace_back(v);
        c[u].emplace_back(w);
        ++din[v];
        ++deg[v];
    }

    for (int i = 1; i <= n; ++i)
        if (din[i] == 0) {
            s.emplace_back(i);
            can[i].insert(1);
        }

    while (!s.empty()) {
        int i = *(s.rbegin());
        s.pop_back();

        o.emplace_back(i);
        for (int j: g[i]) {
            --din[j];
            if (din[j] == 0) {
                s.emplace_back(j);
            }
        }
    }

    for (int i: o) {
        for (int e = 0; e < g[i].size(); ++e) {
            int j = g[i][e], t = c[i][e];
            for (int k: can[i]) {
                if (can[j].count(k + 1) == 0) {
                    d[j][k + 1] = d[i][k] + t;
                    mom[j][k + 1] = i;
                    can[j].insert(k + 1);
                }
                if (d[j][k + 1] > d[i][k] + t) {
                    d[j][k + 1] = d[i][k] + t;
                    mom[j][k + 1] = i;
                }
            }
        }
    }

    int ans = 0;
    for (int k: can[n]) {
        if (d[n][k] <= T) {
            ans = max(ans, k);
        }
    }

    cout << ans << "\n";
    vector<int> res;
    int i = n, j = ans;
    while (j > 0) {
        res.emplace_back(i);
        i = mom[i][j];--j;
    }
    reverse(begin(res), end(res));
    for(int e: res) {
        cout << e << " ";
    }
}

int main() {
    //freopen("main.in","r",stdin);
    ios::sync_with_stdio(0);
    main_body();
    fclose(stdin);
}


#include <bits/stdc++.h>

using namespace std;
typedef long long Long;

int n, m, T, deg[5005], din[5005], mom[5005][5005];
Long d[5005][5005];
vector<int> g[5005], c[5005], o, s;
set<int> can[5005];

void main_body() {
    cin >> n >> m >> T;
    for (int i = 0; i < m; ++i) {
        int u, v, w;

        cin >> u >> v >> w;
        g[u].emplace_back(v);
        c[u].emplace_back(w);
        ++din[v];
        ++deg[v];
    }

    for (int i = 1; i <= n; ++i)
        if (din[i] == 0) {
            s.emplace_back(i);
            can[i].insert(1);
        }

    while (!s.empty()) {
        int i = *(s.rbegin());
        s.pop_back();

        o.emplace_back(i);
        for (int j: g[i]) {
            --din[j];
            if (din[j] == 0) {
                s.emplace_back(j);
            }
        }
    }

    for (int i: o) {
        for (int e = 0; e < g[i].size(); ++e) {
            int j = g[i][e], t = c[i][e];
            for (int k: can[i]) {
                if (can[j].count(k + 1) == 0) {
                    d[j][k + 1] = d[i][k] + t;
                    mom[j][k + 1] = i;
                    can[j].insert(k + 1);
                }
                if (d[j][k + 1] > d[i][k] + t) {
                    d[j][k + 1] = d[i][k] + t;
                    mom[j][k + 1] = i;
                }
            }
        }
    }

    int ans = 0;
    for (int k: can[n]) {
        if (d[n][k] <= T) {
            ans = max(ans, k);
        }
    }

    cout << ans << "\n";
    vector<int> res;
    int i = n, j = ans;
    while (j > 0) {
        res.emplace_back(i);
        i = mom[i][j];--j;
    }
    reverse(begin(res), end(res));
    for(int e: res) {
        cout << e << " ";
    }
}

int main() {
    //freopen("main.in","r",stdin);
    ios::sync_with_stdio(0);
    main_body();
    fclose(stdin);
}


#include <bits/stdc++.h>

using namespace std;
typedef long long Long;

short n, m, deg[5001], din[5001], mom[5001][5001];
Long T, d[5001][5001];
vector<short> g[5001], o, s;
vector<int> c[5001];

void main_body() {
    cin >> n >> m >> T;
    for (int i = 0; i < m; ++i) {
        int u, v, w;

        cin >> u >> v >> w;
        g[u].emplace_back(v);
        c[u].emplace_back(w);
        ++din[v];
        ++deg[v];
    }

    for (int i = 1; i <= n; ++i)
        if (din[i] == 0) {
            s.emplace_back(i);
        }

    while (!s.empty()) {
        int i = *(s.rbegin());
        s.pop_back();

        o.emplace_back(i);
        for (int j: g[i]) {
            --din[j];
            if (din[j] == 0) {
                s.emplace_back(j);
            }
        }
    }

    for (int i: o) {
        if (deg[i] == 0) {
            for (int e = 0; e < g[i].size(); ++e) {
                int j = g[i][e], t = c[i][e], k = 1;
                if (d[j][k + 1] == 0 || d[j][k + 1] > t) {
                    d[j][k + 1] = t;
                    mom[j][k + 1] = i;
                }
            }
        } else {
            for (int e = 0; e < g[i].size(); ++e) {
                int j = g[i][e], t = c[i][e];
                for (int k = 2; k <= n; ++k)
                    if (d[i][k] > 0 && (d[j][k + 1] == 0 || d[j][k + 1] > d[i][k] + t)) {
                        d[j][k + 1] = d[i][k] + t;
                        mom[j][k + 1] = i;
                    }
            }
        }
    }

    int ans = 0;
    for (int k = 2; k <= n; ++k) {
        if (d[n][k] > 0 && d[n][k] <= T) {
            ans = max(ans, k);
        }
    }

    s.clear();

    int i = n, j = ans;
    while (j > 0) {
        s.emplace_back(i);
        if (i == 1) break;
        i = mom[i][j];--j;
    }
    reverse(begin(s), end(s));
    cout << s.size() << "\n";
    for(int e: s) {
        cout << e << " ";
    }
}

int main() {
    //freopen("main.in","r",stdin);
    ios::sync_with_stdio(0);
    main_body();
    fclose(stdin);
}


#include <bits/stdc++.h>

using namespace std;
typedef long long Long;

int n, m, T, deg[5001], din[5001], mom[5001][5001];
Long d[5001][5001];
vector<int> g[5001], c[5001], o, s;

void main_body() {
    cin >> n >> m >> T;
    for (int i = 0; i < m; ++i) {
        int u, v, w;

        cin >> u >> v >> w;
        g[u].emplace_back(v);
        c[u].emplace_back(w);
        ++din[v];
        ++deg[v];
    }

    for (int i = 1; i <= n; ++i)
        if (din[i] == 0) {
            s.emplace_back(i);
            can[i].insert(1);
        }

    while (!s.empty()) {
        int i = *(s.rbegin());
        s.pop_back();

        o.emplace_back(i);
        for (int j: g[i]) {
            --din[j];
            if (din[j] == 0) {
                s.emplace_back(j);
            }
        }
    }

    for (int i: o) {
        if (deg[i] == 0) {
            for (int e = 0; e < g[i].size(); ++e) {
                int j = g[i][e], t = c[i][e], k = 1;
                if (d[j][k + 1] == 0 || d[j][k + 1] > t) {
                    d[j][k + 1] = t;
                    mom[j][k + 1] = i;
                }
            }
        } else {
            for (int e = 0; e < g[i].size(); ++e) {
                int j = g[i][e], t = c[i][e];
                for (int k = 2; k <= n; ++k)
                    if (d[i][k] > 0 && (d[j][k + 1] == 0 || d[j][k + 1] > d[i][k] + t)) {
                        d[j][k + 1] = d[i][k] + t;
                        mom[j][k + 1] = i;
                    }
            }
        }
    }

    int ans = 0;
    for (int k = 2; k <= n; ++k) {
        if (d[n][k] > 0 && d[n][k] <= T) {
            ans = max(ans, k);
        }
    }

    cout << ans << "\n";
    vector<int> res;
    int i = n, j = ans;
    while (j > 0) {
        res.emplace_back(i);
        i = mom[i][j];--j;
    }
    reverse(begin(res), end(res));
    for(int e: res) {
        cout << e << " ";
    }
}

int main() {
   // freopen("main.in","r",stdin);
    ios::sync_with_stdio(0);
    main_body();
    fclose(stdin);
}


#include <bits/stdc++.h>

using namespace std;
typedef long long Long;

short n, m, deg[5001], din[5001], mom[5001][5001];
Long T, d[5001][5001];
vector<short> g[5001], o, s;
vector<int> c[5001];

void main_body() {
    cin >> n >> m >> T;
    for (int i = 0; i < m; ++i) {
        int u, v, w;

        cin >> u >> v >> w;
        g[u].emplace_back(v);
        c[u].emplace_back(w);
        ++din[v];
        ++deg[v];
    }

    for (int i = 1; i <= n; ++i)
        if (din[i] == 0) {
            s.emplace_back(i);
        }

    while (!s.empty()) {
        int i = *(s.rbegin());
        s.pop_back();

        o.emplace_back(i);
        for (int j: g[i]) {
            --din[j];
            if (din[j] == 0) {
                s.emplace_back(j);
            }
        }
    }

    for (int i: o) {
        if (deg[i] == 0) {
            if (i != 1) continue;
            for (int e = 0; e < g[i].size(); ++e) {
                int j = g[i][e], t = c[i][e], k = 1;
                if (d[j][k + 1] == 0 || d[j][k + 1] > t) {
                    d[j][k + 1] = t;
                    mom[j][k + 1] = i;
                }
            }
        } else {
            for (int e = 0; e < g[i].size(); ++e) {
                int j = g[i][e], t = c[i][e];
                for (int k = 2; k <= n; ++k)
                    if (d[i][k] > 0 && (d[j][k + 1] == 0 || d[j][k + 1] > d[i][k] + t)) {
                        d[j][k + 1] = d[i][k] + t;
                        mom[j][k + 1] = i;
                    }
            }
        }
    }

    int ans = 0;
    for (int k = 2; k <= n; ++k) {
        if (d[n][k] > 0 && d[n][k] <= T) {
            ans = max(ans, k);
        }
    }

    s.clear();
    cout << ans << "\n";
    int i = n, j = ans;
    while (j > 0) {
        s.emplace_back(i);
        i = mom[i][j];--j;
    }
    reverse(begin(s), end(s));
    for(int e: s) {
        cout << e << " ";
    }
}

int main() {
    //freopen("main.in","r",stdin);
    ios::sync_with_stdio(0);
    main_body();
    fclose(stdin);
}


#include <bits/stdc++.h>

using namespace std;
typedef long long Long;

int n, m, T, deg[5001], din[5001], mom[5001][5001];
Long d[5001][5001];
vector<int> g[5001], c[5001], o, s;

void main_body() {
    cin >> n >> m >> T;
    for (int i = 0; i < m; ++i) {
        int u, v, w;

        cin >> u >> v >> w;
        g[u].emplace_back(v);
        c[u].emplace_back(w);
        ++din[v];
        ++deg[v];
    }

    for (int i = 1; i <= n; ++i)
        if (din[i] == 0) {
            s.emplace_back(i);
        }

    while (!s.empty()) {
        int i = *(s.rbegin());
        s.pop_back();

        o.emplace_back(i);
        for (int j: g[i]) {
            --din[j];
            if (din[j] == 0) {
                s.emplace_back(j);
            }
        }
    }

    for (int i: o) {
        if (deg[i] == 0) {
            for (int e = 0; e < g[i].size(); ++e) {
                int j = g[i][e], t = c[i][e], k = 1;
                if (d[j][k + 1] == 0 || d[j][k + 1] > t) {
                    d[j][k + 1] = t;
                    mom[j][k + 1] = i;
                }
            }
        } else {
            for (int e = 0; e < g[i].size(); ++e) {
                int j = g[i][e], t = c[i][e];
                for (int k = 2; k <= n; ++k)
                    if (d[i][k] > 0 && (d[j][k + 1] == 0 || d[j][k + 1] > d[i][k] + t)) {
                        d[j][k + 1] = d[i][k] + t;
                        mom[j][k + 1] = i;
                    }
            }
        }
    }

    int ans = 0;
    for (int k = 2; k <= n; ++k) {
        if (d[n][k] > 0 && d[n][k] <= T) {
            ans = max(ans, k);
        }
    }

    cout << ans << "\n";
    vector<int> res;
    int i = n, j = ans;
    while (j > 0) {
        res.emplace_back(i);
        i = mom[i][j];--j;
    }
    reverse(begin(res), end(res));
    for(int e: res) {
        cout << e << " ";
    }
}

int main() {
    //freopen("main.in","r",stdin);
    ios::sync_with_stdio(0);
    main_body();
    fclose(stdin);
}


#include <bits/stdc++.h>

using namespace std;
typedef long long Long;

int n, m, T, deg[short], din[short], mom[short][short];
Long d[5001][5001];
vector<short> g[5001], c[5001], o, s;
set<int> can[short];

void main_body() {
    cin >> n >> m >> T;
    for (int i = 0; i < m; ++i) {
        int u, v, w;

        cin >> u >> v >> w;
        g[u].emplace_back(v);
        c[u].emplace_back(w);
        ++din[v];
        ++deg[v];
    }

    for (int i = 1; i <= n; ++i)
        if (din[i] == 0) {
            s.emplace_back(i);
            can[i].insert(1);
        }

    while (!s.empty()) {
        int i = *(s.rbegin());
        s.pop_back();

        o.emplace_back(i);
        for (int j: g[i]) {
            --din[j];
            if (din[j] == 0) {
                s.emplace_back(j);
            }
        }
    }

    for (int i: o) {
        for (int e = 0; e < g[i].size(); ++e) {
            int j = g[i][e], t = c[i][e];
            for (int k: can[i]) {
                if (can[j].count(k + 1) == 0) {
                    d[j][k + 1] = d[i][k] + t;
                    mom[j][k + 1] = i;
                    can[j].insert(k + 1);
                }
                if (d[j][k + 1] > d[i][k] + t) {
                    d[j][k + 1] = d[i][k] + t;
                    mom[j][k + 1] = i;
                }
            }
        }
    }

    int ans = 0;
    for (int k: can[n]) {
        if (d[n][k] <= T) {
            ans = max(ans, k);
        }
    }

    cout << ans << "\n";
    vector<int> res;
    int i = n, j = ans;
    while (j > 0) {
        res.emplace_back(i);
        i = mom[i][j];--j;
    }
    reverse(begin(res), end(res));
    for(int e: res) {
        cout << e << " ";
    }
}

int main() {
    //freopen("main.in","r",stdin);
    ios::sync_with_stdio(0);
    main_body();
    fclose(stdin);
}


#include <bits/stdc++.h>
#define int long
#define endl "\n"
#define pb push_back
#define INF 1234567890
#define MOD 1000000007
#define PI atan(1)*4
#define mp make_pair
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i <=b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define print(x) cout << x << "\n";
#define debug(x) cout << x << "\n";
#define debug2(x,y) cout << x << " " << y << "\n";
#define debug3(x,y,z) cout << x << " " << y << " " << z << "\n";
#define debug4(x,y,z,zz) cout << x << " " << y << " " << z <<" "<<zz << "\n";
#define debug5(x,y,z,zz,yy) cout << x << " " << y << " " << z <<" "<<zz << " "<< yy << "\n";
const int LIM = 5000+5;

/* AUTHOR : Jagreet 'v01d' Das Gupta */

using namespace std;

void solve();
signed main()
{
	#ifndef ONLINE_JUDGE
	freopen("../input.txt","r",stdin);
	freopen("../output.txt","w",stdout);
	#else
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#endif
	int t = 1;
	//cin >> t;
	WL(t) solve();
}

int n,m,T;
int dp[LIM][LIM];
int par[LIM][LIM];
vector<pii> adj[LIM];

int dfs(int nd,int ct)
{
	if(ct<0)
	{
		return INF;
	}
	if(dp[nd][ct]!=-1)
	{
		//debug("Happy New Year");
		return dp[nd][ct];
	}
	if(nd==0)
	{
		if(ct>0)
			return INF;
		dp[nd][ct] = 0;
		return 0;
	}
	int dis = INF;
	int nnn = -1;
	for(pii edge : adj[nd])
	{
		int curr = dfs(edge.F,ct-1);
		if(curr==INT_MAX)
			continue;

		curr+=edge.S;
		if(curr<dis)
		{
			dis = curr;
			nnn = edge.F;
		}
	}
	//visited[nd] = false;
	par[nd][ct] = nnn;
	dp[nd][ct] = dis;
	return dis;
}

void solve()
{
	cin >> n >> m >> T;
	memset(dp,-1,sizeof(int)*LIM*LIM);
	memset(par,-1,sizeof(int)*LIM*LIM);
	REP(i,n) adj[i] = vector<pii>();
	REP(i,m)
	{
		int u,v,w;
		cin >> u >> v >> w;
		u--;v--;
		adj[v].pb(mp(u,w));
	}
	REPD(i,n)
	{
		//print(dp[n-1][i]);
		int holy = dfs(n-1,i);
		//debug2(holy,i);
		if(holy<=T)
		{
			vi v;
			int nd,ct;
			nd = n-1,ct = i;
			while(nd!=0)
			{
				v.pb(nd+1);
				nd = par[nd][ct--];
			}
			v.pb(1);
			reverse(all(v));
			print(v.size());
			for(int x : v)
				cout << x << " ";
			cout << "\n";
			return;
		}
	}
	throw invalid_argument("HOLY MOLLY");
}


#include <bits/stdc++.h>
#define int long long
#define endl "\n"
#define pb push_back
#define INF 1234567890
#define MOD 1000000007
#define PI atan(1)*4
#define mp make_pair
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i <=b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define print(x) cout << x << "\n";
#define debug(x) cout << x << "\n";
#define debug2(x,y) cout << x << " " << y << "\n";
#define debug3(x,y,z) cout << x << " " << y << " " << z << "\n";
#define debug4(x,y,z,zz) cout << x << " " << y << " " << z <<" "<<zz << "\n";
#define debug5(x,y,z,zz,yy) cout << x << " " << y << " " << z <<" "<<zz << " "<< yy << "\n";

/* AUTHOR : Jagreet 'v01d' Das Gupta */

using namespace std;

void solve();
signed main()
{
	#ifndef ONLINE_JUDGE
	freopen("../input.txt","r",stdin);
	freopen("../output.txt","w",stdout);
	#else
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#endif
	int t = 1;
	//cin >> t;
	WL(t) solve();
}

int n,m,T;
vector<pii> adj[5005];
map<pii,vi> dp;

vi nll = {-1};
vector<bool> visited;

vi dfs(int nd,int t)
{
	if(t>T||visited[nd])
		return nll;
	pii pr = mp(nd,t);
	if(dp.find(pr)!=dp.end())
	{
		//debug("Happy New Year");
		visited[nd] = false;
		return dp[pr];
	}
	visited[nd] = true;
	if(nd==(n-1))
	{
		visited[nd] = false;
		return {n-1};
	}
	vi zns;
	for(pii edge : adj[nd])
	{
		vi curr = dfs(edge.F,edge.S+t);
		if(curr==nll)
			continue;
		if(curr.size()>zns.size()&&curr[0]==n-1)
			zns = curr;
	}
	visited[nd] = false;
	zns.pb(nd);
	dp.insert(mp(pr,zns));
	return zns;
}

void solve()
{
	cin >> n >> m >> T;
	REP(i,n) adj[i] = vector<pii>();
	REP(i,m)
	{
		int u,v,w;
		cin >> u >> v >> w;
		u--;v--;
		adj[u].pb(mp(v,w));
		//adj[v].pb(mp(u,w));
	}
	visited.clear();
	REP(i,n) visited.pb(false);
	vi ans = dfs(0,0);
	print(ans.size());
	for(auto it = ans.rbegin(); it<ans.rend();it++)
		cout << (*it+1) << " ";
	cout <<"\n";
}


#include <bits/stdc++.h>
#define int long long
#define endl "\n"
#define pb push_back
#define INF 1234567890
#define MOD 1000000007
#define PI atan(1)*4
#define mp make_pair
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i <=b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define print(x) cout << x << "\n";
#define debug(x) cout << x << "\n";
#define debug2(x,y) cout << x << " " << y << "\n";
#define debug3(x,y,z) cout << x << " " << y << " " << z << "\n";
#define debug4(x,y,z,zz) cout << x << " " << y << " " << z <<" "<<zz << "\n";
#define debug5(x,y,z,zz,yy) cout << x << " " << y << " " << z <<" "<<zz << " "<< yy << "\n";
const int LIM = 5000+5;

/* AUTHOR : Jagreet 'v01d' Das Gupta */

using namespace std;

void solve();
signed main()
{
	#ifndef ONLINE_JUDGE
	freopen("../input.txt","r",stdin);
	freopen("../output.txt","w",stdout);
	#else
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#endif
	int t = 1;
	//cin >> t;
	WL(t) solve();
}

int n,m,T;
int dp[LIM][LIM];
map<pii,int> par;
map<pii,int> cost;
vector<pii> adj[LIM];

int dfs(int nd,int ct)
{
	if(ct<0)
	{
		return INF;
	}
	if(dp[nd][ct]!=-1)
	{
		//debug("Happy New Year");
		return dp[nd][ct];
	}
	if(nd==0)
	{
		if(ct>0)
			return INF;
		dp[nd][ct] = 0;
		return 0;
	}
	int dis = INT_MAX;
	for(pii edge : adj[nd])
	{
		int curr = dfs(edge.F,ct-1)+edge.S;
		if(curr<dis)
		{
			dis = curr;
			par.insert(mp(mp(edge.F,ct-1),nd));
		}
	}
	//visited[nd] = false;
	dp[nd][ct] = dis;
	return dis;
}

void solve()
{
	cin >> n >> m >> T;
	memset(dp,-1,sizeof(int)*LIM*LIM);
	cost.clear();
	par.clear();
	REP(i,n) adj[i] = vector<pii>();
	REP(i,m)
	{
		int u,v,w;
		cin >> u >> v >> w;
		u--;v--;
		cost.insert(mp(mp(u,v),w));
		adj[v].pb(mp(u,w));
	}
	REPD(i,n)
	{
		//print(dp[n-1][i]);
		int holy = 0;
		if(holy=dfs(n-1,i)<=T)
		{
			//print(holy);
			vi v;
			int nd,ct;
			nd = 0,ct = 0;
			while(nd!=(n-1))
			{
				v.pb(nd+1);
				nd = par[mp(nd,ct++)];
			}
			v.pb(n);
			print(v.size());
			for(int x : v)
				cout << x << " ";
			cout << "\n";
			return;
		}
		else
		{
			//memset(dp,-1,sizeof(int)*LIM*LIM);
			par.clear();
		}
	}
	throw invalid_argument("HOLY MOLLY");
}


#include <bits/stdc++.h>
#define int long long
#define endl "\n"
#define pb push_back
#define INF 1234567890
#define MOD 1000000007
#define PI atan(1)*4
#define mp make_pair
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i <=b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define print(x) cout << x << "\n";
#define debug(x) cout << x << "\n";
#define debug2(x,y) cout << x << " " << y << "\n";
#define debug3(x,y,z) cout << x << " " << y << " " << z << "\n";
#define debug4(x,y,z,zz) cout << x << " " << y << " " << z <<" "<<zz << "\n";
#define debug5(x,y,z,zz,yy) cout << x << " " << y << " " << z <<" "<<zz << " "<< yy << "\n";
const int LIM = 5000+5;

/* AUTHOR : Jagreet 'v01d' Das Gupta */

using namespace std;

void solve();
signed main()
{
	#ifndef ONLINE_JUDGE
	freopen("../input.txt","r",stdin);
	freopen("../output.txt","w",stdout);
	#else
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#endif
	int t = 1;
	//cin >> t;
	WL(t) solve();
}

int n,m,T;
int dp[LIM][LIM];
map<pii,int> par;
map<pii,int> cost;
vector<pii> adj[LIM];

int dfs(int nd,int ct)
{
	if(ct<0)
	{
		return INF;
	}
	if(dp[nd][ct]!=-1)
	{
		//debug("Happy New Year");
		return dp[nd][ct];
	}
	if(nd==0)
	{
		if(ct>0)
			return INF;
		dp[nd][ct] = 0;
		return 0;
	}
	int dis = INT_MAX;
	for(pii edge : adj[nd])
	{
		int curr = dfs(edge.F,ct-1);
		if(curr==INT_MAX)
			continue;
		curr+=edge.S;
		if(curr<dis)
		{
			dis = curr;
			par.insert(mp(mp(edge.F,ct-1),nd));
		}
	}
	//visited[nd] = false;
	dp[nd][ct] = dis;
	return dis;
}

void solve()
{
	cin >> n >> m >> T;
	memset(dp,-1,sizeof(int)*LIM*LIM);
	cost.clear();
	par.clear();
	REP(i,n) adj[i] = vector<pii>();
	REP(i,m)
	{
		int u,v,w;
		cin >> u >> v >> w;
		u--;v--;
		cost.insert(mp(mp(u,v),w));
		adj[v].pb(mp(u,w));
	}
	REPD(i,n)
	{
		//print(dp[n-1][i]);
		int holy = 0;
		if(holy=dfs(n-1,i)<=T)
		{
			//print(holy);
			vi v;
			int nd,ct;
			nd = 0,ct = 0;
			while(nd!=(n-1))
			{
				v.pb(nd+1);
				nd = par[mp(nd,ct++)];
			}
			v.pb(n);
			print(v.size());
			for(int x : v)
				cout << x << " ";
			cout << "\n";
			return;
		}
		else
		{
			memset(dp,-1,sizeof(int)*LIM*LIM);
			par.clear();
		}
	}
	throw invalid_argument("HOLY MOLLY");
}


#include <bits/stdc++.h>
#define int long long
#define endl "\n"
#define pb push_back
#define INF 1234567890
#define MOD 1000000007
#define PI atan(1)*4
#define mp make_pair
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i <=b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define print(x) cout << x << "\n";
#define debug(x) cout << x << "\n";
#define debug2(x,y) cout << x << " " << y << "\n";
#define debug3(x,y,z) cout << x << " " << y << " " << z << "\n";
#define debug4(x,y,z,zz) cout << x << " " << y << " " << z <<" "<<zz << "\n";
#define debug5(x,y,z,zz,yy) cout << x << " " << y << " " << z <<" "<<zz << " "<< yy << "\n";

/* AUTHOR : Jagreet 'v01d' Das Gupta */

using namespace std;

void solve();
signed main()
{
	#ifndef ONLINE_JUDGE
	freopen("../input.txt","r",stdin);
	freopen("../output.txt","w",stdout);
	#else
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#endif
	int t = 1;
	//cin >> t;
	WL(t) solve();
}

int n,m,T;
vector<pii> adj[5005];

vi nll = {-1};

vi dfs(int nd,int t,set<int> stck)
{
	if(t>T||binary_search(all(stck),nd))
		return nll;
	stck.insert(nd);
	if(nd==(n-1))
	{
		return {n-1};
	}
	vi zns;
	for(pii edge : adj[nd])
	{
		vi curr = dfs(edge.F,edge.S+t,stck);
		if(curr==nll)
			continue;
		if(curr.size()>zns.size()&&curr[0]==n-1)
			zns = curr;
	}
	zns.pb(nd);
	return zns;
}

void solve()
{
	cin >> n >> m >> T;
	REP(i,n) adj[i] = vector<pii>();
	REP(i,m)
	{
		int u,v,w;
		cin >> u >> v >> w;
		u--;v--;
		adj[u].pb(mp(v,w));
		adj[v].pb(mp(u,w));
	}
	vi ans = dfs(0,0,set<int>());
	print(ans.size());
	for(auto it = ans.rbegin(); it<ans.rend();it++)
		cout << (*it+1) << " ";
	cout <<"\n";
}


#include <bits/stdc++.h>
#define int long long
#define endl "\n"
#define pb push_back
#define INF 1234567890
#define MOD 1000000007
#define PI atan(1)*4
#define mp make_pair
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i <=b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define print(x) cout << x << "\n";
#define debug(x) cout << x << "\n";
#define debug2(x,y) cout << x << " " << y << "\n";
#define debug3(x,y,z) cout << x << " " << y << " " << z << "\n";
#define debug4(x,y,z,zz) cout << x << " " << y << " " << z <<" "<<zz << "\n";
#define debug5(x,y,z,zz,yy) cout << x << " " << y << " " << z <<" "<<zz << " "<< yy << "\n";
const int LIM = 5000+5;

/* AUTHOR : Jagreet 'v01d' Das Gupta */

using namespace std;

void solve();
signed main()
{
	#ifndef ONLINE_JUDGE
	freopen("../input.txt","r",stdin);
	freopen("../output.txt","w",stdout);
	#else
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#endif
	int t = 1;
	//cin >> t;
	WL(t) solve();
}

int n,m,T;
int dp[LIM][LIM];
map<pii,int> par;
map<pii,int> cost;
vector<bool> visited;
vector<pii> adj[LIM];

int dfs(int nd,int ct,int pr)
{
	if(visited[nd])
		return -1;
	if(dp[nd][ct]!=-1)
	{
		//debug("Happy New Year");
		return dp[nd][ct];
	}
	par.insert(mp(mp(nd,ct),pr));
	if(nd==0)
	{
		dp[nd][ct] = 0;
		return 0;
	}
	visited[nd] = true;
	int dis = INT_MAX;
	for(pii edge : adj[nd])
	{
		int curr = dfs(edge.F,ct+1,nd)+edge.S;
		if(curr<dis)
		{
			dis = curr;
		}
	}
	visited[nd] = false;
	dp[nd][ct] = dis;
	return dis;
}

void solve()
{
	cin >> n >> m >> T;
	memset(dp,-1,sizeof(int)*LIM*LIM);
	cost.clear();
	par.clear();
	REP(i,n) adj[i] = vector<pii>();
	REP(i,m)
	{
		int u,v,w;
		cin >> u >> v >> w;
		u--;v--;
		cost.insert(mp(mp(u,v),w));
		adj[v].pb(mp(u,w));
	}
	//REP(i,n) REP(j,n) print(cost[i][j]);
	visited.clear();
	REP(i,n) visited.pb(false);
	dfs(n-1,0,-1);

	/*
	//Iterative DFS
	struct node{int nd;int ct;int pr;};
	stack<node> stck;
	stck.push({n-1,0,-1});
	while(!stck.empty())
	{
		node x = stck.top();
		if(dp[x.nd][x.ct]!=-1)
		{
			//debug("Happy New Year");
			stck.pop();
			continue;
		}
		//par[x.nd][x.ct] = x.pr;
		par.insert(mp(mp(x.nd,x.ct),x.pr));
		if(x.nd==0)
		{
			dp[x.nd][x.ct] = 0;
			stck.pop();
			continue;
		}
		visited[x.nd] = true;
		int dis = INT_MAX;
		bool ok = true;
		if(x.nd==n-1)
		{
			int xx = 0;
		}
		for(pii edge : adj[x.nd])
		{
			if(visited[edge.F])
				continue;
			if(dp[edge.F][x.ct+1]==-1)
			{
				ok = false;
				stck.push({edge.F,x.ct+1,x.nd});
				break;
			}
			int curr = dp[edge.F][x.ct+1]+edge.S;
			if(curr<dis)
			{
				dis = curr;
			}
		}
		if(!ok) continue;
		visited[x.nd] = false;
		dp[x.nd][x.ct] = dis;
		stck.pop();
	}
	//End of Iterative DFS
	*/

	REPD(i,n)
	{
		//print(dp[n-1][i]);
		if(dp[0][i]!=-1)
		{
			vi v;
			int nd,ct;
			nd = 0;
			ct = i;
			bool ex = true;
			int sum = 0;
			while(nd!=-1)
			{
				v.pb(nd+1);
				if(sum>T)
				{
					ex = false;
					//debug3(sum,nd,"HOLA:()");
					break;
				}
				int pp = par[mp(nd,ct--)];
				int cc = cost[mp(nd,pp)];
				sum+=cc;
				if(cc>INF)
				{
					throw invalid_argument("CHODU");
				}
				nd = pp;
			}
			if(ex)
			{
				//print(tt);
				print(v.size());
				for(int x : v)
					cout << x << " ";
				cout << "\n";
				return;
			}
		}
	}
	throw invalid_argument("HOLY MOLLY");
}