#include <cstdio>
#include <cstring>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
using namespace std;

typedef long long ll;

const int MAXN = 1000 + 8;
const int MAXM = 10000 + 8;
const ll INF = 0x3f3f3f3f3f3f3f3f;
struct Edge{
    int u;
    int v;
    int w;

    Edge(){
    }

    Edge(int u,int v,int w):u(u),v(v),w(w){

    }

}edges[MAXM << 1];

struct node{
    int to;
    int w;

    node(){
    }

    node(int to,int w):to(to),w(w){

    }
};

vector<node> G[MAXN];

void init(int n){
    for (int i = 0;i <= n;i ++)
        G[i].clear();
}

void add_edge(int u,int v,int w){
    G[u].push_back(node(v,w));
}

ll d[MAXN];
int inq[MAXN];
int spfa(int s,int t){
    for (int i = 0;i < MAXN;i ++)
        d[i] = INF;
    memset(inq,0,sizeof(inq));
    d[s] = 0;
    inq[s] = 1;
    queue<int> que;

    que.push(s);

    while(!que.empty()){
        int u = que.front();
        que.pop();
        inq[u] = 0;
        for (int i = 0;i < G[u].size();i ++){
            node& e = G[u][i];

            if (d[u] != INF && d[e.to] > d[u] + e.w){
                d[e.to] = d[u] + e.w;
                if (!inq[e.to]){
                    que.push(e.to);
                    inq[e.to] = 1;
                }
            }

        }

    }

    return d[t];

}

int main(){
    //freopen("1.txt","r",stdin);

    int n,m,L,s,t;
    while(scanf("%d%d%d%d%d",&n,&m,&L,&s,&t)!=EOF){
        init(n);

        for (int i = 1;i <= m;i ++){
            int u,v,w;

            scanf("%d%d%d",&u,&v,&w);

            if (w){
                add_edge(u,v,w);
                add_edge(v,u,w);
            }
            edges[i] = Edge(u,v,w);

        }
        //cout << spfa(s,t) << " " << L << endl;
        if (spfa(s,t) < L){
            puts("NO");
            continue;
        }

        if (d[t] == L){
            puts("YES");
            for (int i = 1;i <= m;i ++){
                if (!edges[i].w)
                    edges[i].w = 0x3f3f3f3f;
                printf("%d %d %d\n",edges[i].u,edges[i].v,edges[i].w);
            }
            continue;
        }
        int pos = -1;
        for (int i = 1;i <= m;i ++){
            if (edges[i].w)
                continue;
            Edge& e = edges[i];
            add_edge(e.u,e.v,1);
            add_edge(e.v,e.u,1);
            e.w = 1;
            if (spfa(s,t) <= L){
                e.w = L - d[t] + 1;
                pos = i;
                break;
            }
        }

        if (pos < 0){
            puts("NO");
            continue;
        }

        for (int i = pos;i <= m;i ++){
            if (!edges[i].w)
                edges[i].w = 0x3f3f3f3f;
        }

        puts("YES");

        for (int i = 1;i <= m;i ++){
            printf("%d %d %d\n",edges[i].u,edges[i].v,edges[i].w);
        }

    }

    return 0;

}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
using namespace std;

typedef long long ll;

const int MAXN = 1000 + 8;
const int MAXM = 10000 + 8;
const ll INF = 0x3f3f3f3f3f3f3f3f;
struct Edge{
    int u;
    int v;
    int w;

    Edge(){
    }

    Edge(int u,int v,int w):u(u),v(v),w(w){

    }

}edges[MAXM],edgeso[MAXM];

struct node{
    int to;
    int w;

    node(){
    }

    node(int to,int w):to(to),w(w){

    }
};

vector<node> G[MAXN];

void init(int n){
    for (int i = 0;i <= n;i ++)
        G[i].clear();
}

void add_edge(int u,int v,int w){
    G[u].push_back(node(v,w));
}

ll d[MAXN];
int inq[MAXN];
ll spfa(int s,int t){
    for (int i = 0;i < MAXN;i ++)
        d[i] = INF;
    memset(inq,0,sizeof(inq));
    d[s] = 0;
    inq[s] = 1;
    queue<int> que;

    que.push(s);

    while(!que.empty()){
        int u = que.front();
        que.pop();
        inq[u] = 0;
        for (int i = 0;i < G[u].size();i ++){
            node& e = G[u][i];

            if (d[u] != INF && d[e.to] > d[u] + e.w){
                d[e.to] = d[u] + e.w;
                if (!inq[e.to]){
                    que.push(e.to);
                    inq[e.to] = 1;
                }
            }

        }

    }

    return d[t];

}

int main(){
    //freopen("1.txt","r",stdin);

    int n,m,L,s,t;
    while(scanf("%d%d%d%d%d",&n,&m,&L,&s,&t)!=EOF){
        init(n);
        int cnt = 0;
        int cnto = 0;
        for (int i = 1;i <= m;i ++){
            int u,v,w;

            scanf("%d%d%d",&u,&v,&w);

            if (w){
                add_edge(u,v,w);
                add_edge(v,u,w);
                edges[cnt++] = Edge(u,v,w);
            }else
                edgeso[cnto++] = Edge(u,v,w);

        }
        //cout << spfa(s,t) << " " << L << endl;
        if (spfa(s,t) < L){
            puts("NO");
            continue;
        }

        if (d[t] == L){
            puts("YES");
            for (int i = 0; i < cnt;i ++){
                printf("%d %d %d\n",edges[i].u,edges[i].v,edges[i].w);
            }

            for (int i = 0;i < cnto;i ++){
                printf("%d %d %d\n",edgeso[i].u,edgeso[i].v,0x3f3f3f3f);
            }

            continue;
        }
        int pos = -1;
        for (int i = 0;i < cnto;i ++){

            Edge& e = edgeso[i];
            add_edge(e.u,e.v,1);
            add_edge(e.v,e.u,1);
            e.w = 1;
            if (spfa(s,t) <= L){
                e.w = L - d[t] + 1;
                pos = i;
                break;
            }
        }

        //cout << pos << endl;

        if (pos < 0){
            puts("NO");
            continue;
        }

        for (int i = pos + 1;i < cnto;i ++){
            edgeso[i].w = 0x3f3f3f3f;
        }

        puts("YES");

        for (int i = 0;i < cnt;i ++){
            printf("%d %d %d\n",edges[i].u,edges[i].v,edges[i].w);
        }

        for (int i = 0;i < cnto;i ++){
            printf("%d %d %d\n",edgeso[i].u,edgeso[i].v,edgeso[i].w);
        }

    }

    return 0;

}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
using namespace std;

typedef long long ll;

const int MAXN = 1000 + 8;
const int MAXM = 10000 + 8;
const ll INF = 0x3f3f3f3f3f3f3f3f;
struct Edge{
    int u;
    int v;
    int w;

    Edge(){
    }

    Edge(int u,int v,int w):u(u),v(v),w(w){

    }

}edges[MAXM << 1];

struct node{
    int to;
    int w;

    node(){
    }

    node(int to,int w):to(to),w(w){

    }
};

vector<node> G[MAXN];

void init(int n){
    for (int i = 0;i <= n;i ++)
        G[i].clear();
}

void add_edge(int u,int v,int w){
    G[u].push_back(node(v,w));
}

ll d[MAXN];
int inq[MAXN];
int spfa(int s,int t){
    for (int i = 0;i < MAXN;i ++)
        d[i] = INF;
    memset(inq,0,sizeof(inq));
    d[s] = 0;
    inq[s] = 1;
    queue<int> que;

    que.push(s);

    while(!que.empty()){
        int u = que.front();
        que.pop();

        for (int i = 0;i < G[u].size();i ++){
            node& e = G[u][i];

            if (d[e.to] > d[u] + e.w){
                d[e.to] = d[u] + e.w;
                if (!inq[e.to]){
                    que.push(e.to);
                    inq[e.to] = 1;
                }
            }

        }
        inq[u] = 0;
    }

    return d[t];

}

int main(){

    freopen("1.txt","r",stdin);

    int n,m,L,s,t;
    while(scanf("%d%d%d%d%d",&n,&m,&L,&s,&t)!=EOF){
        init(n);

        for (int i = 1;i <= m;i ++){
            int u,v,w;

            scanf("%d%d%d",&u,&v,&w);

            if (w){
                add_edge(u,v,w);
                add_edge(v,u,w);
            }
            edges[i] = Edge(u,v,w);

        }
        //cout << spfa(s,t) << " " << L << endl;
        if (spfa(s,t) < L){
            puts("NO");
            continue;
        }

        for (int i = 1;i <= m;i ++){
            if (edges[i].w)
                continue;
            Edge& e = edges[i];
            add_edge(e.u,e.v,1);
            add_edge(e.v,e.u,1);
            e.w = 1;
            if (spfa(s,t) < L){
                e.w = L - d[t] + 1;
                G[e.u].back().w = e.w;
                G[e.v].back().w = e.w;
            }
        }

        if (d[t] > L){
            puts("NO");
            continue;
        }

        for (int i = 1;i <= m;i ++){
            if (edges[i].w)
                continue;
            edges[i].w = INF;
        }

        puts("YES");

        for (int i = 1;i <= m;i ++){
            printf("%d %d %d\n",edges[i].u,edges[i].v,edges[i].w);
        }

    }

    return 0;

}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
using namespace std;

typedef long long ll;

const int MAXN = 1000 + 8;
const int MAXM = 10000 + 8;
const ll INF = 0x7f7f7f7f7f7f7f7f;
struct Edge{
    int u;
    int v;
    int w;

    Edge(){
    }

    Edge(int u,int v,int w):u(u),v(v),w(w){

    }

}edges[MAXM << 1];

struct node{
    int to;
    int w;

    node(){
    }

    node(int to,int w):to(to),w(w){

    }
};

vector<node> G[MAXN];

void init(int n){
    for (int i = 0;i <= n;i ++)
        G[i].clear();
}

void add_edge(int u,int v,int w){
    G[u].push_back(node(v,w));
}

ll d[MAXN];
int inq[MAXN];
int spfa(int s,int t){
    for (int i = 1;i < MAXN;i ++)
        d[i] = INF;
    memset(inq,0,sizeof(inq));
    d[s] = 0;
    inq[s] = 1;
    queue<int> que;

    que.push(s);

    while(!que.empty()){
        int u = que.front();
        que.pop();

        for (int i = 0;i < G[u].size();i ++){
            node& e = G[u][i];

            if (d[e.to] > d[u] + e.w){
                d[e.to] = d[u] + e.w;
                if (!inq[e.to]){
                    que.push(e.to);
                    inq[e.to] = 1;
                }
            }

        }
        inq[u] = 0;
    }

    return d[t];

}

int main(){

    freopen("1.txt","r",stdin);

    int n,m,L,s,t;
    while(scanf("%d%d%d%d%d",&n,&m,&L,&s,&t)!=EOF){
        init(n);

        for (int i = 1;i <= m;i ++){
            int u,v,w;

            scanf("%d%d%d",&u,&v,&w);

            if (w){
                add_edge(u,v,w);
                add_edge(v,u,w);
            }
            edges[i] = Edge(u,v,w);

        }
        //cout << spfa(s,t) << endl;
        if (spfa(s,t) < L){
            puts("NO");
            continue;
        }

        for (int i = 1;i <= m;i ++){
            if (edges[i].w)
                continue;
            Edge& e = edges[i];
            add_edge(e.u,e.v,1);
            add_edge(e.v,e.u,1);
            e.w = 1;
            if (spfa(s,t) < L){
                e.w = L - d[t] - 1;
                break;
            }
        }

        for (int i = 1;i <= m;i ++){
            if (edges[i].w)
                continue;
            edges[i].w = INF;
        }

        puts("YES");

        for (int i = 1;i <= m;i ++){
            printf("%d %d %d\n",edges[i].u,edges[i].v,edges[i].w);
        }

    }

    return 0;

}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
using namespace std;

typedef long long ll;

const int MAXN = 1000 + 8;
const int MAXM = 10000 + 8;
const ll INF = 0x7f7f7f7f7f7f7f7f;
struct Edge{
    int u;
    int v;
    int w;

    Edge(){
    }

    Edge(int u,int v,int w):u(u),v(v),w(w){

    }

}edges[MAXM << 1];

struct node{
    int to;
    int w;

    node(){
    }

    node(int to,int w):to(to),w(w){

    }
};

vector<node> G[MAXN];

void init(int n){
    for (int i = 0;i <= n;i ++)
        G[i].clear();
}

void add_edge(int u,int v,int w){
    G[u].push_back(node(v,w));
}

ll d[MAXN];
int inq[MAXN];
int spfa(int s,int t){
    for (int i = 0;i < MAXN;i ++)
        d[i] = INF;
    memset(inq,0,sizeof(inq));
    d[s] = 0;
    inq[s] = 1;
    queue<int> que;

    que.push(s);

    while(!que.empty()){
        int u = que.front();
        que.pop();

        for (int i = 0;i < G[u].size();i ++){
            node& e = G[u][i];

            if (d[e.to] > d[u] + e.w){
                d[e.to] = d[u] + e.w;
                if (!inq[e.to]){
                    que.push(e.to);
                    inq[e.to] = 1;
                }
            }

        }
        inq[u] = 0;
    }

    return d[t];

}

int main(){

    //freopen("1.txt","r",stdin);

    int n,m,L,s,t;
    while(scanf("%d%d%d%d%d",&n,&m,&L,&s,&t)!=EOF){
        init(n);

        for (int i = 1;i <= m;i ++){
            int u,v,w;

            scanf("%d%d%d",&u,&v,&w);

            if (w){
                add_edge(u,v,w);
                add_edge(v,u,w);
            }
            edges[i] = Edge(u,v,w);

        }
        cout << spfa(s,t) << " " << L << endl;
        if (spfa(s,t) < L){
            puts("NO");
            continue;
        }

        for (int i = 1;i <= m;i ++){
            if (edges[i].w)
                continue;
            Edge& e = edges[i];
            add_edge(e.u,e.v,1);
            add_edge(e.v,e.u,1);
            e.w = 1;
            if (spfa(s,t) < L){
                e.w = L - d[t] + 1;
                break;
            }
        }

        if (d[t] > L){
            puts("NO");
            continue;
        }

        for (int i = 1;i <= m;i ++){
            if (edges[i].w)
                continue;
            edges[i].w = INF;
        }

        puts("YES");

        for (int i = 1;i <= m;i ++){
            printf("%d %d %d\n",edges[i].u,edges[i].v,edges[i].w);
        }

    }

    return 0;

}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
using namespace std;

typedef long long ll;

const int MAXN = 1000 + 8;
const int MAXM = 10000 + 8;
const ll INF = 0x3f3f3f3f3f3f3f3f;
struct Edge{
    int u;
    int v;
    int w;

    Edge(){
    }

    Edge(int u,int v,int w):u(u),v(v),w(w){

    }

}edges[MAXM << 1];

struct node{
    int to;
    int w;

    node(){
    }

    node(int to,int w):to(to),w(w){

    }
};

vector<node> G[MAXN];

void init(int n){
    for (int i = 0;i <= n;i ++)
        G[i].clear();
}

void add_edge(int u,int v,int w){
    G[u].push_back(node(v,w));
}

ll d[MAXN];
int inq[MAXN];
int spfa(int s,int t){
    for (int i = 0;i < MAXN;i ++)
        d[i] = INF;
    memset(inq,0,sizeof(inq));
    d[s] = 0;
    inq[s] = 1;
    queue<int> que;

    que.push(s);

    while(!que.empty()){
        int u = que.front();
        que.pop();

        for (int i = 0;i < G[u].size();i ++){
            node& e = G[u][i];

            if (d[u] != INF && d[e.to] > d[u] + e.w){
                d[e.to] = d[u] + e.w;
                if (!inq[e.to]){
                    que.push(e.to);
                    inq[e.to] = 1;
                }
            }

        }
        inq[u] = 0;
    }

    return d[t];

}

int main(){

    //freopen("1.txt","r",stdin);

    int n,m,L,s,t;
    while(scanf("%d%d%d%d%d",&n,&m,&L,&s,&t)!=EOF){
        init(n);

        for (int i = 1;i <= m;i ++){
            int u,v,w;

            scanf("%d%d%d",&u,&v,&w);

            if (w){
                add_edge(u,v,w);
                add_edge(v,u,w);
            }
            edges[i] = Edge(u,v,w);

        }
        //cout << spfa(s,t) << " " << L << endl;
        if (spfa(s,t) < L){
            puts("NO");
            continue;
        }

        if (d[t] == L){
            puts("YES");
            for (int i = 1;i <= m;i ++){
                if (!edges[i].w)
                    edges[i].w = 0x3f3f3f3f;
                printf("%d %d %d\n",edges[i].u,edges[i].v,edges[i].w);
            }
            continue;
        }
        int pos = -1;
        for (int i = 1;i <= m;i ++){
            if (edges[i].w)
                continue;
            Edge& e = edges[i];
            add_edge(e.u,e.v,1);
            add_edge(e.v,e.u,1);
            e.w = 1;
            if (spfa(s,t) <= L){
                e.w = L - d[t] + 1;
                pos = i;
                break;
            }
        }

        if (pos < 0){
            puts("NO");
            continue;
        }

        for (int i = pos;i <= m;i ++){
            if (edges[i].w)
                continue;
            edges[i].w = 0x3f3f3f3f;
        }

        puts("YES");

        for (int i = 1;i <= m;i ++){
            printf("%d %d %d\n",edges[i].u,edges[i].v,edges[i].w);
        }

    }

    return 0;

}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
using namespace std;

typedef long long ll;

const int MAXN = 1000 + 8;
const int MAXM = 10000 + 8;
const ll INF = 0x3f3f3f3f3f3f3f3f;
struct Edge{
    int u;
    int v;
    int w;

    Edge(){
    }

    Edge(int u,int v,int w):u(u),v(v),w(w){

    }

}edges[MAXM << 1];

struct node{
    int to;
    int w;

    node(){
    }

    node(int to,int w):to(to),w(w){

    }
};

vector<node> G[MAXN];

void init(int n){
    for (int i = 0;i <= n;i ++)
        G[i].clear();
}

void add_edge(int u,int v,int w){
    G[u].push_back(node(v,w));
}

ll d[MAXN];
int inq[MAXN];
int spfa(int s,int t){
    for (int i = 0;i < MAXN;i ++)
        d[i] = INF;
    memset(inq,0,sizeof(inq));
    d[s] = 0;
    inq[s] = 1;
    queue<int> que;

    que.push(s);

    while(!que.empty()){
        int u = que.front();
        que.pop();

        for (int i = 0;i < G[u].size();i ++){
            node& e = G[u][i];

            if (d[e.to] > d[u] + e.w){
                d[e.to] = d[u] + e.w;
                if (!inq[e.to]){
                    que.push(e.to);
                    inq[e.to] = 1;
                }
            }

        }
        inq[u] = 0;
    }

    return d[t];

}

int main(){

    //freopen("1.txt","r",stdin);

    int n,m,L,s,t;
    while(scanf("%d%d%d%d%d",&n,&m,&L,&s,&t)!=EOF){
        init(n);
        int flag = 0;
        for (int i = 1;i <= m;i ++){
            int u,v,w;

            scanf("%d%d%d",&u,&v,&w);

            if (w){
                add_edge(u,v,w);
                add_edge(v,u,w);
            }else
                flag = 1;
            edges[i] = Edge(u,v,w);

        }
        //cout << spfa(s,t) << " " << L << endl;
        if (spfa(s,t) < L){
            puts("NO");
            continue;
        }

        if (d[t] > L && !flag){
            puts("NO");
            continue;
        }

        for (int i = 1;i <= m;i ++){
            if (edges[i].w)
                continue;
            Edge& e = edges[i];
            add_edge(e.u,e.v,1);
            add_edge(e.v,e.u,1);
            e.w = 1;
            if (spfa(s,t) < L){
                e.w = L - d[t] + 1;
                break;
            }
        }

        for (int i = 1;i <= m;i ++){
            if (edges[i].w)
                continue;
            edges[i].w = INF;
        }

        puts("YES");

        for (int i = 1;i <= m;i ++){
            printf("%d %d %d\n",edges[i].u,edges[i].v,edges[i].w);
        }

    }

    return 0;

}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
using namespace std;

typedef long long ll;

const int MAXN = 1000 + 8;
const int MAXM = 10000 + 8;
const ll INF = 0x7f7f7f7f7f7f7f7f;
struct Edge{
    int u;
    int v;
    int w;

    Edge(){
    }

    Edge(int u,int v,int w):u(u),v(v),w(w){

    }

}edges[MAXM << 1];

struct node{
    int to;
    int w;

    node(){
    }

    node(int to,int w):to(to),w(w){

    }
};

vector<node> G[MAXN];

void init(int n){
    for (int i = 0;i <= n;i ++)
        G[i].clear();
}

void add_edge(int u,int v,int w){
    G[u].push_back(node(v,w));
}

ll d[MAXN];
int inq[MAXN];
int spfa(int s,int t){
    for (int i = 1;i < MAXN;i ++)
        d[i] = INF;
    memset(inq,0,sizeof(inq));
    d[s] = 0;
    inq[s] = 1;
    queue<int> que;

    que.push(s);

    while(!que.empty()){
        int u = que.front();
        que.pop();

        for (int i = 0;i < G[u].size();i ++){
            node& e = G[u][i];

            if (d[e.to] > d[u] + e.w){
                d[e.to] = d[u] + e.w;
                if (!inq[e.to]){
                    que.push(e.to);
                    inq[e.to] = 1;
                }
            }

        }
        inq[u] = 0;
    }

    return d[t];

}

int main(){

    //freopen("1.txt","r",stdin);

    int n,m,L,s,t;
    while(scanf("%d%d%d%d%d",&n,&m,&L,&s,&t)!=EOF){
        init(n);

        for (int i = 1;i <= m;i ++){
            int u,v,w;

            scanf("%d%d%d",&u,&v,&w);

            if (w){
                add_edge(u,v,w);
                add_edge(v,u,w);
            }
            edges[i] = Edge(u,v,w);

        }
        //cout << spfa(s,t) << endl;
        if (spfa(s,t) < L){
            puts("NO");
            continue;
        }

        for (int i = 1;i <= m;i ++){
            if (edges[i].w)
                continue;
            Edge& e = edges[i];
            add_edge(e.u,e.v,1);
            add_edge(e.v,e.u,1);
            e.w = 1;
            if (spfa(s,t) < L){
                e.w = L - d[t] - 1;
                break;
            }
        }

        for (int i = 1;i <= m;i ++){
            if (edges[i].w)
                continue;
            edges[i].w = INF;
        }

        puts("YES");

        for (int i = 1;i <= m;i ++){
            printf("%d %d %d\n",edges[i].u,edges[i].v,edges[i].w);
        }

    }

    return 0;

}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
using namespace std;

typedef long long ll;

const int MAXN = 1000 + 8;
const int MAXM = 10000 + 8;
const ll INF = 0x3f3f3f3f3f3f3f3f;
struct Edge{
    int u;
    int v;
    int w;

    Edge(){
    }

    Edge(int u,int v,int w):u(u),v(v),w(w){

    }

}edges[MAXM << 1];

struct node{
    int to;
    int w;

    node(){
    }

    node(int to,int w):to(to),w(w){

    }
};

vector<node> G[MAXN];

void init(int n){
    for (int i = 0;i <= n;i ++)
        G[i].clear();
}

void add_edge(int u,int v,int w){
    G[u].push_back(node(v,w));
}

ll d[MAXN];
int inq[MAXN];
int spfa(int s,int t){
    for (int i = 0;i < MAXN;i ++)
        d[i] = INF;
    memset(inq,0,sizeof(inq));
    d[s] = 0;
    inq[s] = 1;
    queue<int> que;

    que.push(s);

    while(!que.empty()){
        int u = que.front();
        que.pop();

        for (int i = 0;i < G[u].size();i ++){
            node& e = G[u][i];

            if (d[u] != INF && d[e.to] > d[u] + e.w){
                d[e.to] = d[u] + e.w;
                if (!inq[e.to]){
                    que.push(e.to);
                    inq[e.to] = 1;
                }
            }

        }
        inq[u] = 0;
    }

    return d[t];

}

int main(){

    //freopen("1.txt","r",stdin);

    int n,m,L,s,t;
    while(scanf("%d%d%d%d%d",&n,&m,&L,&s,&t)!=EOF){
        init(n);

        for (int i = 1;i <= m;i ++){
            int u,v,w;

            scanf("%d%d%d",&u,&v,&w);

            if (w){
                add_edge(u,v,w);
                add_edge(v,u,w);
            }
            edges[i] = Edge(u,v,w);

        }
        //cout << spfa(s,t) << " " << L << endl;
        if (spfa(s,t) < L){
            puts("NO");
            continue;
        }

        for (int i = 1;i <= m;i ++){
            if (edges[i].w)
                continue;
            Edge& e = edges[i];
            add_edge(e.u,e.v,1);
            add_edge(e.v,e.u,1);
            e.w = 1;
            if (spfa(s,t) < L){
                e.w = L - d[t] + 1;
                break;
            }
        }

        if (d[t] > L){
            puts("NO");
            continue;
        }

        for (int i = 1;i <= m;i ++){
            if (edges[i].w)
                continue;
            edges[i].w = 0x3f3f3f3f;
        }

        puts("YES");

        for (int i = 1;i <= m;i ++){
            printf("%d %d %d\n",edges[i].u,edges[i].v,edges[i].w);
        }

    }

    return 0;

}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
using namespace std;

typedef long long ll;

const int MAXN = 1000 + 8;
const int MAXM = 10000 + 8;
const ll INF = 0x3f3f3f3f3f3f3f3f;
struct Edge{
    int u;
    int v;
    int w;

    Edge(){
    }

    Edge(int u,int v,int w):u(u),v(v),w(w){

    }

}edges[MAXM],edgeso[MAXM];

struct node{
    int to;
    int w;

    node(){
    }

    node(int to,int w):to(to),w(w){

    }
};

vector<node> G[MAXN];

void init(int n){
    for (int i = 0;i <= n;i ++)
        G[i].clear();
}

void add_edge(int u,int v,int w){
    G[u].push_back(node(v,w));
}

ll d[MAXN];
int inq[MAXN];
int spfa(int s,int t){
    for (int i = 0;i < MAXN;i ++)
        d[i] = INF;
    memset(inq,0,sizeof(inq));
    d[s] = 0;
    inq[s] = 1;
    queue<int> que;

    que.push(s);

    while(!que.empty()){
        int u = que.front();
        que.pop();
        inq[u] = 0;
        for (int i = 0;i < G[u].size();i ++){
            node& e = G[u][i];

            if (d[u] != INF && d[e.to] > d[u] + e.w){
                d[e.to] = d[u] + e.w;
                if (!inq[e.to]){
                    que.push(e.to);
                    inq[e.to] = 1;
                }
            }

        }

    }

    return d[t];

}

int main(){
    //freopen("1.txt","r",stdin);

    int n,m,L,s,t;
    while(scanf("%d%d%d%d%d",&n,&m,&L,&s,&t)!=EOF){
        init(n);
        int cnt = 0;
        int cnto = 0;
        for (int i = 1;i <= m;i ++){
            int u,v,w;

            scanf("%d%d%d",&u,&v,&w);

            if (w){
                add_edge(u,v,w);
                add_edge(v,u,w);
                edges[cnt++] = Edge(u,v,w);
            }else
                edgeso[cnto++] = Edge(u,v,w);

        }
        //cout << spfa(s,t) << " " << L << endl;
        if (spfa(s,t) < L){
            puts("NO");
            continue;
        }

        if (d[t] == L){
            puts("YES");
            for (int i = 0; i < cnt;i ++){
                printf("%d %d %d\n",edges[i].u,edges[i].v,edges[i].w);
            }

            for (int i = 0;i < cnto;i ++){
                printf("%d %d %d\n",edges[i].u,edges[i].v,0x3f3f3f3f);
            }

            continue;
        }
        int pos = -1;
        for (int i = 0;i < cnto;i ++){

            Edge& e = edgeso[i];
            add_edge(e.u,e.v,1);
            add_edge(e.v,e.u,1);
            e.w = 1;
            if (spfa(s,t) <= L){
                e.w = L - d[t] + 1;
                pos = i;
                break;
            }
        }

        if (pos < 0){
            puts("NO");
            continue;
        }

        for (int i = pos + 1;i < cnto;i ++){
            edgeso[i].w = 0x3f3f3f3f;
        }

        puts("YES");

        for (int i = 0;i < cnt;i ++){
            printf("%d %d %d\n",edges[i].u,edges[i].v,edges[i].w);
        }

        for (int i = 0;i < cnto;i ++){
            printf("%d %d %d\n",edgeso[i].u,edgeso[i].v,edgeso[i].w);
        }

    }

    return 0;

}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define maxm 10010
#define maxn 1010
int n ,m ,S ,T ;
LL  L;
struct node {
    int to,next; LL v; bool fl;
}E[maxm << 1];
int tot = 0,line[maxn];
inline void insert(int x,int y,LL v,bool fl) {
	tot ++; E[tot].to = y; E[tot].next = line[x]; line[x] = tot; E[tot].v = v; E[tot].fl =fl;
	tot ++; E[tot].to = x; E[tot].next = line[y]; line[y] = tot; E[tot].v = v; E[tot].fl = fl;
}
struct line { int x,y; LL v; }W[maxm];
queue <int> Q;
LL   dis1[maxn],dis2[maxn];
bool In_Q[maxn];
inline void spfa(int s,int t,LL  *dis) {
	dis[s] = 0; In_Q[s] = 1; Q.push(s);
	while(!Q.empty()) {
		int x = Q.front(); Q.pop(); In_Q[x] = false;
		for(int i = line[x];i != 0;i = E[i].next) {
			int p = E[i].to;
			if(dis[p] > dis[x] + E[i].v) {
				dis[p] = dis[x] + E[i].v;
				if(!In_Q[p]) {
					Q.push(p); In_Q[p] = true;
				}
			}
		}
	}
}
bool G[1010][1010];
int main() {
    scanf("%d%d%lld%d%d",&n,&m,&L,&S,&T);
	S ++; T ++;
    int x = 0,y = 0; LL v = 0;
	for(int i = 1;i <= m;++ i) {
        scanf("%d%d%lld",&x,&y,&v);
		W[i].x = x+1;
		W[i].y = y+1;
		W[i].v = v;
		if(v != 0) insert(x+1,y+1,v,0);
		else insert(x+1,y+1,1,1);
    }
	memset(dis1,0x3f,sizeof(dis1));
	spfa(T,S,dis1);
	/*for(int i = 1;i <= n;++ i) {
		printf("%d\n",dis1[i]);
	}*/
	/*memset(dis2,0x3f,sizeof(dis2));
	spfa(S,T,dis2);
	for(int i = 1;i <= n;++ i) {
		printf("%d\n",dis2[i]);
	}
	bool flag = 0;
	printf("%lld %lld\n",dis1[2],dis1[5]);
	printf("%lld %lld\n",dis2[2],dis2[5]);
	for(int i = 1;i <= m;++ i) {
		if(W[i].v == 0) {
			if(dis1[W[i].x]+dis2[W[i].y] <= dis2[W[i].x]+dis1[W[i].y]
					&& dis1[W[i].x] + dis2[W[i].y] + 1 <= L) {
				W[i].v = L - dis1[W[i].x] - dis2[W[i].y];	flag = true;
			} else {
				if(dis1[W[i].y]+dis2[W[i].x] <= dis2[W[i].y]+dis1[W[i].x]
					&& dis1[W[i].y] + dis2[W[i].y] + 1 <= L) {
					W[i].v = L - dis1[W[i].y] - dis2[W[i].x]; flag = true;
				} else {
					W[i].v = 1000000000000000000;
				}
			}
		}
	}*/
	memset(dis2,0x3f,sizeof(dis2));
	dis2[S] = 0; In_Q[S] = 1; Q.push(S);
	while(!Q.empty()) {
		int x = Q.front(); Q.pop(); In_Q[x] = false;
		for(int i = line[x];i != 0;i = E[i].next) {
			int p = E[i].to;
			if(E[i].fl = 1 && dis2[x]+dis1[p] < L) E[i].v = L-dis2[x]-dis1[p];
			if(dis2[p] > dis2[x] + E[i].v) {
				dis2[p] = dis2[x] + E[i].v;
				if(!In_Q[p]) {
					Q.push(p); In_Q[p] = true;
				}
			}
		}
	}
	if(dis2[T] != L) {
		printf("NO\n");
	} else {
        printf("YES\n");
		for(int i = 1;i <= m;++ i) {
			printf("%d %d %lld\n",W[i].x-1,W[i].y-1,E[i*2-1].v);
		}
	}
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define maxm 10010
#define maxn 1010
int n ,m ,S ,T ;
LL  L;
struct node {
    int to,next; LL v;
}E[maxm << 1];
int tot = 0,line[maxn];
inline void insert(int x,int y,LL v) {
	tot ++; E[tot].to = y; E[tot].next = line[x]; line[x] = tot; E[tot].v = v;
	tot ++; E[tot].to = x; E[tot].next = line[y]; line[y] = tot; E[tot].v = v;
}
struct line { int x,y; LL v; }W[maxm];
queue <int> Q;
LL   dis1[maxn],dis2[maxn];
bool In_Q[maxn];
inline void spfa(int s,int t,LL  *dis) {
	dis[s] = 0; In_Q[s] = 1; Q.push(s);
	while(!Q.empty()) {
		int x = Q.front(); Q.pop(); In_Q[x] = false;
		for(int i = line[x];i != 0;i = E[i].next) {
			int p = E[i].to;
			if(dis[p] > dis[x] + E[i].v && E[i].v > 0) {
				dis[p] = dis[x] + E[i].v;
				if(!In_Q[p]) {
					Q.push(p); In_Q[p] = true;
				}
			}
		}
	}
}
bool G[1010][1010];
int main() {
    scanf("%d%d%lld%d%d",&n,&m,&L,&S,&T);
	S ++; T ++;
    int x = 0,y = 0; LL v = 0;
	for(int i = 1;i <= m;++ i) {
        scanf("%d%d%lld",&x,&y,&v);
		W[i].x = x+1;
		W[i].y = y+1;
		W[i].v = v;
		if(v != 0) insert(x+1,y+1,v);
		else insert(x+1,y+1,1);
    }
	memset(dis1,0x3f,sizeof(dis1));
	spfa(T,S,dis1);
	for(int i = 1;i <= n;++ i) {
		printf("%d\n",dis1[i]);
	}
	for(int i = 1;i <= m;++ i) {
		if(W[i].v == 0) E[i*2-1].v = E[i*2].v = 0;
	}
	/*memset(dis2,0x3f,sizeof(dis2));
	spfa(S,T,dis2);
	for(int i = 1;i <= n;++ i) {
		printf("%d\n",dis2[i]);
	}
	bool flag = 0;
	printf("%lld %lld\n",dis1[2],dis1[5]);
	printf("%lld %lld\n",dis2[2],dis2[5]);
	for(int i = 1;i <= m;++ i) {
		if(W[i].v == 0) {
			if(dis1[W[i].x]+dis2[W[i].y] <= dis2[W[i].x]+dis1[W[i].y]
					&& dis1[W[i].x] + dis2[W[i].y] + 1 <= L) {
				W[i].v = L - dis1[W[i].x] - dis2[W[i].y];	flag = true;
			} else {
				if(dis1[W[i].y]+dis2[W[i].x] <= dis2[W[i].y]+dis1[W[i].x]
					&& dis1[W[i].y] + dis2[W[i].y] + 1 <= L) {
					W[i].v = L - dis1[W[i].y] - dis2[W[i].x]; flag = true;
				} else {
					W[i].v = 1000000000000000000;
				}
			}
		}
	}*/
	bool flag = 0;
	memset(dis2,0x3f,sizeof(dis2));
	dis2[S] = 0; In_Q[S] = 1; Q.push(S);
	while(!Q.empty()) {
		int x = Q.front(); Q.pop(); In_Q[x] = false;
		for(int i = line[x];i != 0;i = E[i].next) {
			int p = E[i].to;
			if(E[i].v > 0 && dis2[p] > dis2[x] + E[i].v) {
				dis2[p] = dis2[x] + E[i].v;
				if(!In_Q[p]) {
					Q.push(p); In_Q[p] = true;
				}
			}
			if(E[i].v == 0) {
				if(dis2[x] + dis1[p] + 1 <= L) {
					printf("!!!%d %d\n",x,p);
					printf("!!!%lld %lld\n",dis1[p],dis2[x]);
					printf("!!!%d\n",(i+1)/2);
					W[(i+1)/2].v = L-dis2[x]-dis1[p]; flag = 1;
				} else {
					if(W[(i+1)/2].v == 0) W[(i+1)/2].v = 1000000000000000000;
				}
			}
		}
	}
	if(!flag && dis2[T] != L) {
		printf("NO\n");
	} else {
		for(int i = 1;i <= m;++ i) {
			if(W[i].v == 0) W[i].v = 1000000000000000000;
			printf("%d %d %lld\n",W[i].x-1,W[i].y-1,W[i].v);
		}
	}
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define maxm 10010
#define maxn 1010
int n ,m ,S ,T ;
LL  L;
struct node {
    int to,next; LL v;
}E[maxm << 1];
int tot = 0,line[maxn];
inline void insert(int x,int y,LL v) {
	tot ++; E[tot].to = y; E[tot].next = line[x]; line[x] = tot; E[tot].v = v;
	tot ++; E[tot].to = x; E[tot].next = line[y]; line[y] = tot; E[tot].v = v;
}
struct line { int x,y; LL v; }W[maxm];
queue <int> Q;
LL   dis1[maxn],dis2[maxn];
bool In_Q[maxn];
inline void spfa(int s,int t,LL  *dis) {
	dis[s] = 0; In_Q[s] = 1; Q.push(s);
	while(!Q.empty()) {
		int x = Q.front(); Q.pop(); In_Q[x] = false;
		for(int i = line[x];i != 0;i = E[i].next) {
			int p = E[i].to;
			if(dis[p] > dis[x] + E[i].v && E[i].v > 0) {
				dis[p] = dis[x] + E[i].v;
				if(!In_Q[p]) {
					Q.push(p); In_Q[p] = true;
				}
			}
		}
	}
}
bool G[1010][1010];
int main() {
    scanf("%d%d%lld%d%d",&n,&m,&L,&S,&T);
	S ++; T ++;
    int x = 0,y = 0; LL v = 0;
	for(int i = 1;i <= m;++ i) {
        scanf("%d%d%lld",&x,&y,&v);
		W[i].x = x+1;
		W[i].y = y+1;
		W[i].v = v;
		if(v != 0) insert(x+1,y+1,v);
		else insert(x+1,y+1,1);
    }
	memset(dis1,0x3f,sizeof(dis1));
	spfa(T,S,dis1);
	/*for(int i = 1;i <= n;++ i) {
		printf("%d\n",dis1[i]);
	}*/
	for(int i = 1;i <= m;++ i) {
		if(W[i].v == 0) E[i*2-1].v = E[i*2].v = 0;
	}
	/*memset(dis2,0x3f,sizeof(dis2));
	spfa(S,T,dis2);
	for(int i = 1;i <= n;++ i) {
		printf("%d\n",dis2[i]);
	}
	bool flag = 0;
	printf("%lld %lld\n",dis1[2],dis1[5]);
	printf("%lld %lld\n",dis2[2],dis2[5]);
	for(int i = 1;i <= m;++ i) {
		if(W[i].v == 0) {
			if(dis1[W[i].x]+dis2[W[i].y] <= dis2[W[i].x]+dis1[W[i].y]
					&& dis1[W[i].x] + dis2[W[i].y] + 1 <= L) {
				W[i].v = L - dis1[W[i].x] - dis2[W[i].y];	flag = true;
			} else {
				if(dis1[W[i].y]+dis2[W[i].x] <= dis2[W[i].y]+dis1[W[i].x]
					&& dis1[W[i].y] + dis2[W[i].y] + 1 <= L) {
					W[i].v = L - dis1[W[i].y] - dis2[W[i].x]; flag = true;
				} else {
					W[i].v = 1000000000000000000;
				}
			}
		}
	}*/
	bool flag = 0;
	memset(dis2,0x3f,sizeof(dis2));
	dis2[S] = 0; In_Q[S] = 1; Q.push(S);
	while(!Q.empty()) {
		int x = Q.front(); Q.pop(); In_Q[x] = false;
		for(int i = line[x];i != 0;i = E[i].next) {
			int p = E[i].to;
			if(E[i].v > 0 && dis2[p] > dis2[x] + E[i].v) {
				dis2[p] = dis2[x] + E[i].v;
				if(!In_Q[p]) {
					Q.push(p); In_Q[p] = true;
				}
			}
			if(E[i].v == 0) {
				if(dis2[x] + dis1[p] + 1 <= L) {
					//printf("!!!%d %d\n",x,p);
					//printf("!!!%lld %lld\n",dis1[p],dis2[x]);
					//printf("!!!%d\n",(i+1)/2);
					W[(i+1)/2].v = L-dis2[x]-dis1[p]; flag = 1;
				} else {
					if(W[(i+1)/2].v == 0) W[(i+1)/2].v = 1000000000000000000;
				}
			}
		}
	}
	if((!flag && dis2[T] != L) || (dis2[T] < L)) {
		printf("NO\n");
	} else {
        printf("YES\n");
		for(int i = 1;i <= m;++ i) {
			if(W[i].v == 0) W[i].v = 1000000000000000000;
			printf("%d %d %lld\n",W[i].x-1,W[i].y-1,W[i].v);
		}
	}
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define maxm 10010
#define maxn 1010
int n ,m ,S ,T ;
LL  L;
struct node {
    int to,next; LL v;
}E[maxm << 1];
int tot = 0,line[maxn];
inline void insert(int x,int y,LL v) {
	tot ++; E[tot].to = y; E[tot].next = line[x]; line[x] = tot; E[tot].v = v;
	tot ++; E[tot].to = x; E[tot].next = line[y]; line[y] = tot; E[tot].v = v;
}
struct line { int x,y; LL v; }W[maxm];
queue <int> Q;
LL   dis1[maxn],dis2[maxn];
bool In_Q[maxn];
inline void spfa(int s,int t,LL  *dis) {
	dis[s] = 0; In_Q[s] = 1; Q.push(s);
	while(!Q.empty()) {
		int x = Q.front(); Q.pop(); In_Q[x] = false;
		for(int i = line[x];i != 0;i = E[i].next) {
			int p = E[i].to;
			if(dis[p] > dis[x] + E[i].v && E[i].v > 0) {
				dis[p] = dis[x] + E[i].v;
				if(!In_Q[p]) {
					Q.push(p); In_Q[p] = true;
				}
			}
		}
	}
}
bool G[1010][1010];
int main() {
    scanf("%d%d%lld%d%d",&n,&m,&L,&S,&T);
	S ++; T ++;
    int x = 0,y = 0; LL v = 0;
	for(int i = 1;i <= m;++ i) {
        scanf("%d%d%lld",&x,&y,&v);
		W[i].x = x+1;
		W[i].y = y+1;
		W[i].v = v;
		if(v != 0) insert(x+1,y+1,v);
		else insert(x+1,y+1,1);
    }
	memset(dis1,0x3f,sizeof(dis1));
	spfa(T,S,dis1);
	/*for(int i = 1;i <= n;++ i) {
		printf("%d\n",dis1[i]);
	}*/
	for(int i = 1;i <= m;++ i) {
		if(W[i].v == 0) E[i*2-1].v = E[i*2].v = 0;
	}
	/*memset(dis2,0x3f,sizeof(dis2));
	spfa(S,T,dis2);
	for(int i = 1;i <= n;++ i) {
		printf("%d\n",dis2[i]);
	}
	bool flag = 0;
	printf("%lld %lld\n",dis1[2],dis1[5]);
	printf("%lld %lld\n",dis2[2],dis2[5]);
	for(int i = 1;i <= m;++ i) {
		if(W[i].v == 0) {
			if(dis1[W[i].x]+dis2[W[i].y] <= dis2[W[i].x]+dis1[W[i].y]
					&& dis1[W[i].x] + dis2[W[i].y] + 1 <= L) {
				W[i].v = L - dis1[W[i].x] - dis2[W[i].y];	flag = true;
			} else {
				if(dis1[W[i].y]+dis2[W[i].x] <= dis2[W[i].y]+dis1[W[i].x]
					&& dis1[W[i].y] + dis2[W[i].y] + 1 <= L) {
					W[i].v = L - dis1[W[i].y] - dis2[W[i].x]; flag = true;
				} else {
					W[i].v = 1000000000000000000;
				}
			}
		}
	}*/
	bool flag = 0;
	memset(dis2,0x3f,sizeof(dis2));
	dis2[S] = 0; In_Q[S] = 1; Q.push(S);
	while(!Q.empty()) {
		int x = Q.front(); Q.pop(); In_Q[x] = false;
		for(int i = line[x];i != 0;i = E[i].next) {
			int p = E[i].to;
			if(E[i].v > 0 && dis2[p] > dis2[x] + E[i].v) {
				dis2[p] = dis2[x] + E[i].v;
				if(!In_Q[p]) {
					Q.push(p); In_Q[p] = true;
				}
			}
			if(E[i].v == 0) {
				if(dis2[x] + dis1[p] + 1 <= L) {
					//printf("!!!%d %d\n",x,p);
					//printf("!!!%lld %lld\n",dis1[p],dis2[x]);
					//printf("!!!%d\n",(i+1)/2);
					W[(i+1)/2].v = L-dis2[x]-dis1[p]; flag = 1;
				} else {
					if(W[(i+1)/2].v == 0) W[(i+1)/2].v = 1000000000000000000;
				}
			}
		}
	}
	if((!flag && dis2[T] != L) || (dis2[T] <= L)) {
		printf("NO\n");
	} else {
        printf("YES\n");
		for(int i = 1;i <= m;++ i) {
			if(W[i].v == 0) W[i].v = 1000000000000000000;
			printf("%d %d %lld\n",W[i].x-1,W[i].y-1,W[i].v);
		}
	}
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define maxm 10010
#define maxn 1010
int n ,m ,S ,T ;
LL  L;
struct node {
    int to,next; LL v; bool fl;
}E[maxm << 1];
int tot = 0,line[maxn];
inline void insert(int x,int y,LL v,bool fl) {
	tot ++; E[tot].to = y; E[tot].next = line[x]; line[x] = tot; E[tot].v = v; E[tot].fl =fl;
	tot ++; E[tot].to = x; E[tot].next = line[y]; line[y] = tot; E[tot].v = v; E[tot].fl = fl;
}
struct line { int x,y; LL v; }W[maxm];
queue <int> Q;
LL   dis1[maxn],dis2[maxn];
bool In_Q[maxn];
inline void spfa(int s,int t,LL  *dis) {
	dis[s] = 0; In_Q[s] = 1; Q.push(s);
	while(!Q.empty()) {
		int x = Q.front(); Q.pop(); In_Q[x] = false;
		for(int i = line[x];i != 0;i = E[i].next) {
			int p = E[i].to;
			if(dis[p] > dis[x] + E[i].v) {
				dis[p] = dis[x] + E[i].v;
				if(!In_Q[p]) {
					Q.push(p); In_Q[p] = true;
				}
			}
		}
	}
}
bool G[1010][1010];
int main() {
    scanf("%d%d%lld%d%d",&n,&m,&L,&S,&T);
	S ++; T ++;
    int x = 0,y = 0; LL v = 0;
	for(int i = 1;i <= m;++ i) {
        scanf("%d%d%lld",&x,&y,&v);
		W[i].x = x+1;
		W[i].y = y+1;
		W[i].v = v;
		if(v != 0) insert(x+1,y+1,v,0);
		else insert(x+1,y+1,1,1);
    }
	memset(dis1,0x3f,sizeof(dis1));
	spfa(T,S,dis1);
	/*for(int i = 1;i <= n;++ i) {
		printf("%d\n",dis1[i]);
	}*/
	/*memset(dis2,0x3f,sizeof(dis2));
	spfa(S,T,dis2);
	for(int i = 1;i <= n;++ i) {
		printf("%d\n",dis2[i]);
	}
	bool flag = 0;
	printf("%lld %lld\n",dis1[2],dis1[5]);
	printf("%lld %lld\n",dis2[2],dis2[5]);
	for(int i = 1;i <= m;++ i) {
		if(W[i].v == 0) {
			if(dis1[W[i].x]+dis2[W[i].y] <= dis2[W[i].x]+dis1[W[i].y]
					&& dis1[W[i].x] + dis2[W[i].y] + 1 <= L) {
				W[i].v = L - dis1[W[i].x] - dis2[W[i].y];	flag = true;
			} else {
				if(dis1[W[i].y]+dis2[W[i].x] <= dis2[W[i].y]+dis1[W[i].x]
					&& dis1[W[i].y] + dis2[W[i].y] + 1 <= L) {
					W[i].v = L - dis1[W[i].y] - dis2[W[i].x]; flag = true;
				} else {
					W[i].v = 1000000000000000000;
				}
			}
		}
	}*/
	memset(dis2,0x3f,sizeof(dis2));
	dis2[S] = 0; In_Q[S] = 1; Q.push(S);
	while(!Q.empty()) {
		int x = Q.front(); Q.pop(); In_Q[x] = false;
		for(int i = line[x];i != 0;i = E[i].next) {
			int p = E[i].to;
			if(E[i].fl == 1 && dis2[x]+dis1[p] < L) E[i].v = L-dis2[x]-dis1[p];
			if(dis2[p] > dis2[x] + E[i].v) {
				dis2[p] = dis2[x] + E[i].v;
				if(!In_Q[p]) {
					Q.push(p); In_Q[p] = true;
				}
			}
		}
	}
	if(dis2[T] != L) {
		printf("NO\n");
	} else {
        printf("YES\n");
		for(int i = 1;i <= m;++ i) {
			printf("%d %d %lld\n",W[i].x-1,W[i].y-1,E[i*2-1].v);
		}
	}
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define maxm 10010
#define maxn 1010
int n ,m ,S ,T ;
LL  L;
struct node {
    int to,next,v;
}E[maxm << 1];
int tot = 0,line[maxn];
inline void insert(int x,int y,int v) {
	tot ++; E[tot].to = y; E[tot].next = line[x]; line[x] = tot; E[tot].v = v;
	tot ++; E[tot].to = x; E[tot].next = line[y]; line[y] = tot; E[tot].v = v;
}
struct line { int x,y; LL v; }W[maxm];
queue <int> Q;
int  dis1[maxn],dis2[maxn];
bool In_Q[maxn];
inline void spfa(int s,int t,int *dis) {
	memset(dis,0x3f,sizeof(dis));
	dis[s] = 0; In_Q[s] = 1; Q.push(s);
	while(!Q.empty()) {
		int x = Q.front(); Q.pop(); In_Q[x] = false;
		for(int i = line[x];i != 0;i = E[i].next) {
			int p = E[i].to;
			if(dis[p] > dis[x] + E[i].v && E[i].v > 0) {
				dis[p] = dis[x] + E[i].v;
				if(!In_Q[p]) {
					Q.push(p); In_Q[p] = true;
				}
			}
		}
	}
}
bool G[1010][1010];
int main() {
    scanf("%d%d%lld%d%d",&n,&m,&L,&S,&T);
	S ++; T ++;
    int x = 0,y = 0,v = 0;
	for(int i = 1;i <= m;++ i) {
        scanf("%d%d%d",&x,&y,&v);
		W[i].x = x+1;
		W[i].y = y+1;
		W[i].v = v;
		if(v != 0) insert(x+1,y+1,v);
		else insert(x+1,y+1,1);
    }
	spfa(T,S,dis1);
	for(int i = 1;i <= m;++ i) {
		if(W[i].v == 0) E[i*2-1].v = E[i*2].v = 0;
	}
	bool flag = 0;
	memset(dis2,0x3f,sizeof(dis2));
	dis2[S] = 0; In_Q[S] = 1; Q.push(S);
	while(!Q.empty()) {
		int x = Q.front(); Q.pop(); In_Q[x] = false;
		for(int i = x;i != 0;i = E[i].next) {
			int p = E[i].to;
			if(E[i].v > 0 && dis2[p] > dis2[x] + E[i].v) {
				dis2[p] = dis2[x] + E[i].v;
				if(!In_Q[p]) {
					Q.push(p); In_Q[p] = true;
				}
			}
			if(E[i].v == 0) {
				if(dis2[x] + dis1[p] + 1 <= L) {
					W[(i+1)/2].v = L-dis2[x]-dis1[p]; flag = 1;
				} else {
					W[(i+1)/2].v = 1000000000000000000;
				}
			}
		}
	}
	if(!flag && dis2[T] != L) {
		printf("NO\n");
	} else {
		for(int i = 1;i <= m;++ i) {
			if(W[i].v == 0) W[i].v = 1000000000000000000;
			printf("%d %d %lld\n",W[i].x-1,W[i].y-1,W[i].v);
		}
	}
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define maxm 10010
#define maxn 1010
int n ,m ,S ,T ;
LL  L;
struct node {
    int to,next; LL v;
}E[maxm << 1];
int tot = 0,line[maxn];
inline void insert(int x,int y,LL v) {
	tot ++; E[tot].to = y; E[tot].next = line[x]; line[x] = tot; E[tot].v = v;
	tot ++; E[tot].to = x; E[tot].next = line[y]; line[y] = tot; E[tot].v = v;
}
struct line { int x,y; LL v; }W[maxm];
queue <int> Q;
LL   dis1[maxn],dis2[maxn];
bool In_Q[maxn];
inline void spfa(int s,int t,LL  *dis) {
	dis[s] = 0; In_Q[s] = 1; Q.push(s);
	while(!Q.empty()) {
		int x = Q.front(); Q.pop(); In_Q[x] = false;
		for(int i = line[x];i != 0;i = E[i].next) {
			int p = E[i].to;
			if(dis[p] > dis[x] + E[i].v && E[i].v > 0) {
				dis[p] = dis[x] + E[i].v;
				if(!In_Q[p]) {
					Q.push(p); In_Q[p] = true;
				}
			}
		}
	}
}
bool G[1010][1010];
int main() {
    scanf("%d%d%lld%d%d",&n,&m,&L,&S,&T);
	S ++; T ++;
    int x = 0,y = 0; LL v = 0;
	for(int i = 1;i <= m;++ i) {
        scanf("%d%d%lld",&x,&y,&v);
		W[i].x = x+1;
		W[i].y = y+1;
		W[i].v = v;
		if(v != 0) insert(x+1,y+1,v);
		else insert(x+1,y+1,1);
    }
	memset(dis1,0x3f,sizeof(dis1));
	spfa(T,S,dis1);
	/*for(int i = 1;i <= n;++ i) {
		printf("%d\n",dis1[i]);
	}*/
	for(int i = 1;i <= m;++ i) {
		if(W[i].v == 0) E[i*2-1].v = E[i*2].v = 0;
	}
	/*memset(dis2,0x3f,sizeof(dis2));
	spfa(S,T,dis2);
	for(int i = 1;i <= n;++ i) {
		printf("%d\n",dis2[i]);
	}
	bool flag = 0;
	printf("%lld %lld\n",dis1[2],dis1[5]);
	printf("%lld %lld\n",dis2[2],dis2[5]);
	for(int i = 1;i <= m;++ i) {
		if(W[i].v == 0) {
			if(dis1[W[i].x]+dis2[W[i].y] <= dis2[W[i].x]+dis1[W[i].y]
					&& dis1[W[i].x] + dis2[W[i].y] + 1 <= L) {
				W[i].v = L - dis1[W[i].x] - dis2[W[i].y];	flag = true;
			} else {
				if(dis1[W[i].y]+dis2[W[i].x] <= dis2[W[i].y]+dis1[W[i].x]
					&& dis1[W[i].y] + dis2[W[i].y] + 1 <= L) {
					W[i].v = L - dis1[W[i].y] - dis2[W[i].x]; flag = true;
				} else {
					W[i].v = 1000000000000000000;
				}
			}
		}
	}*/
	bool flag = 0;
	memset(dis2,0x3f,sizeof(dis2));
	dis2[S] = 0; In_Q[S] = 1; Q.push(S);
	while(!Q.empty()) {
		int x = Q.front(); Q.pop(); In_Q[x] = false;
		for(int i = line[x];i != 0;i = E[i].next) {
			int p = E[i].to;
			if(E[i].v > 0 && dis2[p] > dis2[x] + E[i].v) {
				dis2[p] = dis2[x] + E[i].v;
				if(!In_Q[p]) {
					Q.push(p); In_Q[p] = true;
				}
			}
			if(E[i].v == 0) {
				if(dis2[x] + dis1[p] + 1 <= L) {
					//printf("!!!%d %d\n",x,p);
					//printf("!!!%lld %lld\n",dis1[p],dis2[x]);
					//printf("!!!%d\n",(i+1)/2);
					W[(i+1)/2].v = L-dis2[x]-dis1[p]; flag = 1;
				} else {
					if(W[(i+1)/2].v == 0) W[(i+1)/2].v = 1000000000000000000;
				}
			}
		}
	}
	if(!flag && dis2[T] != L) {
		printf("NO\n");
	} else {
		for(int i = 1;i <= m;++ i) {
			if(W[i].v == 0) W[i].v = 1000000000000000000;
			printf("%d %d %lld\n",W[i].x-1,W[i].y-1,W[i].v);
		}
	}
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define maxm 10010
#define maxn 1010
int n ,m ,L ,S ,T ;
struct node {
    int to,next,v;
}E[maxm << 1];
int tot = 0,line[maxn];
inline void insert(int x,int y,int v) {
	tot ++; E[tot].to = y; E[tot].next = line[x]; line[x] = tot; E[tot].v = v;
	tot ++; E[tot].to = x; E[tot].next = line[y]; line[y] = tot; E[tot].v = v;
}
struct line { int x,y,v; }W[maxm];
queue <int> Q;
int  dis[maxn];
bool In_Q[maxn];
inline int spfa(int s,int t) {
	memset(dis,0x3f,sizeof(dis));
	dis[s] = 0; In_Q[s] = 1; Q.push(s);
	while(!Q.empty()) {
		int x = Q.front(); Q.pop(); In_Q[x] = false;
		for(int i = line[x];i != 0;i = E[i].next) {
			int p = E[i].to;
			if(dis[p] > dis[x] + E[i].v && E[i].v > 0) {
				dis[p] = dis[x] + E[i].v;
				if(!In_Q[p]) {
					Q.push(p); In_Q[p] = true;
				}
			}
		}
	}
	return dis[t];
}
bool G[1010][1010];
int main() {
    scanf("%d%d%d%d%d",&n,&m,&L,&S,&T);
	S ++; T ++;
    int x = 0,y = 0,v = 0;
	for(int i = 1;i <= m;++ i) {
        scanf("%d%d%d",&x,&y,&v);
		W[i].x = x+1;
		W[i].y = y+1;
		W[i].v = v;
		if(v != 0) insert(x+1,y+1,v);
    }
	int min_dis = spfa(S,T);
	if(min_dis < L) printf("NO\n");
	else {
		for(int i = 1;i <= m;++ i) {
			if(W[i].v == 0) {
				int len = max(dis[W[i].y],dis[W[i].x]) - min(dis[W[i].y],dis[W[i].x]);
				if(L < min_dis-len+1) {
					W[i].v = 1;
					insert(W[i].x,W[i].y,1);
				} else {
					W[i].v = L-min_dis+len;
					insert(W[i].x,W[i].y,L-min_dis+len);
				}
				min_dis = spfa(S,T);
				if(L == min_dis) break;
			}
		}
		if(L == min_dis) {
			printf("YES\n");
			for(int i = 1;i <= m;++ i) {
				printf("%d %d %d\n",W[i].x-1,W[i].y-1,W[i].v);
			}
		}
		else {
			printf("NO\n");
		}
	}
    return 0;
}
/////


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define maxm 10010
#define maxn 1010
int n ,m ,S ,T ;
LL  L;
struct node {
    int to,next; LL v;
}E[maxm << 1];
int tot = 0,line[maxn];
inline void insert(int x,int y,LL v) {
	tot ++; E[tot].to = y; E[tot].next = line[x]; line[x] = tot; E[tot].v = v;
	tot ++; E[tot].to = x; E[tot].next = line[y]; line[y] = tot; E[tot].v = v;
}
struct line { int x,y; LL v; }W[maxm];
queue <int> Q;
LL   dis1[maxn],dis2[maxn];
bool In_Q[maxn];
inline void spfa(int s,int t,LL  *dis) {
	dis[s] = 0; In_Q[s] = 1; Q.push(s);
	while(!Q.empty()) {
		int x = Q.front(); Q.pop(); In_Q[x] = false;
		for(int i = line[x];i != 0;i = E[i].next) {
			int p = E[i].to;
			if(dis[p] > dis[x] + E[i].v && E[i].v > 0) {
				dis[p] = dis[x] + E[i].v;
				if(!In_Q[p]) {
					Q.push(p); In_Q[p] = true;
				}
			}
		}
	}
}
bool G[1010][1010];
int main() {
    scanf("%d%d%lld%d%d",&n,&m,&L,&S,&T);
	S ++; T ++;
    int x = 0,y = 0; LL v = 0;
	for(int i = 1;i <= m;++ i) {
        scanf("%d%d%lld",&x,&y,&v);
		W[i].x = x+1;
		W[i].y = y+1;
		W[i].v = v;
		if(v != 0) insert(x+1,y+1,v);
		else insert(x+1,y+1,1);
    }
	memset(dis1,0x3f,sizeof(dis1));
	spfa(T,S,dis1);
	/*for(int i = 1;i <= n;++ i) {
		printf("%d\n",dis1[i]);
	}*/
	for(int i = 1;i <= m;++ i) {
		if(W[i].v == 0) E[i*2-1].v = E[i*2].v = 0;
	}
	/*memset(dis2,0x3f,sizeof(dis2));
	spfa(S,T,dis2);
	for(int i = 1;i <= n;++ i) {
		printf("%d\n",dis2[i]);
	}
	bool flag = 0;
	printf("%lld %lld\n",dis1[2],dis1[5]);
	printf("%lld %lld\n",dis2[2],dis2[5]);
	for(int i = 1;i <= m;++ i) {
		if(W[i].v == 0) {
			if(dis1[W[i].x]+dis2[W[i].y] <= dis2[W[i].x]+dis1[W[i].y]
					&& dis1[W[i].x] + dis2[W[i].y] + 1 <= L) {
				W[i].v = L - dis1[W[i].x] - dis2[W[i].y];	flag = true;
			} else {
				if(dis1[W[i].y]+dis2[W[i].x] <= dis2[W[i].y]+dis1[W[i].x]
					&& dis1[W[i].y] + dis2[W[i].y] + 1 <= L) {
					W[i].v = L - dis1[W[i].y] - dis2[W[i].x]; flag = true;
				} else {
					W[i].v = 1000000000000000000;
				}
			}
		}
	}*/
	bool flag = 0;
	memset(dis2,0x3f,sizeof(dis2));
	dis2[S] = 0; In_Q[S] = 1; Q.push(S);
	while(!Q.empty()) {
		int x = Q.front(); Q.pop(); In_Q[x] = false;
		for(int i = line[x];i != 0;i = E[i].next) {
			int p = E[i].to;
			if(E[i].v > 0 && dis2[p] > dis2[x] + E[i].v) {
				dis2[p] = dis2[x] + E[i].v;
				if(!In_Q[p]) {
					Q.push(p); In_Q[p] = true;
				}
			}
			if(E[i].v == 0) {
				if(dis2[x] + dis1[p] + 1 <= L) {
					//printf("!!!%d %d\n",x,p);
					//printf("!!!%lld %lld\n",dis1[p],dis2[x]);
					//printf("!!!%d\n",(i+1)/2);
					W[(i+1)/2].v = L-dis2[x]-dis1[p]; flag = 1;
				} else {
					if(W[(i+1)/2].v == 0) W[(i+1)/2].v = 1000000000000000000;
				}
			}
		}
	}
	if(!flag && dis2[T] != L) {
		printf("NO\n");
	} else {
		for(int i = 1;i <= m;++ i) {
            printf("YES\n");
			if(W[i].v == 0) W[i].v = 1000000000000000000;
			printf("%d %d %lld\n",W[i].x-1,W[i].y-1,W[i].v);
		}
	}
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define maxm 10010
#define maxn 1010
int n ,m ,S ,T ;
LL  L;
struct node {
    int to,next; LL v; bool fl;
}E[maxm << 1];
int tot = 0,line[maxn];
inline void insert(int x,int y,LL v,bool fl) {
	tot ++; E[tot].to = y; E[tot].next = line[x]; line[x] = tot; E[tot].v = v; E[tot].fl =fl;
	tot ++; E[tot].to = x; E[tot].next = line[y]; line[y] = tot; E[tot].v = v; E[tot].fl = fl;
}
struct line { int x,y; LL v; }W[maxm];
queue <int> Q;
LL   dis1[maxn],dis2[maxn];
bool In_Q[maxn];
inline void spfa(int s,int t,LL  *dis) {
	dis[s] = 0; In_Q[s] = 1; Q.push(s);
	while(!Q.empty()) {
		int x = Q.front(); Q.pop(); In_Q[x] = false;
		for(int i = line[x];i != 0;i = E[i].next) {
			int p = E[i].to;
			if(dis[p] > dis[x] + E[i].v) {
				dis[p] = dis[x] + E[i].v;
				if(!In_Q[p]) {
					Q.push(p); In_Q[p] = true;
				}
			}
		}
	}
}
bool G[1010][1010];
int main() {
    scanf("%d%d%lld%d%d",&n,&m,&L,&S,&T);
	S ++; T ++;
    int x = 0,y = 0; LL v = 0;
	for(int i = 1;i <= m;++ i) {
        scanf("%d%d%lld",&x,&y,&v);
		W[i].x = x+1;
		W[i].y = y+1;
		W[i].v = v;
		if(v != 0) insert(x+1,y+1,v,0);
		else insert(x+1,y+1,1,1);
    }
	memset(dis1,0x3f,sizeof(dis1));
	spfa(T,S,dis1);
	/*for(int i = 1;i <= n;++ i) {
		printf("%d\n",dis1[i]);
	}*/
	/*memset(dis2,0x3f,sizeof(dis2));
	spfa(S,T,dis2);
	for(int i = 1;i <= n;++ i) {
		printf("%d\n",dis2[i]);
	}
	bool flag = 0;
	printf("%lld %lld\n",dis1[2],dis1[5]);
	printf("%lld %lld\n",dis2[2],dis2[5]);
	for(int i = 1;i <= m;++ i) {
		if(W[i].v == 0) {
			if(dis1[W[i].x]+dis2[W[i].y] <= dis2[W[i].x]+dis1[W[i].y]
					&& dis1[W[i].x] + dis2[W[i].y] + 1 <= L) {
				W[i].v = L - dis1[W[i].x] - dis2[W[i].y];	flag = true;
			} else {
				if(dis1[W[i].y]+dis2[W[i].x] <= dis2[W[i].y]+dis1[W[i].x]
					&& dis1[W[i].y] + dis2[W[i].y] + 1 <= L) {
					W[i].v = L - dis1[W[i].y] - dis2[W[i].x]; flag = true;
				} else {
					W[i].v = 1000000000000000000;
				}
			}
		}
	}*/
	memset(dis2,0x3f,sizeof(dis2));
	dis2[S] = 0; In_Q[S] = 1; Q.push(S);
	while(!Q.empty()) {
		int x = Q.front(); Q.pop(); In_Q[x] = false;
		for(int i = line[x];i != 0;i = E[i].next) {
			int p = E[i].to;
			if(E[i].fl == 1 && dis2[x]+dis1[p] < L) E[i].v = L-dis2[x]-dis1[p];
			if(dis2[p] > dis2[x] + E[i].v) {
				dis2[p] = dis2[x] + E[i].v;
				if(!In_Q[p]) {
					Q.push(p); In_Q[p] = true;
				}
			}
		}
	}
	if(dis2[T] != L) {
		printf("NO\n");
	} else {
        printf("YES\n");
		for(int i = 1;i <= m;++ i) {
			printf("%d %d %lld\n",W[i].x-1,W[i].y-1,max(E[i*2].v,E[i*2-1].v));
		}
	}
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define maxm 10010
#define maxn 1010
int n ,m ,S ,T ;
LL  L;
struct node {
    int to,next; LL v;
}E[maxm << 1];
int tot = 0,line[maxn];
inline void insert(int x,int y,LL v) {
	tot ++; E[tot].to = y; E[tot].next = line[x]; line[x] = tot; E[tot].v = v;
	tot ++; E[tot].to = x; E[tot].next = line[y]; line[y] = tot; E[tot].v = v;
}
struct line { int x,y; LL v; }W[maxm];
queue <int> Q;
LL   dis1[maxn],dis2[maxn];
bool In_Q[maxn];
inline void spfa(int s,int t,LL  *dis) {
	dis[s] = 0; In_Q[s] = 1; Q.push(s);
	while(!Q.empty()) {
		int x = Q.front(); Q.pop(); In_Q[x] = false;
		for(int i = line[x];i != 0;i = E[i].next) {
			int p = E[i].to;
			if(dis[p] > dis[x] + E[i].v && E[i].v > 0) {
				dis[p] = dis[x] + E[i].v;
				if(!In_Q[p]) {
					Q.push(p); In_Q[p] = true;
				}
			}
		}
	}
}
bool G[1010][1010];
int main() {
    scanf("%d%d%lld%d%d",&n,&m,&L,&S,&T);
	S ++; T ++;
    int x = 0,y = 0; LL v = 0;
	for(int i = 1;i <= m;++ i) {
        scanf("%d%d%lld",&x,&y,&v);
		W[i].x = x+1;
		W[i].y = y+1;
		W[i].v = v;
		if(v != 0) insert(x+1,y+1,v);
		else insert(x+1,y+1,1);
    }
	memset(dis1,0x3f,sizeof(dis1));
	spfa(T,S,dis1);
	/*for(int i = 1;i <= n;++ i) {
		printf("%d\n",dis1[i]);
	}*/
	for(int i = 1;i <= m;++ i) {
		if(W[i].v == 0) E[i*2-1].v = E[i*2].v = 0;
	}
	/*memset(dis2,0x3f,sizeof(dis2));
	spfa(S,T,dis2);
	for(int i = 1;i <= n;++ i) {
		printf("%d\n",dis2[i]);
	}
	bool flag = 0;
	printf("%lld %lld\n",dis1[2],dis1[5]);
	printf("%lld %lld\n",dis2[2],dis2[5]);
	for(int i = 1;i <= m;++ i) {
		if(W[i].v == 0) {
			if(dis1[W[i].x]+dis2[W[i].y] <= dis2[W[i].x]+dis1[W[i].y]
					&& dis1[W[i].x] + dis2[W[i].y] + 1 <= L) {
				W[i].v = L - dis1[W[i].x] - dis2[W[i].y];	flag = true;
			} else {
				if(dis1[W[i].y]+dis2[W[i].x] <= dis2[W[i].y]+dis1[W[i].x]
					&& dis1[W[i].y] + dis2[W[i].y] + 1 <= L) {
					W[i].v = L - dis1[W[i].y] - dis2[W[i].x]; flag = true;
				} else {
					W[i].v = 1000000000000000000;
				}
			}
		}
	}*/
	bool flag = 0;
	memset(dis2,0x3f,sizeof(dis2));
	dis2[S] = 0; In_Q[S] = 1; Q.push(S);
	while(!Q.empty()) {
		int x = Q.front(); Q.pop(); In_Q[x] = false;
		for(int i = line[x];i != 0;i = E[i].next) {
			int p = E[i].to;
			if(E[i].v > 0 && dis2[p] > dis2[x] + E[i].v) {
				dis2[p] = dis2[x] + E[i].v;
				if(!In_Q[p]) {
					Q.push(p); In_Q[p] = true;
				}
			}
			if(E[i].v == 0) {
				if(dis2[x] + dis1[p] + 1 <= L) {
					//printf("!!!%d %d\n",x,p);
					//printf("!!!%lld %lld\n",dis1[p],dis2[x]);
					//printf("!!!%d\n",(i+1)/2);
					W[(i+1)/2].v = L-dis2[x]-dis1[p]; flag = 1;
				} else {
					if(W[(i+1)/2].v == 0) W[(i+1)/2].v = 1000000000000000000;
				}
			}
		}
	}
	if(!flag && dis2[T] != L) {
		printf("NO\n");
	} else {
        printf("YES\n");
		for(int i = 1;i <= m;++ i) {
			if(W[i].v == 0) W[i].v = 1000000000000000000;
			printf("%d %d %lld\n",W[i].x-1,W[i].y-1,W[i].v);
		}
	}
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define maxm 10010
#define maxn 1010
int n ,m ,L ,S ,T ;
struct node {
    int to,next,v;
}E[maxm << 1];
int tot = 0,line[maxn];
inline void insert(int x,int y,int v) {
	tot ++; E[tot].to = y; E[tot].next = line[x]; line[x] = tot; E[tot].v = v;
	tot ++; E[tot].to = x; E[tot].next = line[y]; line[y] = tot; E[tot].v = v;
}
struct line { int x,y,v; }W[maxm];
queue <int> Q;
int  dis[maxn];
bool In_Q[maxn];
inline int spfa(int s,int t) {
	memset(dis,0x3f,sizeof(dis));
	dis[s] = 0; In_Q[s] = 1; Q.push(s);
	while(!Q.empty()) {
		int x = Q.front(); Q.pop(); In_Q[x] = false;
		for(int i = line[x];i != 0;i = E[i].next) {
			int p = E[i].to;
			if(dis[p] > dis[x] + E[i].v && E[i].v > 0) {
				dis[p] = dis[x] + E[i].v;
				if(!In_Q[p]) {
					Q.push(p); In_Q[p] = true;
				}
			}
		}
	}
	return dis[t];
}
bool G[1010][1010];
int main() {
    scanf("%d%d%d%d%d",&n,&m,&L,&S,&T);
	S ++; T ++;
    int x = 0,y = 0,v = 0;
	for(int i = 1;i <= m;++ i) {
        scanf("%d%d%d",&x,&y,&v);
		W[i].x = x+1;
		W[i].y = y+1;
		W[i].v = v;
		if(v != 0) insert(x+1,y+1,v);
    }
	int min_dis = spfa(S,T);
	if(min_dis < L) printf("NO\n");
	else {
		for(int i = 1;i <= m;++ i) {
			if(W[i].v == 0) {
				if(L != min_dis) {
				int len = max(dis[W[i].y],dis[W[i].x]) - min(dis[W[i].y],dis[W[i].x]);
				if(L < min_dis-len+1) {
					W[i].v = 1;
					insert(W[i].x,W[i].y,1);
				} else {
					W[i].v = L-min_dis+len;
					insert(W[i].x,W[i].y,L-min_dis+len);
				}
				min_dis = spfa(S,T);
				if(L == min_dis) break;
				} else {
					W[i].v = 1000000000;
				}
			}
		}
		if(L == min_dis) {
			printf("YES\n");
			for(int i = 1;i <= m;++ i) {
				printf("%d %d %d\n",W[i].x-1,W[i].y-1,W[i].v);
			}
		}
		else {
			printf("NO\n");
		}
	}
    return 0;
}
/////


#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define MX 1009
#define ff first
#define ss second
#define pb(a) push_back(a)
using namespace std;

struct data
{
    ll u,v,w;
    bool operator < (const data& p) const
    {
        return w>p.w;
    }
};

struct data1
{
    ll u,v,w;
};

vector<ll>graph[1005];
ll cost[1005][1005],parrent[1005],dis[1009],n;
bool errase[1005][1005],taken[1005][1005];
priority_queue<data>pq;
data1 road[1005];

ll dijkstra(ll src, ll des)
{
    ll u,v,w,i;
    dis[src]=0;
    data D;
    D.u=src;
    D.w=dis[src];
    pq.push(D);
    while(!pq.empty())
    {
        D=pq.top();
        pq.pop();
        u=D.u;
        w=D.w;
//        cout<<u<<" "<<w<<endl;
        for(i=0;i<graph[u].size();i++)
        {
            v=graph[u][i];
            if(dis[v]>w+cost[u][v])
            {
                dis[v]=w+cost[u][v];
                parrent[v]=u;
                D.u=v;
                D.w=dis[v];
                //cout<<D.u<<"  "<<D.w<<endl;
                pq.push(D);
            }
        }
    }
    return dis[des];
}

ll dijkstra1(ll src, ll des)
{
    ll u,v,w,i;
    for(i=0;i<=n;i++)
        {
            dis[i]=powl(10,18);
        }
    dis[src]=0;
    data D;
    D.u=src;
    D.w=dis[src];
    pq.push(D);
    while(!pq.empty())
    {
        D=pq.top();
        pq.pop();
        u=D.u;
        w=D.w;
//        cout<<u<<" "<<w<<endl;
        for(i=0;i<graph[u].size();i++)
        {
            v=graph[u][i];
            if(dis[v]>w+cost[u][v] && !errase[u][v])
            {
                dis[v]=w+cost[u][v];
//                parrent[v]=u;
                D.u=v;
                D.w=dis[v];
                //cout<<D.u<<"  "<<D.w<<endl;
                pq.push(D);
            }
        }
    }
    return dis[des];
}

int main()
{
    ll t,T,m,i,j,k,ans,a,b,c,x,y,vv,l,r,l2,r2,st,nd,u,v,w,err;
    while(scanf("%lld %lld %lld %lld %lld",&n,&m,&l,&st,&nd)!=EOF)
    {
        ans=0;
        memset(errase,false,sizeof errase);
        memset(taken,false,sizeof taken);
        for(i=0;i<=n;i++)
        {
            dis[i]=powl(10,18);
            graph[i].clear();
        }
        for(i=1;i<=m;i++)
        {
            scanf("%lld %lld %lld",&u,&v,&w);
            graph[u].push_back(v);
            graph[v].push_back(u);
            if(w==0)
            {
                errase[u][v]=true;
                errase[v][u]=true;
                w=1;
            }
            cost[u][v]=w;
            cost[v][u]=w;

            road[i].u=u;
            road[i].v=v;
            road[i].w=w;
        }
        ans=dijkstra(st,nd);
//        cout<<dijkstra1(st,nd)<<endl;
        if(ans>l || dijkstra1(st,nd)<l)
            printf("NO\n");
        else if(ans==l)
        {
            printf("YES\n");
            for(i=1;i<=m;i++)
                printf("%lld %lld %lld\n",road[i].u,road[i].v,road[i].w);
        }
        else
        {
            v=nd;
            err=0;
            while(v!=st)
            {
                u=parrent[v];
                if(errase[u][v]==true)
                {
                    err++;
                    taken[u][v]=true;
                    taken[v][u]=true;
                }
                v=u;
            }
            if(err==0)
                printf("NO\n");
            else
            {
                printf("YES\n");
                for(i=1;i<=m;i++)
                {
                    if(taken[road[i].u][road[i].v] && err>0)
                    {
                        road[i].w+=(l-ans);
                        err=0;
                    }
                    if(!taken[road[i].u][road[i].v] && errase[road[i].u][road[i].v])
                        road[i].w=powl(10,18);
                    printf("%lld %lld %lld\n",road[i].u,road[i].v,road[i].w);
                }
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define MX 1009
#define ff first
#define ss second
#define pb(a) push_back(a)
using namespace std;

struct data
{
    ll u,v,w;
    bool operator < (const data& p) const
    {
        return w>p.w;
    }
};

struct data1
{
    ll u,v,w;
};

vector<ll>graph[1005];
ll cost[1005][1005],parrent[1005],dis[1009],n;
bool errase[1005][1005],taken[1005][1005];
priority_queue<data>pq;
data1 road[10005];

ll dijkstra(ll src, ll des,ll ok)
{
    ll u,v,w,i;
    for(i=0; i<=n; i++)
    {
        dis[i]=powl(10,18);
    }
    dis[src]=0;
    data D;
    D.u=src;
    D.w=dis[src];
    pq.push(D);
    while(!pq.empty())
    {
        D=pq.top();
        pq.pop();
        u=D.u;
        w=D.w;
//        cout<<u<<" "<<w<<endl;
        for(i=0; i<graph[u].size(); i++)
        {
            v=graph[u][i];
            if(ok==0 && errase[u][v]==true)
                continue;
            if(dis[v]>w+cost[u][v])
            {
                dis[v]=w+cost[u][v];
                parrent[v]=u;
                D.u=v;
                D.w=dis[v];
                //cout<<D.u<<"  "<<D.w<<endl;
                pq.push(D);
            }
        }
    }
    return dis[des];
}

int main()
{
    ll t,T,m,i,j,k,ans,a,b,c,x,y,vv,l,r,l2,r2,st,nd,u,v,w,err;
    while(scanf("%lld %lld %lld %lld %lld",&n,&m,&l,&st,&nd)!=EOF)
    {
        ans=0;
        memset(errase,false,sizeof errase);
        memset(taken,false,sizeof taken);
        for(i=0; i<=n; i++)
        {
            dis[i]=powl(10,18);
            graph[i].clear();
        }
        for(i=1; i<=m; i++)
        {
            scanf("%lld %lld %lld",&u,&v,&w);
            graph[u].push_back(v);
            graph[v].push_back(u);
            if(w==0)
            {
                errase[u][v]=true;
                errase[v][u]=true;
                w=1;
            }
            cost[u][v]=w;
            cost[v][u]=w;

            road[i].u=u;
            road[i].v=v;
            road[i].w=w;
        }
        ans=dijkstra(st,nd,1);
//        cout<<ans<<endl;
        if(ans>l || dijkstra(st,nd,0)<l)
            printf("NO\n");
        else if(ans==l)
        {
            printf("YES\n");
            for(i=1; i<=m; i++)
                printf("%lld %lld %lld\n",road[i].u,road[i].v,road[i].w);
        }
        else
        {
            while(ans<l)
            {
                memset(taken,false,sizeof taken);
                v=nd;
                while(v!=st)
                {
                    u=parrent[v];
                    if(errase[u][v]==true)
                    {
                        taken[u][v]=true;
                        taken[v][u]=true;
                    }
                    v=u;
                }
                for(i=1; i<=m; i++)
                {
                    if(!taken[road[i].u][road[i].v] && errase[u][v]==true)
                    {
                        road[i].w=powl(10,15);
                        cost[road[i].u][road[i].v]=powl(10,15);
                        cost[road[i].v][road[i].u]=powl(10,15);
                    }
                }
                for(i=1; i<=m; i++)
                {
                    if(taken[road[i].u][road[i].v])
                    {
                        road[i].w+=(l-ans);
                        cost[road[i].u][road[i].v]+=(l-ans);
                        cost[road[i].v][road[i].u]+=(l-ans);
                        break;
                    }
                }
                ans=dijkstra(st,nd,1);
            }
            printf("YES\n");
            for(i=1; i<=m; i++)
            {
                printf("%lld %lld %lld\n",road[i].u,road[i].v,road[i].w);
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define MX 1009
#define ff first
#define ss second
#define pb(a) push_back(a)
using namespace std;

struct data
{
    ll u,v,w;
    bool operator < (const data& p) const
    {
        return w>p.w;
    }
};

struct data1
{
    ll u,v,w;
};

vector<ll>graph[1005];
ll cost[1005][1005],parrent[1005],dis[1009],n;
bool errase[1005][1005],taken[1005][1005];
priority_queue<data>pq;
data1 road[10005];

ll dijkstra(ll src, ll des,ll ok)
{
    ll u,v,w,i;
    for(i=0; i<=n; i++)
    {
        dis[i]=powl(10,18);
    }
    dis[src]=0;
    data D;
    D.u=src;
    D.w=dis[src];
    pq.push(D);
    while(!pq.empty())
    {
        D=pq.top();
        pq.pop();
        u=D.u;
        w=D.w;
//        cout<<u<<" "<<w<<endl;
        for(i=0; i<graph[u].size(); i++)
        {
            v=graph[u][i];
            if(ok==0 && errase[u][v]==true)
                continue;
            if(dis[v]>w+cost[u][v])
            {
                dis[v]=w+cost[u][v];
                parrent[v]=u;
                D.u=v;
                D.w=dis[v];
                //cout<<D.u<<"  "<<D.w<<endl;
                pq.push(D);
            }
        }
    }
    return dis[des];
}

int main()
{
    ll t,T,m,i,j,k,ans,a,b,c,x,y,vv,l,r,l2,r2,st,nd,u,v,w,err;
    while(scanf("%lld %lld %lld %lld %lld",&n,&m,&l,&st,&nd)!=EOF)
    {
        ans=0;
        memset(errase,false,sizeof errase);
        for(i=0; i<=n; i++)
        {
            dis[i]=powl(10,18);
            graph[i].clear();
        }
        for(i=1; i<=m; i++)
        {
            scanf("%lld %lld %lld",&u,&v,&w);
            graph[u].push_back(v);
            graph[v].push_back(u);
            if(w==0)
            {
                errase[u][v]=true;
                errase[v][u]=true;
                w=1;
            }
            cost[u][v]=w;
            cost[v][u]=w;

            road[i].u=u;
            road[i].v=v;
            road[i].w=w;
        }
        ans=dijkstra(st,nd,1);
//        cout<<ans<<endl;
        if(ans>l || dijkstra(st,nd,0)<l)
            printf("NO\n");
        else if(ans==l)
        {
            printf("YES\n");
            for(i=1; i<=m; i++)
                printf("%lld %lld %lld\n",road[i].u,road[i].v,road[i].w);
        }
        else
        {
            while(ans<l)
            {
                memset(taken,false,sizeof taken);
                v=nd;
                while(v!=st)
                {
                    u=parrent[v];
                    if(errase[u][v]==true)
                    {
                        taken[u][v]=true;
                        taken[v][u]=true;
                    }
                    v=u;
                }
                for(i=1; i<=m; i++)
                {
                    u=road[i].u;
                    v=road[i].v;
                    w=road[i].w;
                    if(taken[u][v]==false && errase[u][v]==true)
                    {
                        road[i].w=powl(10,15);
                        errase[u][v]=false;
                        errase[v][u]=false;
                        cost[u][v]=powl(10,15);
                        cost[v][u]=powl(10,15);
                    }
                }
                for(i=1; i<=m; i++)
                {
                    u=road[i].u;
                    v=road[i].v;
                    w=road[i].w;
                    if(taken[u][v])
                    {
                        road[i].w+=(l-ans);
                        cost[u][v]+=(l-ans);
                        cost[v][u]+=(l-ans);
                        break;
                    }
                }
                ans=dijkstra(st,nd,1);
            }
            printf("YES\n");
            for(i=1; i<=m; i++)
            {
                printf("%lld %lld %lld\n",road[i].u,road[i].v,road[i].w);
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define MX 1009
#define ff first
#define ss second
#define pb(a) push_back(a)
using namespace std;

struct data
{
    ll u,v,w;
    bool operator < (const data& p) const
    {
        return w>p.w;
    }
};

struct data1
{
    ll u,v,w;
};

vector<ll>graph[1005];
ll cost[1005][1005],parrent[1005],dis[1009],n;
bool errase[1005][1005],taken[1005][1005];
priority_queue<data>pq;
data1 road[1005];

ll dijkstra(ll src, ll des)
{
    ll u,v,w,i;
    dis[src]=0;
    data D;
    D.u=src;
    D.w=dis[src];
    pq.push(D);
    while(!pq.empty())
    {
        D=pq.top();
        pq.pop();
        u=D.u;
        w=D.w;
//        cout<<u<<" "<<w<<endl;
        for(i=0;i<graph[u].size();i++)
        {
            v=graph[u][i];
            if(dis[v]>w+cost[u][v])
            {
                dis[v]=w+cost[u][v];
                parrent[v]=u;
                D.u=v;
                D.w=dis[v];
                //cout<<D.u<<"  "<<D.w<<endl;
                pq.push(D);
            }
        }
    }
    return dis[des];
}

ll dijkstra1(ll src, ll des)
{
    ll u,v,w,i;
    for(i=0;i<=n;i++)
        {
            dis[i]=powl(10,18);
        }
    dis[src]=0;
    data D;
    D.u=src;
    D.w=dis[src];
    pq.push(D);
    while(!pq.empty())
    {
        D=pq.top();
        pq.pop();
        u=D.u;
        w=D.w;
//        cout<<u<<" "<<w<<endl;
        for(i=0;i<graph[u].size();i++)
        {
            v=graph[u][i];
            if(dis[v]>w+cost[u][v] && !errase[u][v])
            {
                dis[v]=w+cost[u][v];
//                parrent[v]=u;
                D.u=v;
                D.w=dis[v];
                //cout<<D.u<<"  "<<D.w<<endl;
                pq.push(D);
            }
        }
    }
    return dis[des];
}

int main()
{
    ll t,T,m,i,j,k,ans,a,b,c,x,y,vv,l,r,l2,r2,st,nd,u,v,w,err;
    while(scanf("%lld %lld %lld %lld %lld",&n,&m,&l,&st,&nd)!=EOF)
    {
        ans=0;
        memset(errase,false,sizeof errase);
        memset(taken,false,sizeof taken);
        for(i=0;i<=n;i++)
        {
            dis[i]=powl(10,18);
            graph[i].clear();
        }
        for(i=1;i<=m;i++)
        {
            scanf("%lld %lld %lld",&u,&v,&w);
            graph[u].push_back(v);
            graph[v].push_back(u);
            if(w==0)
            {
                errase[u][v]=true;
                errase[v][u]=true;
                w=1;
            }
            cost[u][v]=w;
            cost[v][u]=w;

            road[i].u=u;
            road[i].v=v;
            road[i].w=w;
        }
        ans=dijkstra(st,nd);
//        cout<<dijkstra1(st,nd)<<endl;
        if(ans>l || dijkstra1(st,nd)<l)
            printf("NO\n");
        else if(ans==l)
        {
            printf("YES\n");
            for(i=1;i<=m;i++)
                printf("%lld %lld %lld",road[i].u,road[i].v,road[i].w);
        }
        else
        {
            v=nd;
            err=0;
            while(v!=st)
            {
                u=parrent[v];
                if(errase[u][v]==true)
                {
                    err++;
                    taken[u][v]=true;
                    taken[v][u]=true;
                }
                v=u;
            }
            if(err==0)
                printf("NO\n");
            else
            {
                printf("YES\n");
                for(i=1;i<=m;i++)
                {
                    if(taken[road[i].u][road[i].v] && err>0)
                    {
                        road[i].w+=(l-ans);
                        err=0;
                    }
                    printf("%lld %lld %lld\n",road[i].u,road[i].v,road[i].w);
                }
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define MX 1009
#define ff first
#define ss second
#define pb(a) push_back(a)
using namespace std;

struct data
{
    ll u,v,w;
    bool operator < (const data& p) const
    {
        return w>p.w;
    }
};

struct data1
{
    ll u,v,w;
};

vector<ll>graph[1005];
ll cost[1005][1005],parrent[1005],dis[1009];
bool errase[1005][1005],taken[1005][1005];
priority_queue<data>pq;
data1 road[1005];

ll dijkstra(ll src, ll des)
{
    ll u,v,w,i;
    dis[src]=0;
    data D;
    D.u=src;
    D.w=dis[src];
    pq.push(D);
    while(!pq.empty())
    {
        D=pq.top();
        pq.pop();
        u=D.u;
        w=D.w;
//        cout<<u<<" "<<w<<endl;
        for(i=0;i<graph[u].size();i++)
        {
            v=graph[u][i];
            if(dis[v]>w+cost[u][v])
            {
                dis[v]=w+cost[u][v];
                parrent[v]=u;
                D.u=v;
                D.w=dis[v];
                //cout<<D.u<<"  "<<D.w<<endl;
                pq.push(D);
            }
        }
    }
    return dis[des];
}

int main()
{
    ll t,T,n,m,i,j,k,ans,a,b,c,x,y,vv,l,r,l2,r2,st,nd,u,v,w,err;
    while(scanf("%lld %lld %lld %lld %lld",&n,&m,&l,&st,&nd)!=EOF)
    {
        ans=0;
        memset(errase,false,sizeof errase);
        memset(taken,false,sizeof taken);
        for(i=0;i<=n;i++)
        {
            dis[i]=powl(10,18);
            graph[i].clear();
        }
        for(i=1;i<=m;i++)
        {
            scanf("%lld %lld %lld",&u,&v,&w);
            graph[u].push_back(v);
            graph[v].push_back(u);
            if(w==0)
            {
                errase[u][v]=true;
                errase[v][u]=true;
                w=1;
            }
            cost[u][v]=w;
            cost[v][u]=w;

            road[i].u=u;
            road[i].v=v;
            road[i].w=w;
        }
        ans=dijkstra(st,nd);
//        cout<<ans<<endl;
        if(ans>l)
            printf("NO\n");
        else if(ans==l)
        {
            printf("YES\n");
            for(i=1;i<=m;i++)
                printf("%lld %lld %lld",road[i].u,road[i].v,road[i].w);
        }
        else
        {
            v=nd;
            err=0;
            while(v!=st)
            {
                u=parrent[v];
                if(errase[u][v]==true)
                {
                    err++;
                    taken[u][v]=true;
                    taken[v][u]=true;
                }
                v=u;
            }
            if(err==0)
                printf("NO\n");
            else
            {
                printf("YES\n");
                for(i=1;i<=m;i++)
                {
                    if(taken[road[i].u][road[i].v] && err>0)
                    {
                        road[i].w+=(l-ans);
                        err=0;
                    }
                    printf("%lld %lld %lld\n",road[i].u,road[i].v,road[i].w);
                }
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define MX 1009
#define ff first
#define ss second
#define pb(a) push_back(a)
using namespace std;

struct data
{
    ll u,v,w;
    bool operator < (const data& p) const
    {
        return w>p.w;
    }
};

struct data1
{
    ll u,v,w;
};

vector<ll>graph[1005];
ll cost[1005][1005],parrent[1005],dis[1009],n;
bool errase[1005][1005],taken[1005][1005];
priority_queue<data>pq;
data1 road[1005];

ll dijkstra(ll src, ll des)
{
    ll u,v,w,i;
    dis[src]=0;
    data D;
    D.u=src;
    D.w=dis[src];
    pq.push(D);
    while(!pq.empty())
    {
        D=pq.top();
        pq.pop();
        u=D.u;
        w=D.w;
//        cout<<u<<" "<<w<<endl;
        for(i=0;i<graph[u].size();i++)
        {
            v=graph[u][i];
            if(dis[v]>w+cost[u][v])
            {
                dis[v]=w+cost[u][v];
                parrent[v]=u;
                D.u=v;
                D.w=dis[v];
                //cout<<D.u<<"  "<<D.w<<endl;
                pq.push(D);
            }
        }
    }
    return dis[des];
}

ll dijkstra1(ll src, ll des)
{
    ll u,v,w,i;
    for(i=0;i<=n;i++)
        {
            dis[i]=powl(10,18);
        }
    dis[src]=0;
    data D;
    D.u=src;
    D.w=dis[src];
    pq.push(D);
    while(!pq.empty())
    {
        D=pq.top();
        pq.pop();
        u=D.u;
        w=D.w;
//        cout<<u<<" "<<w<<endl;
        for(i=0;i<graph[u].size();i++)
        {
            v=graph[u][i];
            if(dis[v]>w+cost[u][v] && !errase[u][v])
            {
                dis[v]=w+cost[u][v];
//                parrent[v]=u;
                D.u=v;
                D.w=dis[v];
                //cout<<D.u<<"  "<<D.w<<endl;
                pq.push(D);
            }
        }
    }
    return dis[des];
}

int main()
{
    ll t,T,m,i,j,k,ans,a,b,c,x,y,vv,l,r,l2,r2,st,nd,u,v,w,err;
    while(scanf("%lld %lld %lld %lld %lld",&n,&m,&l,&st,&nd)!=EOF)
    {
        ans=0;
        memset(errase,false,sizeof errase);
        memset(taken,false,sizeof taken);
        for(i=0;i<=n;i++)
        {
            dis[i]=powl(10,18);
            graph[i].clear();
        }
        for(i=1;i<=m;i++)
        {
            scanf("%lld %lld %lld",&u,&v,&w);
            graph[u].push_back(v);
            graph[v].push_back(u);
            if(w==0)
            {
                errase[u][v]=true;
                errase[v][u]=true;
                w=1;
            }
            cost[u][v]=w;
            cost[v][u]=w;

            road[i].u=u;
            road[i].v=v;
            road[i].w=w;
        }
        ans=dijkstra(st,nd);
//        cout<<dijkstra1(st,nd)<<endl;
        if(ans>l || dijkstra1(st,nd)<l)
            printf("NO\n");
        else if(ans==l)
        {
            printf("YES\n");
            for(i=1;i<=m;i++)
                printf("%lld %lld %lld\n",road[i].u,road[i].v,road[i].w);
        }
        else
        {
            v=nd;
            err=0;
            while(v!=st)
            {
                u=parrent[v];
                if(errase[u][v]==true)
                {
                    err++;
                    taken[u][v]=true;
                    taken[v][u]=true;
                }
                v=u;
            }
            if(err==0)
                printf("NO\n");
            else
            {
                printf("YES\n");
                for(i=1;i<=m;i++)
                {
                    if(taken[road[i].u][road[i].v] && err>0)
                    {
                        road[i].w+=(l-ans);
                        err=0;
                    }
                    printf("%lld %lld %lld\n",road[i].u,road[i].v,road[i].w);
                }
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define MX 1009
#define ff first
#define ss second
#define pb(a) push_back(a)
using namespace std;

struct data
{
    ll u,v,w;
    bool operator < (const data& p) const
    {
        return w>p.w;
    }
};

struct data1
{
    ll u,v,w;
};

vector<ll>graph[1005];
ll cost[1005][1005],parrent[1005],dis[1009],n;
bool errase[1005][1005],taken[1005][1005];
priority_queue<data>pq;
data1 road[10005];

ll dijkstra(ll src, ll des,ll ok)
{
    ll u,v,w,i;
    for(i=0; i<=n; i++)
    {
        dis[i]=powl(10,18);
    }
    dis[src]=0;
    data D;
    D.u=src;
    D.w=dis[src];
    pq.push(D);
    while(!pq.empty())
    {
        D=pq.top();
        pq.pop();
        u=D.u;
        w=D.w;
//        cout<<u<<" "<<w<<endl;
        for(i=0; i<graph[u].size(); i++)
        {
            v=graph[u][i];
            if(ok==0 && errase[u][v]==true)
                continue;
            if(dis[v]>w+cost[u][v])
            {
                dis[v]=w+cost[u][v];
                parrent[v]=u;
                D.u=v;
                D.w=dis[v];
                //cout<<D.u<<"  "<<D.w<<endl;
                pq.push(D);
            }
        }
    }
    return dis[des];
}

int main()
{
    ll t,T,m,i,j,k,ans,a,b,c,x,y,vv,l,r,l2,r2,st,nd,u,v,w,err;
    while(scanf("%lld %lld %lld %lld %lld",&n,&m,&l,&st,&nd)!=EOF)
    {
        ans=0;
        memset(errase,false,sizeof errase);
        for(i=0; i<=n; i++)
        {
            dis[i]=powl(10,18);
            graph[i].clear();
        }
        for(i=1; i<=m; i++)
        {
            scanf("%lld %lld %lld",&u,&v,&w);
            graph[u].push_back(v);
            graph[v].push_back(u);
            if(w==0)
            {
                errase[u][v]=true;
                errase[v][u]=true;
                w=1;
            }
            cost[u][v]=w;
            cost[v][u]=w;

            road[i].u=u;
            road[i].v=v;
            road[i].w=w;
        }

        if(dijkstra(st,nd,1)>l || dijkstra(st,nd,0)<l)
            printf("NO\n");

        else if(ans==l)
        {
            printf("YES\n");
            for(i=1; i<=m; i++)
                printf("%lld %lld %lld\n",road[i].u,road[i].v,road[i].w);
        }
        else
        {
            ans=dijkstra(st,nd,1);
            while(ans<l)
            {
                memset(taken,false,sizeof taken);
                v=nd;
                while(v!=st)
                {
                    u=parrent[v];
                    if(errase[u][v]==true)
                    {
                        taken[u][v]=true;
                        taken[v][u]=true;
                    }
                    v=u;
                }
                for(i=1; i<=m; i++)
                {
                    u=road[i].u;
                    v=road[i].v;
                    w=road[i].w;
                    if(taken[u][v]==false && errase[u][v]==true)
                    {
                        road[i].w=powl(10,15);
                        errase[u][v]=false;
                        errase[v][u]=false;
                        cost[u][v]=powl(10,15);
                        cost[v][u]=powl(10,15);
                    }
                }
                for(i=1; i<=m; i++)
                {
                    u=road[i].u;
                    v=road[i].v;
                    w=road[i].w;
                    if(taken[u][v])
                    {
                        road[i].w+=(l-ans);
                        cost[u][v]+=(l-ans);
                        cost[v][u]+=(l-ans);
                        break;
                    }
                }
                ans=dijkstra(st,nd,1);
            }
            printf("YES\n");
            for(i=1; i<=m; i++)
            {
                printf("%lld %lld %lld\n",road[i].u,road[i].v,road[i].w);
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define MX 1009
#define ff first
#define ss second
#define pb(a) push_back(a)
using namespace std;

struct data
{
    ll u,v,w;
    bool operator < (const data& p) const
    {
        return w>p.w;
    }
};

struct data1
{
    ll u,v,w;
};

vector<ll>graph[1005];
ll cost[1005][1005],parrent[1005],dis[1009],n;
bool errase[1005][1005],taken[1005][1005];
priority_queue<data>pq;
data1 road[10005];

ll dijkstra(ll src, ll des,ll ok)
{
    ll u,v,w,i;
    for(i=0; i<=n; i++)
    {
        dis[i]=powl(10,18);
    }
    dis[src]=0;
    data D;
    D.u=src;
    D.w=dis[src];
    pq.push(D);
    while(!pq.empty())
    {
        D=pq.top();
        pq.pop();
        u=D.u;
        w=D.w;
//        cout<<u<<" "<<w<<endl;
        for(i=0; i<graph[u].size(); i++)
        {
            v=graph[u][i];
            if(ok==0 && errase[u][v]==true)
                continue;
            if(dis[v]>w+cost[u][v])
            {
                dis[v]=w+cost[u][v];
                parrent[v]=u;
                D.u=v;
                D.w=dis[v];
                //cout<<D.u<<"  "<<D.w<<endl;
                pq.push(D);
            }
        }
    }
    return dis[des];
}

int main()
{
    ll t,T,m,i,j,k,ans,a,b,c,x,y,vv,l,r,l2,r2,st,nd,u,v,w,err;
    while(scanf("%lld %lld %lld %lld %lld",&n,&m,&l,&st,&nd)!=EOF)
    {
        ans=0;
        memset(errase,false,sizeof errase);
        memset(taken,false,sizeof taken);
        for(i=0; i<=n; i++)
        {
            dis[i]=powl(10,18);
            graph[i].clear();
        }
        for(i=1; i<=m; i++)
        {
            scanf("%lld %lld %lld",&u,&v,&w);
            graph[u].push_back(v);
            graph[v].push_back(u);
            if(w==0)
            {
                errase[u][v]=true;
                errase[v][u]=true;
                w=1;
            }
            cost[u][v]=w;
            cost[v][u]=w;

            road[i].u=u;
            road[i].v=v;
            road[i].w=w;
        }
        ans=dijkstra(st,nd,1);
//        cout<<ans<<endl;
        if(ans>l || dijkstra(st,nd,0)<l)
            printf("NO\n");
        else if(ans==l)
        {
            printf("YES\n");
            for(i=1; i<=m; i++)
                printf("%lld %lld %lld\n",road[i].u,road[i].v,road[i].w);
        }
        else
        {
            while(ans<l)
            {
                memset(taken,false,sizeof taken);
                v=nd;
                while(v!=st)
                {
                    u=parrent[v];
                    if(errase[u][v]==true)
                    {
                        taken[u][v]=true;
                        taken[v][u]=true;
                    }
                    v=u;
                }
                for(i=1; i<=m; i++)
                {
                    if(!taken[road[i].u][road[i].v] && errase[u][v]==true)
                    {
                        road[i].w=powl(10,18);
                        cost[road[i].u][road[i].v]=powl(10,18);
                        cost[road[i].v][road[i].u]=powl(10,18);
                    }
                }
                for(i=1; i<=m; i++)
                {
                    if(taken[road[i].u][road[i].v])
                    {
                        road[i].w+=(l-ans);
                        cost[road[i].u][road[i].v]+=(l-ans);
                        cost[road[i].v][road[i].u]+=(l-ans);
                    }
                }
                ans=dijkstra(st,nd,1);
            }
            printf("YES\n");
            for(i=1; i<=m; i++)
            {
                if(taken[road[i].u][road[i].v] && err>0)
                {
                    road[i].w+=(l-ans);
                    err=0;
                }
                if(!taken[road[i].u][road[i].v] && errase[road[i].u][road[i].v])
                    road[i].w=powl(10,18);
                printf("%lld %lld %lld\n",road[i].u,road[i].v,road[i].w);
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define MX 1009
#define ff first
#define ss second
#define pb(a) push_back(a)
using namespace std;

struct data
{
    ll u,v,w;
    bool operator < (const data& p) const
    {
        return w>p.w;
    }
};

struct data1
{
    ll u,v,w;
};

vector<ll>graph[1005];
ll cost[1005][1005],parrent[1005],dis[1009];
bool errase[1005][1005],taken[1005][1005];
priority_queue<data>pq;
data1 road[1005];

ll dijkstra(ll src, ll des)
{
    ll u,v,w,i;
    dis[src]=0;
    data D;
    D.u=src;
    D.w=dis[src];
    pq.push(D);
    while(!pq.empty())
    {
        D=pq.top();
        pq.pop();
        u=D.u;
        w=D.w;
//        cout<<u<<" "<<w<<endl;
        for(i=0;i<graph[u].size();i++)
        {
            v=graph[u][i];
            if(dis[v]>w+cost[u][v])
            {
                dis[v]=w+cost[u][v];
                parrent[v]=u;
                D.u=v;
                D.w=dis[v];
                //cout<<D.u<<"  "<<D.w<<endl;
                pq.push(D);
            }
        }
    }
    return dis[des];
}

ll dijkstra1(ll src, ll des)
{
    ll u,v,w,i;
    dis[src]=0;
    data D;
    D.u=src;
    D.w=dis[src];
    pq.push(D);
    while(!pq.empty())
    {
        D=pq.top();
        pq.pop();
        u=D.u;
        w=D.w;
//        cout<<u<<" "<<w<<endl;
        for(i=0;i<graph[u].size();i++)
        {
            v=graph[u][i];
            if(dis[v]>w+cost[u][v] && !errase[u][v])
            {
                dis[v]=w+cost[u][v];
//                parrent[v]=u;
                D.u=v;
                D.w=dis[v];
                //cout<<D.u<<"  "<<D.w<<endl;
                pq.push(D);
            }
        }
    }
    return dis[des];
}

int main()
{
    ll t,T,n,m,i,j,k,ans,a,b,c,x,y,vv,l,r,l2,r2,st,nd,u,v,w,err;
    while(scanf("%lld %lld %lld %lld %lld",&n,&m,&l,&st,&nd)!=EOF)
    {
        ans=0;
        memset(errase,false,sizeof errase);
        memset(taken,false,sizeof taken);
        for(i=0;i<=n;i++)
        {
            dis[i]=powl(10,18);
            graph[i].clear();
        }
        for(i=1;i<=m;i++)
        {
            scanf("%lld %lld %lld",&u,&v,&w);
            graph[u].push_back(v);
            graph[v].push_back(u);
            if(w==0)
            {
                errase[u][v]=true;
                errase[v][u]=true;
                w=1;
            }
            cost[u][v]=w;
            cost[v][u]=w;

            road[i].u=u;
            road[i].v=v;
            road[i].w=w;
        }
        ans=dijkstra(st,nd);
//        cout<<ans<<endl;
        if(ans>l || dijkstra1(st,nd)<l)
            printf("NO\n");
        else if(ans==l)
        {
            printf("YES\n");
            for(i=1;i<=m;i++)
                printf("%lld %lld %lld",road[i].u,road[i].v,road[i].w);
        }
        else
        {
            v=nd;
            err=0;
            while(v!=st)
            {
                u=parrent[v];
                if(errase[u][v]==true)
                {
                    err++;
                    taken[u][v]=true;
                    taken[v][u]=true;
                }
                v=u;
            }
            if(err==0)
                printf("NO\n");
            else
            {
                printf("YES\n");
                for(i=1;i<=m;i++)
                {
                    if(taken[road[i].u][road[i].v] && err>0)
                    {
                        road[i].w+=(l-ans);
                        err=0;
                    }
                    printf("%lld %lld %lld\n",road[i].u,road[i].v,road[i].w);
                }
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define MX 1009
#define ff first
#define ss second
#define pb(a) push_back(a)
using namespace std;

struct data
{
    ll u,v,w;
    bool operator < (const data& p) const
    {
        return w>p.w;
    }
};

struct data1
{
    ll u,v,w;
};

vector<ll>graph[1005];
ll cost[1005][1005],parrent[1005],dis[1009],n;
bool errase[1005][1005],taken[1005][1005];
priority_queue<data>pq;
data1 road[10005];

ll dijkstra(ll src, ll des,ll ok)
{
    ll u,v,w,i;
    for(i=0; i<=n; i++)
    {
        dis[i]=powl(10,18);
    }
    dis[src]=0;
    data D;
    D.u=src;
    D.w=dis[src];
    pq.push(D);
    while(!pq.empty())
    {
        D=pq.top();
        pq.pop();
        u=D.u;
        w=D.w;
//        cout<<u<<" "<<w<<endl;
        for(i=0; i<graph[u].size(); i++)
        {
            v=graph[u][i];
            if(ok==0 && errase[u][v]==true)
                continue;
            if(dis[v]>w+cost[u][v])
            {
                dis[v]=w+cost[u][v];
                parrent[v]=u;
                D.u=v;
                D.w=dis[v];
                //cout<<D.u<<"  "<<D.w<<endl;
                pq.push(D);
            }
        }
    }
    return dis[des];
}

int main()
{
    ll t,T,m,i,j,k,ans,a,b,c,x,y,vv,l,r,l2,r2,st,nd,u,v,w,err;
    while(scanf("%lld %lld %lld %lld %lld",&n,&m,&l,&st,&nd)!=EOF)
    {
        ans=0;
        memset(errase,false,sizeof errase);
        memset(taken,false,sizeof taken);
        for(i=0; i<=n; i++)
        {
            dis[i]=powl(10,18);
            graph[i].clear();
        }
        for(i=1; i<=m; i++)
        {
            scanf("%lld %lld %lld",&u,&v,&w);
            graph[u].push_back(v);
            graph[v].push_back(u);
            if(w==0)
            {
                errase[u][v]=true;
                errase[v][u]=true;
                w=1;
            }
            cost[u][v]=w;
            cost[v][u]=w;

            road[i].u=u;
            road[i].v=v;
            road[i].w=w;
        }
        ans=dijkstra(st,nd,1);
//        cout<<ans<<endl;
        if(ans>l || dijkstra(st,nd,0)<l)
            printf("NO\n");
        else if(ans==l)
        {
            printf("YES\n");
            for(i=1; i<=m; i++)
                printf("%lld %lld %lld\n",road[i].u,road[i].v,road[i].w);
        }
        else
        {
            while(ans<l)
            {
                memset(taken,false,sizeof taken);
                v=nd;
                while(v!=st)
                {
                    u=parrent[v];
                    if(errase[u][v]==true)
                    {
                        taken[u][v]=true;
                        taken[v][u]=true;
                    }
                    v=u;
                }
                for(i=1; i<=m; i++)
                {
                    if(!taken[road[i].u][road[i].v] && errase[u][v]==true)
                    {
                        road[i].w=powl(10,18);
                        cost[road[i].u][road[i].v]=powl(10,18);
                        cost[road[i].v][road[i].u]=powl(10,18);
                    }
                }
                for(i=1; i<=m; i++)
                {
                    if(taken[road[i].u][road[i].v])
                    {
                        road[i].w+=(l-ans);
                        cost[road[i].u][road[i].v]+=(l-ans);
                        cost[road[i].v][road[i].u]+=(l-ans);
                    }
                }
                ans=dijkstra(st,nd,1);
            }
            printf("YES\n");
            for(i=1; i<=m; i++)
            {
                printf("%lld %lld %lld\n",road[i].u,road[i].v,road[i].w);
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define MX 1009
#define ff first
#define ss second
#define pb(a) push_back(a)
using namespace std;

struct data
{
    ll u,v,w;
    bool operator < (const data& p) const
    {
        return w>p.w;
    }
};

struct data1
{
    ll u,v,w;
};

vector<ll>graph[1005];
ll cost[1005][1005],parrent[1005],dis[1009],n;
bool errase[1005][1005],taken[1005][1005];
priority_queue<data>pq;
data1 road[10005];

ll dijkstra(ll src, ll des)
{
    ll u,v,w,i;
    dis[src]=0;
    data D;
    D.u=src;
    D.w=dis[src];
    pq.push(D);
    while(!pq.empty())
    {
        D=pq.top();
        pq.pop();
        u=D.u;
        w=D.w;
//        cout<<u<<" "<<w<<endl;
        for(i=0;i<graph[u].size();i++)
        {
            v=graph[u][i];
            if(dis[v]>w+cost[u][v])
            {
                dis[v]=w+cost[u][v];
                parrent[v]=u;
                D.u=v;
                D.w=dis[v];
                //cout<<D.u<<"  "<<D.w<<endl;
                pq.push(D);
            }
        }
    }
    return dis[des];
}

ll dijkstra1(ll src, ll des)
{
    ll u,v,w,i;
    for(i=0;i<=n;i++)
        {
            dis[i]=powl(10,18);
        }
    dis[src]=0;
    data D;
    D.u=src;
    D.w=dis[src];
    pq.push(D);
    while(!pq.empty())
    {
        D=pq.top();
        pq.pop();
        u=D.u;
        w=D.w;
//        cout<<u<<" "<<w<<endl;
        for(i=0;i<graph[u].size();i++)
        {
            v=graph[u][i];
            if(dis[v]>w+cost[u][v] && !errase[u][v])
            {
                dis[v]=w+cost[u][v];
//                parrent[v]=u;
                D.u=v;
                D.w=dis[v];
                //cout<<D.u<<"  "<<D.w<<endl;
                pq.push(D);
            }
        }
    }
    return dis[des];
}

int main()
{
    ll t,T,m,i,j,k,ans,a,b,c,x,y,vv,l,r,l2,r2,st,nd,u,v,w,err;
    while(scanf("%lld %lld %lld %lld %lld",&n,&m,&l,&st,&nd)!=EOF)
    {
        ans=0;
        memset(errase,false,sizeof errase);
        memset(taken,false,sizeof taken);
        for(i=0;i<=n;i++)
        {
            dis[i]=powl(10,18);
            graph[i].clear();
        }
        for(i=1;i<=m;i++)
        {
            scanf("%lld %lld %lld",&u,&v,&w);
            graph[u].push_back(v);
            graph[v].push_back(u);
            if(w==0)
            {
                errase[u][v]=true;
                errase[v][u]=true;
                w=1;
            }
            cost[u][v]=w;
            cost[v][u]=w;

            road[i].u=u;
            road[i].v=v;
            road[i].w=w;
        }
        ans=dijkstra(st,nd);
//        cout<<dijkstra1(st,nd)<<endl;
        if(ans>l || dijkstra1(st,nd)<l)
            printf("NO\n");
        else if(ans==l)
        {
            printf("YES\n");
            for(i=1;i<=m;i++)
                printf("%lld %lld %lld\n",road[i].u,road[i].v,road[i].w);
        }
        else
        {
            v=nd;
            err=0;
            while(v!=st)
            {
                u=parrent[v];
                if(errase[u][v]==true)
                {
                    err++;
                    taken[u][v]=true;
                    taken[v][u]=true;
                }
                v=u;
            }
            if(err==0)
                printf("NO\n");
            else
            {
                printf("YES\n");
                for(i=1;i<=m;i++)
                {
                    if(taken[road[i].u][road[i].v] && err>0)
                    {
                        road[i].w+=(l-ans);
                        err=0;
                    }
                    if(!taken[road[i].u][road[i].v] && errase[road[i].u][road[i].v])
                        road[i].w=powl(10,18);
                    printf("%lld %lld %lld\n",road[i].u,road[i].v,road[i].w);
                }
            }
        }
    }
    return 0;
}