#include<bits/stdc++.h>
// #define M 100001
#define MAX 1000000010
#define mod 1000000007
#define ss second
#define ff first
#define ll long long int
#define pb push_back
#define ld double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

ll M = 100000000000000000;
ll wt[1000][1000];
bool check = false,w[1000][1000];

void diakstra(vector<pair<ll,ll> >adj[],ll root,ll dis[],ll n,ll parent[])
{
    fill(dis,dis+n,M);
    dis[root] = 0;
    parent[root] = root;
    set<pair<ll,ll> >s;
    for(int i=0;i<n;i++)
    {
        if(i == root)
        {
            s.insert({0,i});
        }
        else
        {
            s.insert({M,i});
        }
    }
    while(!s.empty())
    {
        auto it = s.begin();
        pair<ll,ll> p = (*it);
        s.erase(it);
        for(pair<ll,ll> child:adj[p.second])
        {
            if(s.find({dis[child.second],child.second}) != s.end())
            {
                if(dis[p.second] + child.first < dis[child.second])
                {
                    s.erase(s.find({dis[child.second],child.second}));
                    dis[child.second] = dis[p.second] + child.first;
                    parent[child.second] = p.second;
                    s.insert({dis[child.second],child.second});
                }
            }
        }
    }
}

void display(int n)
{
    cout<<"YES\n";
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(wt[i][j] != 0)
            {
                cout<<i<<" "<<j<<" "<<wt[i][j]<<endl;
            }
        }
    }

}

int main() {
    fast;
    ll n,m,l,s,t;
    cin>>n>>m>>l>>s>>t;
    vector<pair<ll,ll> > adj[n];
    for(int i=0;i<m;i++)
    {
        ll a,b,w1;
        cin>>a>>b>>w1;
        if(w1 != 0){
            wt[a][b] = wt[b][a] = w1;
            adj[a].pb({w1,b});
            adj[b].pb({w1,a});
        }
        else{
            wt[a][b] = wt[b][a] = M;
            w[a][b] = 1;
            w[b][a] = 1;
            adj[a].pb({1ll,b});
            adj[b].pb({1ll,a});
        }
    }
    ll dis[n],parent[n],current = t;
    fill(parent,parent+n,-1);
    diakstra(adj,s,dis,n,parent);
    bool nopath = false;
    while(parent[current] != current)
    {
        if(parent[current] == -1){
            nopath = true;
            break;
        }
        if(w[current][parent[current]] == 1)
        {
            check = true;
        }
        current = parent[current];
    }
    // cout<<dis[t]<<" "<<check<<" "<<nopath<<endl;
    // for(int i=0;i<n;i++)
    //     cout<<dis[i]<<" ";
    // cout<<endl;
    if((dis[t] < l && check==0) || nopath ||(dis[t]>l))
    {
        cout<<"NO\n";
        return 0;
    }
    current = t;
    ll wx = 0,la=-1,lb=-1;
    while(parent[current] != current)
    {
        if(w[current][parent[current]] == 1)
        {
            if(la == -1)
            {
                la = current;
                lb = parent[current];
            }
            wt[current][parent[current]] = 1;
            for(int i=0;i<adj[current].size();i++)
            {
                if(adj[current][i].ss == parent[current])
                {
                    adj[current][i].ff = 1;
                    break;
                }
            }

            for(int i=0;i<adj[parent[current]].size();i++)
            {
                if(adj[parent[current]][i].ss == current)
                {
                    adj[parent[current]][i].ff = 1;
                    break;
                }
            }

            wx++;
        }
        else
        {
            wx+=wt[current][parent[current]];
        }
        current = parent[current];
    }
    if(la != -1){
        wt[la][lb] = wt[lb][la] = l-wx + 1;
        for(int i=0;i<adj[la].size();i++)
        {
            if(adj[la][i].ss == lb)
            {
                adj[la][i].ff = wt[la][lb];
                break;
            }
        }
        for(int i=0;i<adj[lb].size();i++)
        {
            if(adj[lb][i].ss == la)
            {
                adj[lb][i].ff = wt[la][lb];
                break;
            }
        }

    }

    diakstra(adj,s,dis,n,parent);
    if(dis[t] == l)
        display(n);
    else
    {
        cout<<"NO\n";
    }

	return 0;
}


#include<bits/stdc++.h>
// #define M 100001
#define MAX 1000000010
#define mod 1000000007
#define ss second
#define ff first
#define ll long long int
#define pb push_back
#define ld double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

ll M = 100000000000000000;
ll wt[1000][1000];
bool check = false,w[1000][1000];

void diakstra(vector<pair<ll,ll> >adj[],ll root,ll dis[],ll n,ll parent[])
{
    fill(dis,dis+n,M);
    dis[root] = 0;
    parent[root] = root;
    set<pair<ll,ll> >s;
    for(int i=0;i<n;i++)
    {
        if(i == root)
        {
            s.insert({0,i});
        }
        else
        {
            s.insert({M,i});
        }
    }
    while(!s.empty())
    {
        auto it = s.begin();
        pair<ll,ll> p = (*it);
        s.erase(it);
        for(pair<ll,ll> child:adj[p.second])
        {
            if(s.find({dis[child.second],child.second}) != s.end())
            {
                if(dis[p.second] + child.first < dis[child.second])
                {
                    s.erase(s.find({dis[child.second],child.second}));
                    dis[child.second] = dis[p.second] + child.first;
                    parent[child.second] = p.second;
                    s.insert({dis[child.second],child.second});
                }
            }
        }
    }
}

void display(int n)
{
    cout<<"YES\n";
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(wt[i][j] != 0)
            {
                cout<<i<<" "<<j<<" "<<wt[i][j]<<endl;
            }
        }
    }

}

int main() {
    fast;
    ll n,m,l,s,t;
    cin>>n>>m>>l>>s>>t;
    vector<pair<ll,ll> > adj[n];
    for(int i=0;i<m;i++)
    {
        ll a,b,w1;
        cin>>a>>b>>w1;
        if(w1 != 0){
            wt[a][b] = wt[b][a] = w1;
            adj[a].pb({w1,b});
            adj[b].pb({w1,a});
        }
        else{
            wt[a][b] = wt[b][a] = M;
            w[a][b] = 1;
            w[b][a] = 1;
            adj[a].pb({1ll,b});
            adj[b].pb({1ll,a});
        }
    }
    ll dis[n],parent[n],current = t;
    fill(parent,parent+n,-1);
    diakstra(adj,s,dis,n,parent);
    bool nopath = false;
    while(parent[current] != current)
    {
        if(parent[current] == -1){
            nopath = true;
            break;
        }
        if(w[current][parent[current]] == 1)
        {
            check = true;
        }
        current = parent[current];
    }
    // cout<<dis[t]<<" "<<check<<" "<<nopath<<endl;
    // for(int i=0;i<n;i++)
    //     cout<<dis[i]<<" ";
    // cout<<endl;
    if((dis[t] < l && check==0) || nopath ||(dis[t]>l && check == 0))
    {
        cout<<"NO\n";
        return 0;
    }
    current = t;
    ll wx = 0,la=-1,lb=-1;
    while(parent[current] != current)
    {
        if(w[current][parent[current]] == 1)
        {
            if(la == -1)
            {
                la = current;
                lb = parent[current];
            }
            wt[current][parent[current]] = 1;
            for(int i=0;i<adj[current].size();i++)
            {
                if(adj[current][i].ss == parent[current])
                {
                    adj[current][i].ff = 1;
                    break;
                }
            }

            for(int i=0;i<adj[parent[current]].size();i++)
            {
                if(adj[parent[current]][i].ss == current)
                {
                    adj[parent[current]][i].ff = 1;
                    break;
                }
            }

            wx++;
        }
        else
        {
            wx+=wt[current][parent[current]];
        }
        current = parent[current];
    }
    if(la != -1){
        wt[la][lb] = wt[lb][la] = l-wx + 1;
        for(int i=0;i<adj[la].size();i++)
        {
            if(adj[la][i].ss == lb)
            {
                adj[la][i].ff = wt[la][lb];
                break;
            }
        }
        for(int i=0;i<adj[lb].size();i++)
        {
            if(adj[lb][i].ss == la)
            {
                adj[lb][i].ff = wt[la][lb];
                break;
            }
        }

    }

    diakstra(adj,s,dis,n,parent);
    if(dis[t] == l)
        display(n);
    else
    {
        cout<<"NO\n";
    }

	return 0;
}


#include<bits/stdc++.h>
// #define M 100001
#define MAX 1000000010
#define mod 1000000007
#define ss second
#define ff first
#define ll long long int
#define pb push_back
#define ld double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

ll M = 100000000000000000;
ll wt[1000][1000],zero[1000];
bool check = false,w[1000][1000];

void diakstra(vector<pair<ll,ll> >adj[],ll root,ll dis[],ll n,ll parent[])
{
    fill(dis,dis+n,M);
    dis[root] = 0;
    parent[root] = root;
    set<pair<ll,ll> >s;
    for(int i=0;i<n;i++)
    {
        if(i == root)
        {
            s.insert({0,i});
        }
        else
        {
            s.insert({M,i});
        }
    }
    while(!s.empty())
    {
        auto it = s.begin();
        pair<ll,ll> p = (*it);
        s.erase(it);
        for(pair<ll,ll> child:adj[p.second])
        {
            if(s.find({dis[child.second],child.second}) != s.end())
            {
                if(dis[p.second] + child.first < dis[child.second])
                {
                    s.erase(s.find({dis[child.second],child.second}));
                    dis[child.second] = dis[p.second] + child.first;
                    parent[child.second] = p.second;
                    s.insert({dis[child.second],child.second});
                    int temp = 0;
                    if(w[child.ss][p.ss])
                        temp = 1;
                    temp += zero[p.ss];
                    zero[child.ss] = temp;
                }
                else if(dis[p.second] + child.first == dis[child.second])
                {
                    int temp = 0;
                    if(w[child.ss][p.ss])
                        temp = 1;
                    temp += zero[p.ss];
                    if(temp < zero[child.ss])
                    {
                        s.erase(s.find({dis[child.second],child.second}));
                        dis[child.second] = dis[p.second] + child.first;
                        parent[child.second] = p.second;
                        s.insert({dis[child.second],child.second});
                        zero[child.ss] = temp;
                    }
                }
            }
        }
    }
}

void display(int n)
{
    cout<<"YES\n";
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(wt[i][j] != 0)
            {
                cout<<i<<" "<<j<<" "<<wt[i][j]<<endl;
            }
        }
    }

}

int main() {
    fast;
    ll n,m,l,s,t;
    cin>>n>>m>>l>>s>>t;
    vector<pair<ll,ll> > adj[n];
    for(int i=0;i<m;i++)
    {
        ll a,b,w1;
        cin>>a>>b>>w1;
        if(w1 != 0){
            wt[a][b] = wt[b][a] = w1;
            adj[a].pb({w1,b});
            adj[b].pb({w1,a});
        }
        else{
            wt[a][b] = wt[b][a] = M;
            w[a][b] = 1;
            w[b][a] = 1;
            adj[a].pb({1ll,b});
            adj[b].pb({1ll,a});
        }
    }
    ll dis[n],parent[n],current = t;
    fill(parent,parent+n,-1);
    diakstra(adj,s,dis,n,parent);
    bool nopath = false;
    while(parent[current] != current)
    {
        if(parent[current] == -1){
            nopath = true;
            break;
        }
        if(w[current][parent[current]] == 1)
        {
            check = true;
        }
        current = parent[current];
    }
    // cout<<dis[t]<<" "<<check<<" "<<nopath<<endl;
    // for(int i=0;i<n;i++)
    //     cout<<dis[i]<<" ";
    // cout<<endl;
    if((dis[t] < l && check==0) || nopath ||(dis[t]>l))
    {
        cout<<"NO\n";
        return 0;
    }
    current = t;
    ll wx = 0,la=-1,lb=-1;
    while(parent[current] != current)
    {
        if(w[current][parent[current]] == 1)
        {
            w[current][parent[current]] = 0;
            w[parent[current]][current] = 0;
            if(la == -1)
            {
                la = current;
                lb = parent[current];
            }
            wt[current][parent[current]] = 1;
            wt[parent[current]][current] = 1;
            for(int i=0;i<adj[current].size();i++)
            {
                if(adj[current][i].ss == parent[current])
                {
                    adj[current][i].ff = 1;
                    break;
                }
            }

            for(int i=0;i<adj[parent[current]].size();i++)
            {
                if(adj[parent[current]][i].ss == current)
                {
                    adj[parent[current]][i].ff = 1;
                    break;
                }
            }

            wx++;
        }
        else
        {
            wx+=wt[current][parent[current]];
        }
        current = parent[current];
    }
    // cout<<la<<" hjh "<<lb<<endl;
    if(la != -1){
        wt[la][lb] = wt[lb][la] = l-wx + 1;
        for(int i=0;i<adj[la].size();i++)
        {
            if(adj[la][i].ss == lb)
            {
                adj[la][i].ff = wt[la][lb];
                break;
            }
        }
        for(int i=0;i<adj[lb].size();i++)
        {
            if(adj[lb][i].ss == la)
            {
                adj[lb][i].ff = wt[la][lb];
                break;
            }
        }

    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<adj[i].size();j++)
        {
            if(w[i][adj[i][j].ss] == 1)
            {
                adj[i][j].ff = wt[i][adj[i][j].ss];
            }
        }
    }

    diakstra(adj,s,dis,n,parent);
    // cout<<dis[t]<<endl;
    if(dis[t] == l)
        display(n);
    else
    {
        cout<<"NO\n";
    }

	return 0;
}


#include<bits/stdc++.h>
// #define M 100001
#define MAX 1000000010
#define mod 1000000007
#define ss second
#define ff first
#define ll long long int
#define pb push_back
#define ld double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

ll M = 100000000000000000;
ll wt[1000][1000];
bool check = false,w[1000][1000];

void diakstra(vector<pair<ll,ll> >adj[],ll root,ll dis[],ll n,ll parent[])
{
    fill(dis,dis+n,M);
    dis[root] = 0;
    parent[root] = root;
    set<pair<ll,ll> >s;
    for(int i=0;i<n;i++)
    {
        if(i == root)
        {
            s.insert({0,i});
        }
        else
        {
            s.insert({M,i});
        }
    }
    while(!s.empty())
    {
        auto it = s.begin();
        pair<ll,ll> p = (*it);
        s.erase(it);
        for(pair<ll,ll> child:adj[p.second])
        {
            if(s.find({dis[child.second],child.second}) != s.end())
            {
                if(dis[p.second] + child.first < dis[child.second])
                {
                    s.erase(s.find({dis[child.second],child.second}));
                    dis[child.second] = dis[p.second] + child.first;
                    parent[child.second] = p.second;
                    s.insert({dis[child.second],child.second});
                }
            }
        }
    }
}

void display(int n)
{
    cout<<"YES\n";
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(wt[i][j] != 0)
            {
                cout<<i<<" "<<j<<" "<<wt[i][j]<<endl;
            }
        }
    }

}

int main() {
    fast;
    ll n,m,l,s,t;
    cin>>n>>m>>l>>s>>t;
    vector<pair<ll,ll> > adj[n];
    for(int i=0;i<m;i++)
    {
        ll a,b,w1;
        cin>>a>>b>>w1;
        if(w1 != 0){
            wt[a][b] = wt[b][a] = w1;
            adj[a].pb({w1,b});
            adj[b].pb({w1,a});
        }
        else{
            wt[a][b] = wt[b][a] = M;
            w[a][b] = 1;
            w[b][a] = 1;
            adj[a].pb({1ll,b});
            adj[b].pb({1ll,a});
        }
    }
    ll dis[n],parent[n],current = t;
    fill(parent,parent+n,-1);
    diakstra(adj,s,dis,n,parent);
    bool nopath = false;
    while(parent[current] != current)
    {
        if(parent[current] == -1){
            nopath = true;
            break;
        }
        if(w[current][parent[current]] == 1)
        {
            check = true;
        }
        current = parent[current];
    }
    // cout<<dis[t]<<" "<<check<<" "<<nopath<<endl;
    // for(int i=0;i<n;i++)
    //     cout<<dis[i]<<" ";
    // cout<<endl;
    if((dis[t] < l && check==0) || nopath ||(dis[t]>l))
    {
        cout<<"NO\n";
        return 0;
    }
    current = t;
    ll wx = 0,la=-1,lb=-1;
    while(parent[current] != current)
    {
        if(w[current][parent[current]] == 1)
        {
            w[current][parent[current]] = 0;
            w[parent[current]][current] = 0;
            if(la == -1)
            {
                la = current;
                lb = parent[current];
            }
            wt[current][parent[current]] = 1;
            wt[parent[current]][current] = 1;
            for(int i=0;i<adj[current].size();i++)
            {
                if(adj[current][i].ss == parent[current])
                {
                    adj[current][i].ff = 1;
                    break;
                }
            }

            for(int i=0;i<adj[parent[current]].size();i++)
            {
                if(adj[parent[current]][i].ss == current)
                {
                    adj[parent[current]][i].ff = 1;
                    break;
                }
            }

            wx++;
        }
        else
        {
            wx+=wt[current][parent[current]];
        }
        current = parent[current];
    }
    // cout<<la<<" hjh "<<lb<<endl;
    if(la != -1){
        wt[la][lb] = wt[lb][la] = l-wx + 1;
        for(int i=0;i<adj[la].size();i++)
        {
            if(adj[la][i].ss == lb)
            {
                adj[la][i].ff = wt[la][lb];
                break;
            }
        }
        for(int i=0;i<adj[lb].size();i++)
        {
            if(adj[lb][i].ss == la)
            {
                adj[lb][i].ff = wt[la][lb];
                break;
            }
        }

    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<adj[i].size();j++)
        {
            if(w[i][adj[i][j].ss] == 1)
            {
                adj[i][j].ff = wt[i][adj[i][j].ss];
            }
        }
    }

    diakstra(adj,s,dis,n,parent);
    // cout<<dis[t]<<endl;
    if(dis[t] == l)
        display(n);
    else
    {
        cout<<"NO\n";
    }

	return 0;
}


#include <iostream>
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;

ll M = 100000000000000000;
ll w[1000][1000];

void diakstra(vector<pair<ll,ll> >adj[],ll root,ll dis[],ll n,ll parent[])
{
    fill(dis,dis+n,M);
    dis[root] = 0;
    parent[root] = root;
    set<pair<ll,ll> >s;
    for(int i=0;i<n;i++)
    {
        if(i == root)
        {
            s.insert({0,i});
        }
        else
        {
            s.insert({M,i});
        }
    }
    while(!s.empty())
    {
        auto it = s.begin();
        pair<ll,ll> p = (*it);
        s.erase(it);
        for(pair<ll,ll> child:adj[p.second])
        {
            if(s.find({dis[child.second],child.second}) != s.end())
            {
                if(dis[p.second] + child.first < dis[child.second])
                {
                    s.erase(s.find({dis[child.second],child.second}));
                    dis[child.second] = dis[p.second] + child.first;
                    parent[child.second] = p.second;
                    s.insert({dis[child.second],child.second});
                }
            }
        }
    }
}

int main() {
    fast;
    ll n,m,l,s,t;
    cin>>n>>m>>l>>s>>t;
    vector<pair<ll,ll> > adj[n];
    vector<pair<ll,pair<ll,ll> > >zero;
    for(int i=0;i<m;i++)
    {
        ll a,b,w1;
        cin>>a>>b>>w1;
        if(w1 != 0){
            adj[a].pb({w1,b});
            adj[b].pb({w1,a});
            w[a][b] = w[b][a] = w1;
        }
        else{
            zero.pb({w1,{a,b}});
            w[a][b] = w[b][a] = M;
        }
    }
    ll dis[n],parent[n];
    // cout<<w[4][1]<<endl;
    diakstra(adj,s,dis,n,parent);
    // for(int i=0;i<n;i++)
    //     cout<<dis[i]<<" ";
    if(dis[t] < l)
    {
        cout<<"NO\n";
        return 0;
    }
    for(pair<ll,pair<ll,ll> > p:zero)
    {
        adj[p.second.first].pb({p.first,p.second.second});
        adj[p.second.second].pb({p.first,p.second.first});
    }
    diakstra(adj,s,dis,n,parent);
    ll current = t,cnt = 0,lasta=0,lastb=0;
    while(parent[current] != current)
    {
        // cout<<current<<" "<<parent[current]<<endl;
        // cout<<w[current][parent[current]]<<endl;
        if(w[current][parent[current]] == M){
            w[current][parent[current]] = 1;
            w[parent[current]][current] = 1;
            lasta = current;
            lastb = parent[current];
            cnt++;

        }
        else
            cnt+=w[current][parent[current]];
        current = parent[current];
    }
    if(cnt > l)
    {
        cout<<"NO\n";
        return 0;
    }
    // cout<<cnt<<endl;
    w[lasta][lastb] += l-cnt;
    w[lastb][lasta] += l-cnt;
    cout<<"YES\n";
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(w[i][j] != 0)
            {
                cout<<i<<" "<<j<<" "<<w[i][j]<<endl;
            }
        }
    }

	return 0;
}


#include<bits/stdc++.h>
// #define M 100001
#define MAX 1000000010
#define mod 1000000007
#define ss second
#define ff first
#define ll long long int
#define pb push_back
#define ld double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

ll M = 100000000000000000;
ll wt[1000][1000];
bool check = false,w[1000][1000];

void diakstra(vector<pair<ll,ll> >adj[],ll root,ll dis[],ll n)
{
    fill(dis,dis+n,M);
    dis[root] = 0;
    set<pair<ll,ll> >s;
    s.insert({0,root});
    while(!s.empty())
    {
        auto it = s.begin();
        pair<ll,ll> p = (*it);
        s.erase(it);
        for(pair<ll,ll> child:adj[p.second])
        {
            if(dis[p.second] + child.first < dis[child.second])
            {
                s.erase({dis[child.ss],child.ss});
                dis[child.second] = dis[p.second] + child.first;
                s.insert({dis[child.second],child.second});
            }
        }
    }
}

void display(int n)
{
    cout<<"YES\n";
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(wt[i][j] != 0)
            {
                cout<<i<<" "<<j<<" "<<wt[i][j]<<endl;
            }
        }
    }

}

int main() {
    fast;
    ll n,m,l,s,t;
    cin>>n>>m>>l>>s>>t;
    vector<pair<ll,ll> > adj[n];
    vector<pair<ll,ll> >zero;
    for(int i=0;i<m;i++)
    {
        ll a,b,w1;
        cin>>a>>b>>w1;
        if(w1 != 0){
            wt[a][b] = wt[b][a] = w1;
            adj[a].pb({w1,b});
            adj[b].pb({w1,a});
        }
        else{
            wt[a][b] = wt[b][a] = 0;
            zero.pb({a,b});
            // adj[a].pb({1ll,b});
            // adj[b].pb({1ll,a});
        }
    }
    ll dis[n];
    diakstra(adj,s,dis,n);
    // cout<<dis[t]<<" "<<check<<" "<<nopath<<endl;
    // for(int i=0;i<n;i++)
    //     cout<<dis[i]<<" ";
    // cout<<endl;
    if(dis[t] < l)
    {
        cout<<"NO\n";
        return 0;
    }

    for(pair<ll,ll>p:zero)
    {
        ll u = p.ff,v = p.ss;
        adj[u].pb({1,v});
        adj[v].pb({1,u});
        wt[u][v] = 1;
        wt[v][u] = 1;
        diakstra(adj,s,dis,n);
        ll dif = l-dis[t];
        if(dif > 0)
        {
            adj[u].pop_back();
            adj[v].pop_back();
            adj[u].pb({dif+1,v});
            adj[v].pb({dif+1,u});
            wt[u][v] = dif+1;
            wt[v][u] = dif+1;
        }
    }
    diakstra(adj,s,dis,n);
    if(dis[t] > l)
    {
        cout<<"NO\n";
        return 0;
    }
    display(n);

	return 0;
}


#include<bits/stdc++.h>
// #define M 100001
#define MAX 1000000010
#define mod 1000000007
#define ss second
#define ff first
#define ll long long int
#define pb push_back
#define ld double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

ll M = 100000000000000000;
ll wt[1000][1000];
bool check = false,w[1000][1000];

void diakstra(vector<pair<ll,ll> >adj[],ll root,ll dis[],ll n,ll parent[])
{
    fill(dis,dis+n,M);
    dis[root] = 0;
    parent[root] = root;
    set<pair<ll,ll> >s;
    for(int i=0;i<n;i++)
    {
        if(i == root)
        {
            s.insert({0,i});
        }
        else
        {
            s.insert({M,i});
        }
    }
    while(!s.empty())
    {
        auto it = s.begin();
        pair<ll,ll> p = (*it);
        s.erase(it);
        for(pair<ll,ll> child:adj[p.second])
        {
            if(s.find({dis[child.second],child.second}) != s.end())
            {
                if(dis[p.second] + child.first < dis[child.second])
                {
                    s.erase(s.find({dis[child.second],child.second}));
                    dis[child.second] = dis[p.second] + child.first;
                    parent[child.second] = p.second;
                    s.insert({dis[child.second],child.second});
                }
            }
        }
    }
}

void display(int n)
{
    cout<<"YES\n";
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(wt[i][j] != 0)
            {
                cout<<i<<" "<<j<<" "<<wt[i][j]<<endl;
            }
        }
    }

}

int main() {
    fast;
    ll n,m,l,s,t;
    cin>>n>>m>>l>>s>>t;
    vector<pair<ll,ll> > adj[n];
    for(int i=0;i<m;i++)
    {
        ll a,b,w1;
        cin>>a>>b>>w1;
        if(w1 != 0){
            wt[a][b] = wt[b][a] = w1;
            adj[a].pb({w1,b});
            adj[b].pb({w1,a});
        }
        else{
            wt[a][b] = wt[b][a] = M;
            w[a][b] = 1;
            w[b][a] = 1;
            adj[a].pb({1ll,b});
            adj[b].pb({1ll,a});
        }
    }
    ll dis[n],parent[n],current = t;
    fill(parent,parent+n,-1);
    diakstra(adj,s,dis,n,parent);
    bool nopath = false;
    while(parent[current] != current)
    {
        if(parent[current] == -1)
            nopath = true;
        if(w[current][parent[current]] == 1)
        {
            check = true;
        }
        current = parent[current];
    }
    // cout<<dis[t]<<" "<<check<<" "<<nopath<<endl;
    // for(int i=0;i<n;i++)
    //     cout<<dis[i]<<" ";
    // cout<<endl;
    if((dis[t] < l && check==0) || nopath ||(dis[t]>l && check == 0))
    {
        cout<<"NO\n";
        return 0;
    }
    current = t;
    ll wx = 0,la=-1,lb=-1;
    while(parent[current] != current)
    {
        if(w[current][parent[current]] == 1)
        {
            if(la == -1)
            {
                la = current;
                lb = parent[current];
            }
            wt[current][parent[current]] = 1;
            for(int i=0;i<adj[current].size();i++)
            {
                if(adj[current][i].ss == parent[current])
                {
                    adj[current][i].ff = 1;
                    break;
                }
            }

            for(int i=0;i<adj[parent[current]].size();i++)
            {
                if(adj[parent[current]][i].ss == current)
                {
                    adj[parent[current]][i].ff = 1;
                    break;
                }
            }

            wx++;
        }
        else
        {
            wx+=wt[current][parent[current]];
        }
        current = parent[current];
    }
    if(la != -1){
        wt[la][lb] = wt[lb][la] = l-wx + 1;
        for(int i=0;i<adj[la].size();i++)
        {
            if(adj[la][i].ss == lb)
            {
                adj[la][i].ff = wt[la][lb];
                break;
            }
        }
        for(int i=0;i<adj[lb].size();i++)
        {
            if(adj[lb][i].ss == la)
            {
                adj[lb][i].ff = wt[la][lb];
                break;
            }
        }

    }

    diakstra(adj,s,dis,n,parent);
    if(dis[t] == l)
        display(n);
    else
    {
        cout<<"NO\n";
    }

	return 0;
}


#include<bits/stdc++.h>
// #define M 100001
#define MAX 1000000010
#define mod 1000000007
#define ss second
#define ff first
#define ll long long int
#define pb push_back
#define ld double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

ll M = 100000000000000000;
ll wt[1000][1000];
bool check = false,w[1000][1000];

void diakstra(vector<pair<ll,ll> >adj[],ll root,ll dis[],ll n,ll parent[])
{
    fill(dis,dis+n,M);
    dis[root] = 0;
    parent[root] = root;
    set<pair<ll,ll> >s;
    for(int i=0;i<n;i++)
    {
        if(i == root)
        {
            s.insert({0,i});
        }
        else
        {
            s.insert({M,i});
        }
    }
    while(!s.empty())
    {
        auto it = s.begin();
        pair<ll,ll> p = (*it);
        s.erase(it);
        for(pair<ll,ll> child:adj[p.second])
        {
            if(s.find({dis[child.second],child.second}) != s.end())
            {
                if(dis[p.second] + child.first < dis[child.second])
                {
                    s.erase(s.find({dis[child.second],child.second}));
                    dis[child.second] = dis[p.second] + child.first;
                    parent[child.second] = p.second;
                    s.insert({dis[child.second],child.second});
                }
            }
        }
    }
}

void display(int n)
{
    cout<<"YES\n";
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(wt[i][j] != 0)
            {
                cout<<i<<" "<<j<<" "<<wt[i][j]<<endl;
            }
        }
    }

}

int main() {
    fast;
    ll n,m,l,s,t;
    cin>>n>>m>>l>>s>>t;
    vector<pair<ll,ll> > adj[n];
    for(int i=0;i<m;i++)
    {
        ll a,b,w1;
        cin>>a>>b>>w1;
        if(w1 != 0){
            wt[a][b] = wt[b][a] = w1;
            adj[a].pb({w1,b});
            adj[b].pb({w1,a});
        }
        else{
            wt[a][b] = wt[b][a] = M;
            w[a][b] = 1;
            w[b][a] = 1;
            adj[a].pb({1ll,b});
            adj[b].pb({1ll,a});
        }
    }
    ll dis[n],parent[n],current = t;
    fill(parent,parent+n,-1);
    diakstra(adj,s,dis,n,parent);
    bool nopath = false;
    while(parent[current] != current)
    {
        if(parent[current] == -1){
            nopath = true;
            break;
        }
        if(w[current][parent[current]] == 1)
        {
            check = true;
        }
        current = parent[current];
    }
    // cout<<dis[t]<<" "<<check<<" "<<nopath<<endl;
    // for(int i=0;i<n;i++)
    //     cout<<dis[i]<<" ";
    // cout<<endl;
    if((dis[t] < l && check==0) || nopath ||(dis[t]>l))
    {
        cout<<"NO\n";
        return 0;
    }
    current = t;
    ll wx = 0,la=-1,lb=-1;
    while(parent[current] != current)
    {
        if(w[current][parent[current]] == 1)
        {
            if(la == -1)
            {
                la = current;
                lb = parent[current];
            }
            wt[current][parent[current]] = 1;
            wt[parent[current]][current] = 1;
            for(int i=0;i<adj[current].size();i++)
            {
                if(adj[current][i].ss == parent[current])
                {
                    adj[current][i].ff = 1;
                    break;
                }
            }

            for(int i=0;i<adj[parent[current]].size();i++)
            {
                if(adj[parent[current]][i].ss == current)
                {
                    adj[parent[current]][i].ff = 1;
                    break;
                }
            }

            wx++;
        }
        else
        {
            wx+=wt[current][parent[current]];
        }
        current = parent[current];
    }
    // cout<<la<<" hjh "<<lb<<endl;
    if(la != -1){
        wt[la][lb] = wt[lb][la] = l-wx + 1;
        for(int i=0;i<adj[la].size();i++)
        {
            if(adj[la][i].ss == lb)
            {
                adj[la][i].ff = wt[la][lb];
                break;
            }
        }
        for(int i=0;i<adj[lb].size();i++)
        {
            if(adj[lb][i].ss == la)
            {
                adj[lb][i].ff = wt[la][lb];
                break;
            }
        }

    }

    diakstra(adj,s,dis,n,parent);
    if(dis[t] == l)
        display(n);
    else
    {
        cout<<"NO\n";
    }

	return 0;
}


#include <iostream>
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;

ll M = 100000000000000000;
ll w[1000][1000];

void diakstra(vector<pair<ll,ll> >adj[],ll root,ll dis[],ll n,ll parent[])
{
    fill(dis,dis+n,M);
    dis[root] = 0;
    parent[root] = root;
    set<pair<ll,ll> >s;
    for(int i=0;i<n;i++)
    {
        if(i == root)
        {
            s.insert({0,i});
        }
        else
        {
            s.insert({M,i});
        }
    }
    while(!s.empty())
    {
        auto it = s.begin();
        pair<ll,ll> p = (*it);
        s.erase(it);
        for(pair<ll,ll> child:adj[p.second])
        {
            if(s.find({dis[child.second],child.second}) != s.end())
            {
                if(dis[p.second] + child.first < dis[child.second])
                {
                    s.erase(s.find({dis[child.second],child.second}));
                    dis[child.second] = dis[p.second] + child.first;
                    parent[child.second] = p.second;
                    s.insert({dis[child.second],child.second});
                }
            }
        }
    }
}

int main() {
    fast;
    ll n,m,l,s,t;
    cin>>n>>m>>l>>s>>t;
    vector<pair<ll,ll> > adj[n];
    vector<pair<ll,pair<ll,ll> > >zero;
    for(int i=0;i<m;i++)
    {
        ll a,b,w1;
        cin>>a>>b>>w1;
        if(w1 != 0){
            adj[a].pb({w1,b});
            adj[b].pb({w1,a});
            w[a][b] = w[b][a] = w1;
        }
        else{
            zero.pb({w1,{a,b}});
            w[a][b] = w[b][a] = M;
        }
    }
    ll dis[n],parent[n];
    // cout<<w[4][1]<<endl;
    diakstra(adj,s,dis,n,parent);
    // for(int i=0;i<n;i++)
    //     cout<<dis[i]<<" ";
    if(dis[t] < l)
    {
        cout<<"NO\n";
        return 0;
    }
    for(pair<ll,pair<ll,ll> > p:zero)
    {
        adj[p.second.first].pb({p.first,p.second.second});
        adj[p.second.second].pb({p.first,p.second.first});
    }
    fill(parent,parent+n,-1);
    diakstra(adj,s,dis,n,parent);
    ll current = t,cnt = 0,lasta=0,lastb=0;
    bool check = false;
    while(parent[current] != current)
    {
        if(parent[current] == -1)
        {
            check = true;
            break;
        }
        // cout<<current<<" "<<parent[current]<<endl;
        // cout<<w[current][parent[current]]<<endl;
        if(w[current][parent[current]] == M){
            w[current][parent[current]] = 1;
            w[parent[current]][current] = 1;
            lasta = current;
            lastb = parent[current];
            cnt++;

        }
        else
            cnt+=w[current][parent[current]];
        current = parent[current];
    }
    if(cnt > l || check)
    {
        cout<<"NO\n";
        return 0;
    }
    // cout<<cnt<<endl;
    w[lasta][lastb] += l-cnt;
    w[lastb][lasta] += l-cnt;
    cout<<"YES\n";
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(w[i][j] != 0)
            {
                cout<<i<<" "<<j<<" "<<w[i][j]<<endl;
            }
        }
    }

	return 0;
}


#include<bits/stdc++.h>
// #define M 100001
#define MAX 1000000010
#define mod 1000000007
#define ss second
#define ff first
#define ll long long int
#define pb push_back
#define ld double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

ll M = 100000000000000000;
ll wt[1000][1000];
bool check = false,w[1000][1000];

void diakstra(vector<pair<ll,ll> >adj[],ll root,ll dis[],ll n,ll parent[])
{
    fill(dis,dis+n,M);
    dis[root] = 0;
    parent[root] = root;
    set<pair<ll,ll> >s;
    for(int i=0;i<n;i++)
    {
        if(i == root)
        {
            s.insert({0,i});
        }
        else
        {
            s.insert({M,i});
        }
    }
    while(!s.empty())
    {
        auto it = s.begin();
        pair<ll,ll> p = (*it);
        s.erase(it);
        for(pair<ll,ll> child:adj[p.second])
        {
            if(s.find({dis[child.second],child.second}) != s.end())
            {
                if(dis[p.second] + child.first < dis[child.second])
                {
                    s.erase(s.find({dis[child.second],child.second}));
                    dis[child.second] = dis[p.second] + child.first;
                    parent[child.second] = p.second;
                    s.insert({dis[child.second],child.second});
                }
            }
        }
    }
}

void display(int n)
{
    cout<<"YES\n";
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(wt[i][j] != 0)
            {
                cout<<i<<" "<<j<<" "<<wt[i][j]<<endl;
            }
        }
    }

}

int main() {
    fast;
    ll n,m,l,s,t;
    cin>>n>>m>>l>>s>>t;
    vector<pair<ll,ll> > adj[n];
    for(int i=0;i<m;i++)
    {
        ll a,b,w1;
        cin>>a>>b>>w1;
        if(w1 != 0){
            wt[a][b] = wt[b][a] = w1;
            adj[a].pb({w1,b});
            adj[b].pb({w1,a});
        }
        else{
            wt[a][b] = wt[b][a] = M;
            w[a][b] = 1;
            w[b][a] = 1;
            adj[a].pb({1ll,b});
            adj[b].pb({1ll,a});
        }
    }
    ll dis[n],parent[n],current = t;
    fill(parent,parent+n,-1);
    diakstra(adj,s,dis,n,parent);
    bool nopath = false;
    while(parent[current] != current)
    {
        if(parent[current] == -1){
            nopath = true;
            break;
        }
        if(w[current][parent[current]] == 1)
        {
            check = true;
        }
        current = parent[current];
    }
    // cout<<dis[t]<<" "<<check<<" "<<nopath<<endl;
    // for(int i=0;i<n;i++)
    //     cout<<dis[i]<<" ";
    // cout<<endl;
    if((dis[t] < l && check==0) || nopath ||(dis[t]>l))
    {
        cout<<"NO\n";
        return 0;
    }
    current = t;
    ll wx = 0,la=-1,lb=-1;
    while(parent[current] != current)
    {
        if(w[current][parent[current]] == 1)
        {
            if(la == -1)
            {
                la = current;
                lb = parent[current];
            }
            wt[current][parent[current]] = 1;
            wt[parent[current]][current] = 1;
            for(int i=0;i<adj[current].size();i++)
            {
                if(adj[current][i].ss == parent[current])
                {
                    adj[current][i].ff = 1;
                    break;
                }
            }

            for(int i=0;i<adj[parent[current]].size();i++)
            {
                if(adj[parent[current]][i].ss == current)
                {
                    adj[parent[current]][i].ff = 1;
                    break;
                }
            }

            wx++;
        }
        else
        {
            wx+=wt[current][parent[current]];
        }
        current = parent[current];
    }
    cout<<la<<" hjh "<<lb<<endl;
    if(la != -1){
        wt[la][lb] = wt[lb][la] = l-wx + 1;
        for(int i=0;i<adj[la].size();i++)
        {
            if(adj[la][i].ss == lb)
            {
                adj[la][i].ff = wt[la][lb];
                break;
            }
        }
        for(int i=0;i<adj[lb].size();i++)
        {
            if(adj[lb][i].ss == la)
            {
                adj[lb][i].ff = wt[la][lb];
                break;
            }
        }

    }

    diakstra(adj,s,dis,n,parent);
    if(dis[t] == l)
        display(n);
    else
    {
        cout<<"NO\n";
    }

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;
#define f first
#define s second

const int N = 1000 + 10;
const ll mod = 1000*1000*1000 + 7;
const ll inf = 1e16;

ll dp[N];
vector<pair<int, ll>> adj[2][N];
set<pair<ll, ll>> s;
int par[N];
vector<int> p;
vector<pair<int, int>> e;
ll ans[N][N];

int n, m;

void dij(int b, int u)
{
	for(int i = 0; i < n; i++)
	{
		dp[i] = inf;
		par[i] = -1;
	}
	dp[u] = 0;
	for(int i = 0; i < n; i++)
	{
		s.insert({dp[i], i});
	}

	while(!s.empty())
	{
		int x = s.begin()->s;
		s.erase(s.begin());
		for(int i = 0; i < adj[b][x].size(); i++)
		{
			int v = adj[b][x][i].f, w = adj[b][x][i].s;
			if(dp[v] > dp[x]+w)
			{
				s.erase(s.lower_bound({dp[v], v}));
				dp[v] = dp[x]+w;
				par[v] = x;
				s.insert({dp[v], v});
			}
		}
	}

	return;

}

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

	int l, s, t;
	cin >> n >> m >> l >> s >> t;
	for(int i = 0; i < m; i++)
	{
		int x, y, w;
		cin >> x >> y >> w;
		if(w != 0)
		{
			adj[1][x].push_back({y, w});
			adj[1][y].push_back({x, w});
			adj[0][x].push_back({y, w});
			adj[0][y].push_back({x, w});
			ans[x][y] = w;
		}
		else
		{
			w++;
			adj[1][x].push_back({y, w});
			adj[1][y].push_back({x, w});
			ans[x][y] = inf;
			ans[y][x] = inf;
		}
		e.push_back({x, y});

	}
	dij(0, s);
	//cout << "///" << endl;

	if(dp[t] < l)
	{
		cout << "NO" << endl;
		return 0;
	}

	dij(1, s);

	if(dp[t] > l)
	{
		cout << "NO" << endl;
		return 0;
	}
	int u = t;
	while(u != -1)
	{
		p.push_back(u);
		u = par[u];
	}
	//cout << "///" << endl;
	bool fl = true;
	bool bol = false;
	for(int i = 0; i < p.size()-1; i++)
	{
		int x = p[i], y = p[i+1];
		if(ans[x][y] == inf && fl)
		{
			ans[x][y] =	l-dp[t]+1;
			ans[y][x] =	l-dp[t]+1;
			fl = false;
			bol = true;

		}
		else if(ans[x][y] == inf)
		{
			ans[x][y] = 1;
			ans[y][x] = 1;
		}
	}

	if(!bol && dp[t] != l)
	{
		cout << "NO" << endl;
		return 0;
	}
	cout << "YES" << endl;
	for(int i = 0; i < m; i++)
	{
		cout << e[i].f << ' ' << e[i].s << ' ' << ans[e[i].f][e[i].s] << endl;
	}

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;
#define f first
#define s second

const int N = 1000 + 10;
const ll mod = 1000*1000*1000 + 7;
const ll inf = 1e10;

ll dp[N];
vector<pair<int, ll>> adj[2][N];
set<pair<ll, ll>> s;
int par[N];
vector<int> p;
vector<pair<int, int>> e;
ll ans[N][N];

int n, m;

void dij(int b, int u)
{
	for(int i = 0; i < n; i++)
	{
		dp[i] = inf;
		par[i] = -1;
	}
	dp[u] = 0;
	for(int i = 0; i < n; i++)
	{
		s.insert({dp[i], i});
	}

	while(!s.empty())
	{
		int x = s.begin()->s;
		s.erase(s.begin());
		for(int i = 0; i < adj[b][x].size(); i++)
		{
			int v = adj[b][x][i].f, w = adj[b][x][i].s;
			if(dp[v] > dp[x]+w)
			{
				s.erase(s.lower_bound({dp[v], v}));
				dp[v] = dp[x]+w;
				par[v] = x;
				s.insert({dp[v], v});
			}
		}
	}

	return;

}

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

	int l, s, t;
	cin >> n >> m >> l >> s >> t;
	for(int i = 0; i < m; i++)
	{
		int x, y, w;
		cin >> x >> y >> w;
		if(w != 0)
		{
			adj[1][x].push_back({y, w});
			adj[1][y].push_back({x, w});
			adj[0][x].push_back({y, w});
			adj[0][y].push_back({x, w});
			ans[x][y] = w;
		}
		else
		{
			w++;
			adj[1][x].push_back({y, w});
			adj[1][y].push_back({x, w});
			ans[x][y] = inf;
			ans[y][x] = inf;
		}
		e.push_back({x, y});

	}
	dij(0, s);
	//cout << "///" << endl;

	if(dp[t] < l)
	{
		cout << "NO" << endl;
		return 0;
	}

	dij(1, s);

	if(dp[t] > l)
	{
		cout << "NO" << endl;
		return 0;
	}
	int u = t;
	while(u != -1)
	{
		p.push_back(u);
		u = par[u];
	}
	//cout << "///" << endl;
	bool fl = true;
	bool bol = false;
	for(int i = 0; i < p.size()-1; i++)
	{
		int x = p[i], y = p[i+1];
		if(ans[x][y] == inf && fl)
		{
			ans[x][y] =	l-dp[t]+1;
			ans[y][x] =	l-dp[t]+1;
			fl = false;
			bol = true;

		}
		else if(ans[x][y] == inf)
		{
			ans[x][y] = 1;
			ans[y][x] = 1;
		}
	}

	if(!bol)
	{
		cout << "NO" << endl;
		return 0;
	}
	cout << "YES" << endl;
	for(int i = 0; i < m; i++)
	{
		cout << e[i].f << ' ' << e[i].s << ' ' << ans[e[i].f][e[i].s] << endl;
	}

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;
#define f first
#define s second

const int N = 2000 + 10;
const ll mod = 998244353;
const ll inf = 1e18;
//const ll inf = 1e18;

ll dp[3][N];
vector<pair<int, ll>> adj[N];
ll ans[N][N];
bool mark[N][N];
vector<pair<pair<int, int>, ll>> e;
vector<int> p;
vector<int> adj2[N];
bool mr[N];
set<pair<ll, int>> s;
int par[N];

int n, m, l, st, t;

void dfs(int u)
{
	mr[u] = 1;
	for(int i = 0; i < adj2[u].size(); i++)
	{
		int x = adj2[u][i];
		if(!mr[x])
		{
			par[x] = u;
			dfs(x);
		}
	}
	return;
}

void dij(int u, int c)
{
	for(int i = 0; i < n; i++)
	{
		dp[c][i] = inf;
	}
	dp[c][u] = 0;

	for(int i = 0; i < n; i++)
		s.insert({dp[c][i], i});

	while(!s.empty())
	{
		int x = s.begin()->s;
		s.erase(s.begin());

	 	//cout << c << ' ' << x << endl;
		for(int i = 0; i < adj[x].size(); i++)
		{
			ll y = adj[x][i].f, w = adj[x][i].s;
			if(dp[c][x] != inf && w != inf && dp[c][y] > dp[c][x] + w)
			{
				s.erase(s.lower_bound({dp[c][y], y}));
				dp[c][y] = dp[c][x] + w;
				s.insert({dp[c][y], y});
			}
		}

	}

	return;

}

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

	cin >> n >> m >> l >> st >> t;
	for(int i = 0; i < m; i++)
	{
		ll x, y, w;
		cin >> x >> y >> w;
		if(w == 0)
		{
			mark[x][y] = true;
			mark[y][x] = true;
			w = 1;
			ans[x][y] = inf;
			ans[y][x] = inf;
		}
		else
		{
			ans[x][y] =  w;
			ans[y][x] =  w;
		}
		adj[x].push_back({y, w});
		adj[y].push_back({x, w});

		e.push_back({{x, y}, w});
	}
	dij(st, 0);
	dij(t, 1);

	ll dis = dp[0][t];
//	cout << "///////////////////" << endl;
	//cout << dis << endl;
	if(dis > l)
	{
		cout << "NO" << endl;
		return 0;
	}

	for(int i = 0; i < m; i++)
	{
		int x = e[i].f.f, y = e[i].f.s, w = e[i].s;
		if(dp[0][x]+dp[1][y]+w == dis || dp[1][x]+dp[0][y]+w == dis)
		{
			adj2[x].push_back(y);
			adj2[y].push_back(x);
			//cout << x << ' ' << y << endl;
		}
	}
	dfs(st);
	int x = t;
	while(x != st)
	{
		p.push_back(x);
		x = par[x];
	}
	p.push_back(st);
	reverse(p.begin(), p.end());

	bool fl = true;
	for(int i = 1; i < p.size(); i++)
	{
		if(mark[p[i]][p[i-1]] && fl)
		{
			ans[p[i]][p[i-1]] = l-dis+1;
			ans[p[i-1]][p[i]] = l-dis+1;
			fl = false;
		}
		else if(mark[p[i]][p[i-1]])
		{
			ans[p[i-1]][p[i]] = 1;
			ans[p[i]][p[i-1]] = 1;
		}
	}

	for(int i = 0; i < n; i++)
		adj[i].clear();

	for(int i = 0; i < m; i++)
	{
		ll x = e[i].f.f, y = e[i].f.s;
		ll w = ans[x][y];
		adj[x].push_back({y, w});
		adj[y].push_back({x, w});
	}

	//cout << "//////////////" << endl;
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < adj[i].size(); j++)
		{
			int x = adj[i][j].f;
			//cout << i << ' ' << x << ' ' << adj[i][j].s << endl;
		}

	}
//	cout << "//////////////////////" << endl;

//	cout << st << endl;
	dij(st, 2);

	if(dp[2][t] >= l)
	{
		cout << "YES" << endl;

		for(int i = 0; i < m; i++)
		{
			int x = e[i].f.f, y = e[i].f.s;
			ll w = ans[x][y];
			cout << x << ' ' << y << ' ' << w << endl;
		}

	}
	else
	{
		cout << "NO" << endl;
	}

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;
#define f first
#define s second

const int N = 2000 + 10;
const ll mod = 998244353;
const ll inf = 1e17;
//const ll inf = 1e18;

ll dp[3][N];
vector<pair<int, ll>> adj[N];
ll ans[N][N];
bool mark[N][N];
vector<pair<pair<int, int>, ll>> e;
vector<int> p;
vector<int> adj2[N];
bool mr[N];
set<pair<ll, int>> s;
int par[N];

int n, m, l, st, t;

void dfs(int u)
{
	mr[u] = 1;
	for(int i = 0; i < adj2[u].size(); i++)
	{
		int x = adj2[u][i];
		if(!mr[x])
		{
			par[x] = u;
			dfs(x);
		}
	}
	return;
}

void dij(int u, int c)
{
	for(int i = 0; i < n; i++)
	{
		dp[c][i] = inf+2;
	}
	dp[c][u] = 0;

	for(int i = 0; i < n; i++)
		s.insert({dp[c][i], i});

	while(!s.empty())
	{
		int x = s.begin()->s;
		s.erase(s.begin());

	 	//cout << c << ' ' << x << endl;
		for(int i = 0; i < adj[x].size(); i++)
		{
			ll y = adj[x][i].f, w = adj[x][i].s;
			if(dp[c][y] > dp[c][x] + w)
			{
				s.erase(s.lower_bound({dp[c][y], y}));
				dp[c][y] = dp[c][x] + w;
				s.insert({dp[c][y], y});
			}
		}

	}

	return;

}

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

	cin >> n >> m >> l >> st >> t;
	for(int i = 0; i < m; i++)
	{
		ll x, y, w;
		cin >> x >> y >> w;
		if(w == 0)
		{
			mark[x][y] = true;
			mark[y][x] = true;
			w = 1;
			ans[x][y] = inf;
			ans[y][x] = inf;
		}
		else
		{
			ans[x][y] =  w;
			ans[y][x] =  w;
		}
		adj[x].push_back({y, w});
		adj[y].push_back({x, w});

		e.push_back({{x, y}, w});
	}
	dij(st, 0);
	dij(t, 1);

	ll dis = dp[0][t];
//	cout << "///////////////////" << endl;
	//cout << dis << endl;
	if(dis > l)
	{
		cout << "NO" << endl;
		return 0;
	}

	for(int i = 0; i < m; i++)
	{
		int x = e[i].f.f, y = e[i].f.s, w = e[i].s;
		if(dp[0][x]+dp[1][y]+w == dis || dp[1][x]+dp[0][y]+w == dis)
		{
			adj2[x].push_back(y);
			adj2[y].push_back(x);
			//cout << x << ' ' << y << endl;
		}
	}
	dfs(st);
	int x = t;
	while(x != st)
	{
		p.push_back(x);
		x = par[x];
	}
	p.push_back(st);
	reverse(p.begin(), p.end());

	bool fl = true;
	for(int i = 1; i < p.size(); i++)
	{
		if(mark[p[i]][p[i-1]] && fl)
		{
			ans[p[i]][p[i-1]] = l-dis+1;
			ans[p[i-1]][p[i]] = l-dis+1;
			fl = false;
		}
		else if(mark[p[i]][p[i-1]])
		{
			ans[p[i-1]][p[i]] = 1;
			ans[p[i]][p[i-1]] = 1;
		}
	}

	for(int i = 0; i < n; i++)
		adj[i].clear();

	for(int i = 0; i < m; i++)
	{
		int x = e[i].f.f, y = e[i].f.s;
		ll w = ans[x][y];
		adj[x].push_back({y, w});
		adj[y].push_back({x, w});
	}

	//cout << "//////////////" << endl;
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < adj[i].size(); j++)
		{
			int x = adj[i][j].f;
			//cout << i << ' ' << x << ' ' << adj[i][j].s << endl;
		}

	}
//	cout << "//////////////////////" << endl;

//	cout << st << endl;
	dij(st, 2);

	if(dp[2][t] == l)
	{
		cout << "YES" << endl;

		for(int i = 0; i < m; i++)
		{
			int x = e[i].f.f, y = e[i].f.s;
			ll w = ans[x][y];
			cout << x << ' ' << y << ' ' << w << endl;
		}

	}
	else
	{
		cout << "NO" << endl;
	}

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;
#define f first
#define s second

const int N = 1000 + 10;
const ll mod = 1000*1000*1000 + 7;
const ll inf = 1e16;

ll dp[N];
vector<pair<int, ll>> adj[2][N];
set<pair<ll, ll>> s;
int par[N];
vector<int> p;
vector<pair<int, int>> e;
ll ans[N][N];

int n, m;

void dij(int b, int u)
{
	for(int i = 0; i < n; i++)
	{
		dp[i] = inf;
		par[i] = -1;
	}
	dp[u] = 0;
	for(int i = 0; i < n; i++)
	{
		s.insert({dp[i], i});
	}

	while(!s.empty())
	{
		int x = s.begin()->s;
		s.erase(s.begin());
		for(int i = 0; i < adj[b][x].size(); i++)
		{
			ll v = adj[b][x][i].f, w = adj[b][x][i].s;
			if(dp[v] > dp[x]+w)
			{
				s.erase(s.lower_bound({dp[v], v}));
				dp[v] = dp[x]+w;
				par[v] = x;
				s.insert({dp[v], v});
			}
		}
	}

	return;

}

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

	ll l, s, t;
	cin >> n >> m >> l >> s >> t;
	for(int i = 0; i < m; i++)
	{
		int x, y, w;
		cin >> x >> y >> w;
		if(w != 0)
		{
			adj[1][x].push_back({y, w});
			adj[1][y].push_back({x, w});
			adj[0][x].push_back({y, w});
			adj[0][y].push_back({x, w});
			ans[x][y] = w;
			ans[y][x] = w;
		}
		else
		{
			w++;
			adj[1][x].push_back({y, w});
			adj[1][y].push_back({x, w});
			ans[x][y] = inf;
			ans[y][x] = inf;
		}
		e.push_back({x, y});

	}
	dij(0, s);
	//cout << "///" << endl;

	if(dp[t] < l)
	{
		cout << "NO" << endl;
		return 0;
	}

	dij(1, s);

	if(dp[t] > l)
	{
		cout << "NO" << endl;
		return 0;
	}
	int u = t;
	while(u != -1)
	{
		p.push_back(u);
		u = par[u];
	}
	//cout << "///" << endl;
	bool fl = true;
	bool bol = false;
	for(int i = 0; i < p.size()-1; i++)
	{
		ll x = p[i], y = p[i+1];
		if(ans[x][y] == inf && fl)
		{
			ans[x][y] =	l-dp[t]+1;
			ans[y][x] =	l-dp[t]+1;
			fl = false;
			bol = true;

		}
		else if(ans[x][y] == inf)
		{
			ans[x][y] = 1;
			ans[y][x] = 1;
		}
	}

	if(!bol && dp[t] != l)
	{
		cout << "NO" << endl;
		return 0;
	}
	cout << "YES" << endl;
	for(int i = 0; i < m; i++)
	{
		cout << e[i].f << ' ' << e[i].s << ' ' << ans[e[i].f][e[i].s] << endl;
	}

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;
#define f first
#define s second

const int N = 2000 + 10;
const ll mod = 998244353;
const ll inf = 1e16;
//const ll inf = 1e18;

ll dp[3][N];
vector<pair<int, ll>> adj[N];
ll ans[N][N];
bool mark[N][N];
vector<pair<pair<int, int>, int>> e;
vector<int> p;
vector<int> adj2[N];
bool mr[N];
set<pair<ll, int>> s;
int par[N];

int n, m, l, st, t;

void dfs(int u)
{
	mr[u] = 1;
	for(int i = 0; i < adj2[u].size(); i++)
	{
		int x = adj2[u][i];
		if(!mr[x])
		{
			par[x] = u;
			dfs(x);
		}
	}
	return;
}

void dij(int u, int c)
{
	for(int i = 0; i < n; i++)
	{
		dp[c][i] = inf+2;
	}
	dp[c][u] = 0;

	for(int i = 0; i < n; i++)
		s.insert({dp[c][i], i});

	while(!s.empty())
	{
		int x = s.begin()->s;
		s.erase(s.begin());

	 	//cout << c << ' ' << x << endl;
		for(int i = 0; i < adj[x].size(); i++)
		{
			int y = adj[x][i].f, w = adj[x][i].s;
			if(dp[c][y] > dp[c][x] + w)
			{
				s.erase(s.lower_bound({dp[c][y], y}));
				dp[c][y] = dp[c][x] + w;
				s.insert({dp[c][y], y});
			}
		}

	}

	return;

}

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

	cin >> n >> m >> l >> st >> t;
	for(int i = 0; i < m; i++)
	{
		ll x, y, w;
		cin >> x >> y >> w;
		if(w == 0)
		{
			mark[x][y] = true;
			mark[y][x] = true;
			w = 1;
			ans[x][y] = inf;
			ans[y][x] = inf;
		}
		else
		{
			ans[x][y] =  w;
			ans[y][x] =  w;
		}
		adj[x].push_back({y, w});
		adj[y].push_back({x, w});

		e.push_back({{x, y}, w});
	}
	dij(st, 0);
	dij(t, 1);

	ll dis = dp[0][t];
//	cout << "///////////////////" << endl;
	//cout << dis << endl;
	if(dis > l)
	{
		cout << "NO" << endl;
		return 0;
	}

	for(int i = 0; i < m; i++)
	{
		int x = e[i].f.f, y = e[i].f.s, w = e[i].s;
		if(dp[0][x]+dp[1][y]+w == dis || dp[1][x]+dp[0][y]+w == dis)
		{
			adj2[x].push_back(y);
			adj2[y].push_back(x);
			//cout << x << ' ' << y << endl;
		}
	}
	dfs(st);
	int x = t;
	while(x != st)
	{
		p.push_back(x);
		x = par[x];
	}
	p.push_back(st);
	reverse(p.begin(), p.end());

	bool fl = true;
	for(int i = 1; i < p.size(); i++)
	{
		if(mark[p[i]][p[i-1]] && fl)
		{
			ans[p[i]][p[i-1]] = l-dis+1;
			ans[p[i-1]][p[i]] = l-dis+1;
			fl = false;
		}
		else if(mark[p[i]][p[i-1]])
		{
			ans[p[i-1]][p[i]] = 1;
			ans[p[i]][p[i-1]] = 1;
		}
	}

	for(int i = 0; i < n; i++)
		adj[i].clear();

	for(int i = 0; i < m; i++)
	{
		int x = e[i].f.f, y = e[i].f.s;
		ll w = ans[x][y];
		adj[x].push_back({y, w});
		adj[y].push_back({x, w});
	}

	//cout << "//////////////" << endl;
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < adj[i].size(); j++)
		{
			int x = adj[i][j].f;
			//cout << i << ' ' << x << ' ' << adj[i][j].s << endl;
		}

	}
//	cout << "//////////////////////" << endl;

//	cout << st << endl;
	dij(st, 2);

	if(dp[2][t] == l)
	{
		cout << "YES" << endl;

		for(int i = 0; i < m; i++)
		{
			int x = e[i].f.f, y = e[i].f.s;
			ll w = ans[x][y];
			cout << x << ' ' << y << ' ' << w << endl;
		}

	}
	else
	{
		cout << "NO" << endl;
	}

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;
#define f first
#define s second

const int N = 2000 + 10;
const ll mod = 998244353;
const ll inf = 1e17;
//const ll inf = 1e18;

ll dp[3][N];
vector<pair<int, ll>> adj[N];
ll ans[N][N];
bool mark[N][N];
vector<pair<pair<int, int>, ll>> e;
vector<int> p;
vector<int> adj2[N];
bool mr[N];
set<pair<ll, int>> s;
int par[N];

int n, m, l, st, t;

void dfs(int u)
{
	mr[u] = 1;
	for(int i = 0; i < adj2[u].size(); i++)
	{
		int x = adj2[u][i];
		if(!mr[x])
		{
			par[x] = u;
			dfs(x);
		}
	}
	return;
}

void dij(int u, int c)
{
	for(int i = 0; i < n; i++)
	{
		dp[c][i] = inf+2;
	}
	dp[c][u] = 0;

	for(int i = 0; i < n; i++)
		s.insert({dp[c][i], i});

	while(!s.empty())
	{
		int x = s.begin()->s;
		s.erase(s.begin());

	 	//cout << c << ' ' << x << endl;
		for(int i = 0; i < adj[x].size(); i++)
		{
			ll y = adj[x][i].f, w = adj[x][i].s;
			if(dp[c][y] > dp[c][x] + w)
			{
				s.erase(s.lower_bound({dp[c][y], y}));
				dp[c][y] = dp[c][x] + w;
				s.insert({dp[c][y], y});
			}
		}

	}

	return;

}

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

	cin >> n >> m >> l >> st >> t;
	for(int i = 0; i < m; i++)
	{
		ll x, y, w;
		cin >> x >> y >> w;
		if(w == 0)
		{
			mark[x][y] = true;
			mark[y][x] = true;
			w = 1;
			ans[x][y] = inf;
			ans[y][x] = inf;
		}
		else
		{
			ans[x][y] =  w;
			ans[y][x] =  w;
		}
		adj[x].push_back({y, w});
		adj[y].push_back({x, w});

		e.push_back({{x, y}, w});
	}
	dij(st, 0);
	dij(t, 1);

	ll dis = dp[0][t];
//	cout << "///////////////////" << endl;
	//cout << dis << endl;
	if(dis > l)
	{
		cout << "NO" << endl;
		return 0;
	}

	for(int i = 0; i < m; i++)
	{
		int x = e[i].f.f, y = e[i].f.s, w = e[i].s;
		if(dp[0][x]+dp[1][y]+w == dis || dp[1][x]+dp[0][y]+w == dis)
		{
			adj2[x].push_back(y);
			adj2[y].push_back(x);
			//cout << x << ' ' << y << endl;
		}
	}
	dfs(st);
	int x = t;
	while(x != st)
	{
		p.push_back(x);
		x = par[x];
	}
	p.push_back(st);
	reverse(p.begin(), p.end());

	bool fl = true;
	for(int i = 1; i < p.size(); i++)
	{
		if(mark[p[i]][p[i-1]] && fl)
		{
			ans[p[i]][p[i-1]] = l-dis+1;
			ans[p[i-1]][p[i]] = l-dis+1;
			fl = false;
		}
		else if(mark[p[i]][p[i-1]])
		{
			ans[p[i-1]][p[i]] = 1;
			ans[p[i]][p[i-1]] = 1;
		}
	}

	for(int i = 0; i < n; i++)
		adj[i].clear();

	for(int i = 0; i < m; i++)
	{
		ll x = e[i].f.f, y = e[i].f.s;
		ll w = ans[x][y];
		adj[x].push_back({y, w});
		adj[y].push_back({x, w});
	}

	//cout << "//////////////" << endl;
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < adj[i].size(); j++)
		{
			int x = adj[i][j].f;
			//cout << i << ' ' << x << ' ' << adj[i][j].s << endl;
		}

	}
//	cout << "//////////////////////" << endl;

//	cout << st << endl;
	dij(st, 2);

	if(dp[2][t] >= l)
	{
		cout << "YES" << endl;

		for(int i = 0; i < m; i++)
		{
			int x = e[i].f.f, y = e[i].f.s;
			ll w = ans[x][y];
			cout << x << ' ' << y << ' ' << w << endl;
		}

	}
	else
	{
		cout << "NO" << endl;
	}

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;
#define f first
#define s second

const int N = 1000 + 10;
const ll mod = 1000*1000*1000 + 7;
const ll inf = 1e16;

ll dp[N], dis[N];
set<pair<ll, ll>> s;
vector<pair<int, int>> e;
vector<int> adj[N];
ll ans[N][N];
bool mark[N][N];

ll n, m, l, t;

void dij1(int u)
{
	for(int i = 0; i < n; i++)
		dp[i] = inf;
	dp[u] = 0;
	for(int i = 0; i < n; i++)
		s.insert({dp[i], i});

	while(!s.empty())
	{
		int x = s.begin()->s;
		s.erase(s.begin());
		for(int i = 0; i < adj[x].size(); i++)
		{
			int v = adj[x][i];
			ll w = ans[v][x];
			if(dp[v] > dp[x]+w)
			{
				s.erase({dp[v], v});
				dp[v] = dp[x] + w;
				s.insert({dp[v], v});
			}
		}
	}

	return;
}

void dij2(int u)
{
	for(int i = 0; i < n; i++)
		dis[i] = inf;
	dis[u] = 0;
	for(int i = 0; i < n; i++)
		s.insert({dis[i], i});

	while(!s.empty())
	{
		int x = s.begin()->s;
		s.erase(s.begin());
		for(int i = 0; i < adj[x].size(); i++)
		{
			int v = adj[x][i];

			if(mark[x][v])
			{
				ans[x][v] = max(ans[x][v], l - (dp[t]-dp[v]) - dis[x]);
				ans[v][x] = ans[x][v];
			}

			ll w = ans[v][x];
			if(dis[v] > dis[x]+w)
			{
				s.erase({dis[v], v});
				dis[v] = dis[x] + w;
				s.insert({dis[v], v});
			}
		}
	}

	return;
}

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

	int s;
	cin >> n >> m >> l >> s >> t;
	for(int i = 0; i < m; i++)
	{
		int x, y, w;
		cin >> x >> y >> w;
		adj[x].push_back(y);
		adj[y].push_back(x);
		if(w == 0)
		{
			w++;
			mark[x][y] = 1;
			mark[y][x] = 1;

		}
		ans[x][y] = w;
		ans[y][x] = w;

		e.push_back({x, y});

	}

	dij1(s);
	dij2(s);

	//for(int i = 0; i < n; i++)
		//cout << dis[i] << endl;

	if(dp[t] > l || dis[t] != l)
		cout << "NO" << endl;
	else
	{
		cout << "YES" << endl;
		for(int i = 0; i < m; i++)
			cout << e[i].f << ' ' << e[i].s << ' ' << ans[e[i].f][e[i].s] << endl;
	}

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;
#define f first
#define s second

const int N = 2000 + 10;
const ll mod = 998244353;
const ll inf = 1e18;

ll dp[3][N];
vector<pair<int, ll>> adj[N];
ll ans[N][N];
bool mark[N][N];
vector<pair<pair<int, int>, int>> e;
vector<int> p;
vector<int> adj2[N];
bool mr[N];
set<pair<ll, int>> s;
int par[N];

int n, m, l, st, t;

void dfs(int u)
{
	mr[u] = 1;
	for(int i = 0; i < adj2[u].size(); i++)
	{
		int x = adj2[u][i];
		if(!mr[x])
		{
			par[x] = u;
			dfs(x);
		}
	}
	return;
}

void dij(int u, int c)
{
	for(int i = 0; i < n; i++)
	{
		dp[c][i] = inf+2;
	}
	dp[c][u] = 0;

	for(int i = 0; i < n; i++)
		s.insert({dp[c][i], i});

	while(!s.empty())
	{
		int x = s.begin()->s;
		s.erase(s.begin());

	 	//cout << c << ' ' << x << endl;
		for(int i = 0; i < adj[x].size(); i++)
		{
			int y = adj[x][i].f, w = adj[x][i].s;
			if(dp[c][y] > dp[c][x] + w)
			{
				s.erase(s.lower_bound({dp[c][y], y}));
				dp[c][y] = dp[c][x] + w;
				s.insert({dp[c][y], y});
			}
		}

	}

	return;

}

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

	cin >> n >> m >> l >> st >> t;
	for(int i = 0; i < m; i++)
	{
		ll x, y, w;
		cin >> x >> y >> w;
		if(w == 0)
		{
			mark[x][y] = true;
			mark[y][x] = true;
			w = 1;
			ans[x][y] = inf;
			ans[y][x] = inf;
		}
		else
		{
			ans[x][y] =  w;
			ans[y][x] =  w;
		}
		adj[x].push_back({y, w});
		adj[y].push_back({x, w});

		e.push_back({{x, y}, w});
	}
	dij(st, 0);
	dij(t, 1);

	ll dis = dp[0][t];
//	cout << "///////////////////" << endl;
	//cout << dis << endl;
	if(dis > l)
	{
		cout << "NO" << endl;
		return 0;
	}

	for(int i = 0; i < m; i++)
	{
		int x = e[i].f.f, y = e[i].f.s, w = e[i].s;
		if(dp[0][x]+dp[1][y]+w == dis || dp[1][x]+dp[0][y]+w == dis)
		{
			adj2[x].push_back(y);
			adj2[y].push_back(x);
			//cout << x << ' ' << y << endl;
		}
	}
	dfs(st);
	int x = t;
	while(x != st)
	{
		p.push_back(x);
		x = par[x];
	}
	p.push_back(st);
	reverse(p.begin(), p.end());

	bool fl = true;
	for(int i = 1; i < p.size(); i++)
	{
		if(mark[p[i]][p[i-1]] && fl)
		{
			ans[p[i]][p[i-1]] = l-dis+1;
			ans[p[i-1]][p[i]] = l-dis+1;
			fl = false;
		}
		else if(mark[p[i]][p[i-1]])
		{
			ans[p[i-1]][p[i]] = 1;
			ans[p[i]][p[i-1]] = 1;
		}
	}

	for(int i = 0; i < n; i++)
		adj[i].clear();

	for(int i = 0; i < m; i++)
	{
		int x = e[i].f.f, y = e[i].f.s;
		ll w = ans[x][y];
		adj[x].push_back({y, w});
		adj[y].push_back({x, w});
	}

	//cout << "//////////////" << endl;
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < adj[i].size(); j++)
		{
			int x = adj[i][j].f;
		//	cout << i << ' ' << x << ' ' << adj[i][j].s << endl;
		}

	}
//	cout << "//////////////////////" << endl;

//	cout << st << endl;
	dij(st, 2);

	if(dp[2][t] == l)
	{
		cout << "YES" << endl;

		for(int i = 0; i < m; i++)
		{
			int x = e[i].f.f, y = e[i].f.s;
			ll w = ans[x][y];
			cout << x << ' ' << y << ' ' << w << endl;
		}

	}
	else
	{
		cout << "NO" << endl;
	}

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;
#define f first
#define s second

const int N = 1000 + 10;
const ll mod = 1000*1000*1000 + 7;
const ll inf = 1e10;

ll dp[N];
vector<pair<int, ll>> adj[2][N];
set<pair<ll, ll>> s;
int par[N];
vector<int> p;
vector<pair<int, int>> e;
ll ans[N][N];

int n, m;

void dij(int b, int u)
{
	for(int i = 0; i < n; i++)
	{
		dp[i] = inf;
		par[i] = -1;
	}
	dp[u] = 0;
	for(int i = 0; i < n; i++)
	{
		s.insert({dp[i], i});
	}

	while(!s.empty())
	{
		int x = s.begin()->s;
		s.erase(s.begin());
		for(int i = 0; i < adj[b][x].size(); i++)
		{
			int v = adj[b][x][i].f, w = adj[b][x][i].s;
			if(dp[v] > dp[x]+w)
			{
				s.erase(s.lower_bound({dp[v], v}));
				dp[v] = dp[x]+w;
				par[v] = x;
				s.insert({dp[v], v});
			}
		}
	}

	return;

}

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

	int l, s, t;
	cin >> n >> m >> l >> s >> t;
	for(int i = 0; i < m; i++)
	{
		int x, y, w;
		cin >> x >> y >> w;
		if(w != 0)
		{
			adj[1][x].push_back({y, w});
			adj[1][y].push_back({x, w});
			adj[0][x].push_back({y, w});
			adj[0][y].push_back({x, w});
			ans[x][y] = w;
		}
		else
		{
			w++;
			adj[1][x].push_back({y, w});
			adj[1][y].push_back({x, w});
			ans[x][y] = inf;
			ans[y][x] = inf;
		}
		e.push_back({x, y});

	}
	dij(0, s);
	//cout << "///" << endl;

	if(dp[t] < l)
	{
		cout << "NO" << endl;
		return 0;
	}

	dij(1, s);

	if(dp[t] > l)
	{
		cout << "NO" << endl;
		return 0;
	}
	int u = t;
	while(u != -1)
	{
		p.push_back(u);
		u = par[u];
	}
	//cout << "///" << endl;
	bool fl = true;
	bool bol = false;
	for(int i = 0; i < p.size()-1; i++)
	{
		int x = p[i], y = p[i+1];
		if(ans[x][y] == inf && fl)
		{
			ans[x][y] =	l-dp[t]+1;
			ans[y][x] =	l-dp[t]+1;
			fl = false;
			bol = true;

		}
		else if(ans[x][y] == inf)
		{
			ans[x][y] = 1;
			ans[y][x] = 1;
		}
	}

	if(!bol && dp[t] != l)
	{
		cout << "NO" << endl;
		return 0;
	}
	cout << "YES" << endl;
	for(int i = 0; i < m; i++)
	{
		cout << e[i].f << ' ' << e[i].s << ' ' << ans[e[i].f][e[i].s] << endl;
	}

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1005;
const long long INF = 1E15 + 7;
typedef long long int64;

int n, m, L, s, t;
long long dFinish[MAXN], dStart[MAXN];

priority_queue <pair <long long, int>, vector <pair <long long, int> >, greater<pair<long long, int> > >
 pq;

vector <pair <int, int64> > adj[MAXN];

vector <pair <int, int> > edges;

int64 d[MAXN][MAXN];

int main() {
	// freopen("input.txt", "r", stdin);
	cin >> n >> m >> L >> s >> t;
	for (int u = 0; u < n; ++u)
	for (int v = 0; v < n; ++v)
		d[u][v] = INF;
	for (int i = 0; i < m; ++i) {
		int u, v;
		int64 w;
		cin >> u >> v >> w;
		adj[u].push_back(make_pair(v, w));
		adj[v].push_back(make_pair(u, w));
		d[u][v] = d[v][u] = w;
		edges.push_back(make_pair(u, v));
	}
	for (int i = 0; i < n; ++i)
		dFinish[i] = INF;
	dFinish[t] = 0;
	pq.push(make_pair(0, t));
	while (pq.size()) {
		int64 dist = pq.top().first;
		int u = pq.top().second; pq.pop();
		if (dist > dFinish[u]) continue;
		for (int i = 0; i < adj[u].size(); ++i) {
			int v = adj[u][i].first, w = adj[u][i].second;
			if (w == 0) continue;
			if (dFinish[v] > dFinish[u] + w) {
				dFinish[v] = dFinish[u] + w;
				pq.push(make_pair(dFinish[v], v));
			}
		}
	}

	if (dFinish[s] < INF) {
		if (dFinish[s] < L) {
			puts("NO");
			return 0;
		}
	}

	for (int i = 0; i < n; ++i)
		dStart[i] = INF;
	dStart[s] = 0;
	pq.push(make_pair(0, s));
	while (pq.size()) {
		int64 dist = pq.top().first;
		int u = pq.top().second;
		pq.pop();
		if (dist > dStart[u]) continue;
		for (int i = 0; i < adj[u].size(); ++i) {
			int v = adj[u][i].first, w = adj[u][i].second;
			if (w == 0) {
				if (d[u][v] != 0) {
					w = d[u][v];
				}
				else if (dFinish[v] == INF) {
					d[u][v] = d[v][u] = 1;
					w = 1;
				}
				else {
					int64 newW = L - dStart[u] - dFinish[v];
					if (newW <= 0) {
						puts("NO");
						return 0;
					}
					d[u][v] = d[v][u] = newW;
					w = newW;
				}
			}
			if (dStart[v] > dStart[u] + w) {
				dStart[v] = dStart[u] + w;
				pq.push(make_pair(dStart[v], v));
			}
		}
	}

	if (dStart[t] == INF || dStart[t] != L) {
		puts("NO");
		return 0;
	}
	puts("YES");
	for (int i = 0; i < edges.size(); ++i) {
		if (d[edges[i].first][edges[i].second])
			d[edges[i].first][edges[i].second] = L;
		cout << edges[i].first <<" "<<edges[i].second << " "<<d[edges[i].first][edges[i].second] << endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1005;
const long long INF = 1E15 + 7;
typedef long long int64;

int n, m, L, s, t;
long long dFinish[MAXN], dStart[MAXN];

priority_queue <pair <long long, int>, vector <pair <long long, int> >, greater<pair<long long, int> > >
 pq;

vector <pair <int, int64> > adj[MAXN];

vector <pair <int, int> > edges;

int64 d[MAXN][MAXN];

int main() {
	// freopen("input.txt", "r", stdin);
	cin >> n >> m >> L >> s >> t;
	for (int u = 0; u < n; ++u)
	for (int v = 0; v < n; ++v)
		d[u][v] = INF;
	for (int i = 0; i < m; ++i) {
		int u, v;
		int64 w;
		cin >> u >> v >> w;
		adj[u].push_back(make_pair(v, w));
		adj[v].push_back(make_pair(u, w));
		d[u][v] = d[v][u] = w;
		edges.push_back(make_pair(u, v));
	}
	for (int i = 0; i < n; ++i)
		dFinish[i] = INF;
	dFinish[t] = 0;
	pq.push(make_pair(0, t));
	while (pq.size()) {
		int64 dist = pq.top().first;
		int u = pq.top().second; pq.pop();
		if (dist > dFinish[u]) continue;
		for (int i = 0; i < adj[u].size(); ++i) {
			int v = adj[u][i].first, w = adj[u][i].second;
			if (w == 0) continue;
			if (dFinish[v] > dFinish[u] + w) {
				dFinish[v] = dFinish[u] + w;
				pq.push(make_pair(dFinish[v], v));
			}
		}
	}

	if (dFinish[s] < INF) {
		if (dFinish[s] < L) {
			puts("NO");
			return 0;
		}
	}

	for (int i = 0; i < n; ++i)
		dStart[i] = INF;
	dStart[s] = 0;
	pq.push(make_pair(0, s));
	while (pq.size()) {
		int64 dist = pq.top().first;
		int u = pq.top().second;
		pq.pop();
		if (dist > dStart[u]) continue;
		for (int i = 0; i < adj[u].size(); ++i) {
			int v = adj[u][i].first, w = adj[u][i].second;
			if (w == 0) {
				if (d[u][v] != 0) {
					w = d[u][v];
				}
				else if (dFinish[v] == INF) {
					d[u][v] = d[v][u] = 1;
					w = 1;
				}
				else {
					int64 newW = L - dStart[u] - dFinish[v];
					// if (newW <= 0) {
					// 	cout << u <<" "<<v << endl;
					// 	puts("NO");
					// 	return 0;
					// }
					d[u][v] = d[v][u] = newW;
					w = newW;
				}
			}
			if (dStart[v] > dStart[u] + w) {
				dStart[v] = dStart[u] + w;
				pq.push(make_pair(dStart[v], v));
			}
		}
	}

	if (dStart[t] == INF || dStart[t] != L) {
		puts("NO");
		return 0;
	}
	puts("YES");
	for (int i = 0; i < edges.size(); ++i) {
		if (d[edges[i].first][edges[i].second] <= 0)
			d[edges[i].first][edges[i].second] = L;
		cout << edges[i].first <<" "<<edges[i].second << " "<<d[edges[i].first][edges[i].second] << endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1005;
const int INF = 1E9 + 7;

int n, m, dFinish[MAXN], dStart[MAXN], L, s, t;

priority_queue <pair <int, int>, vector <pair <int, int> >, greater<pair<int, int> > >
 pq;

vector <pair <int, int> > adj[MAXN], edges;

int d[MAXN][MAXN];

int main() {
	// freopen("input.txt", "r", stdin);
	cin >> n >> m >> L >> s >> t;
	for (int u = 0; u < n; ++u)
	for (int v = 0; v < n; ++v)
		d[u][v] = INF;
	for (int i = 0; i < m; ++i) {
		int u, v, w;
		cin >> u >> v >> w;
		adj[u].push_back(make_pair(v, w));
		adj[v].push_back(make_pair(u, w));
		d[u][v] = d[v][u] = w;
		edges.push_back(make_pair(u, v));
	}
	for (int i = 0; i < n; ++i)
		dFinish[i] = INF;
	dFinish[t] = 0;
	pq.push(make_pair(0, t));
	while (pq.size()) {
		int dist = pq.top().first;
		int u = pq.top().second; pq.pop();
		if (dist > dFinish[u]) continue;
		for (int i = 0; i < adj[u].size(); ++i) {
			int v = adj[u][i].first, w = adj[u][i].second;
			if (w == 0) continue;
			if (dFinish[v] > dFinish[u] + w) {
				dFinish[v] = dFinish[u] + w;
				pq.push(make_pair(dFinish[v], v));
			}
		}
	}

	if (dFinish[s] < INF) {
		if (dFinish[s] < L) {
			puts("NO");
			return 0;
		}
	}

	for (int i = 0; i < n; ++i)
		dStart[i] = INF;
	dStart[s] = 0;
	pq.push(make_pair(0, s));
	while (pq.size()) {
		int dist = pq.top().first;
		int u = pq.top().second;
		pq.pop();
		if (dist > dStart[u]) continue;
		for (int i = 0; i < adj[u].size(); ++i) {
			int v = adj[u][i].first, w = adj[u][i].second;
			if (w == 0) {
				if (d[u][v] != 0) {
					w = d[u][v];
				}
				else if (dFinish[v] == INF) {
					d[u][v] = d[v][u] = 1;
					w = 1;
				}
				else {
					int newW = L - dStart[u] - dFinish[v];
					if (newW <= 0) {
						puts("NO");
						return 0;
					}
					d[u][v] = d[v][u] = newW;
					w = newW;
				}
			}
			if (dStart[v] > dStart[u] + w) {
				dStart[v] = dStart[u] + w;
				pq.push(make_pair(dStart[v], v));
			}
		}
	}

	if (dStart[t] == INF || dStart[t] != L) {
		puts("NO");
		return 0;
	}
	puts("YES");
	for (int i = 0; i < edges.size(); ++i) {
		cout << edges[i].first <<" "<<edges[i].second << " "<<d[edges[i].first][edges[i].second] << endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1005;
const long long INF = 1E15 + 7;
typedef long long int64;

int n, m, L, s, t;
long long dFinish[MAXN], dStart[MAXN];

priority_queue <pair <long long, int>, vector <pair <long long, int> >, greater<pair<long long, int> > >
 pq;

vector <pair <int, int64> > adj[MAXN];

vector <pair <int, int> > edges;

int64 d[MAXN][MAXN];

int main() {
	// freopen("input.txt", "r", stdin);
	cin >> n >> m >> L >> s >> t;
	for (int u = 0; u < n; ++u)
	for (int v = 0; v < n; ++v)
		d[u][v] = INF;
	for (int i = 0; i < m; ++i) {
		int u, v;
		int64 w;
		cin >> u >> v >> w;
		adj[u].push_back(make_pair(v, w));
		adj[v].push_back(make_pair(u, w));
		d[u][v] = d[v][u] = w;
		edges.push_back(make_pair(u, v));
	}
	for (int i = 0; i < n; ++i)
		dFinish[i] = INF;
	dFinish[t] = 0;
	pq.push(make_pair(0, t));
	while (pq.size()) {
		int64 dist = pq.top().first;
		int u = pq.top().second; pq.pop();
		if (dist > dFinish[u]) continue;
		for (int i = 0; i < adj[u].size(); ++i) {
			int v = adj[u][i].first, w = adj[u][i].second;
			if (w == 0) continue;
			if (dFinish[v] > dFinish[u] + w) {
				dFinish[v] = dFinish[u] + w;
				pq.push(make_pair(dFinish[v], v));
			}
		}
	}

	if (dFinish[s] < INF) {
		if (dFinish[s] < L) {
			puts("NO");
			return 0;
		}
	}

	for (int i = 0; i < n; ++i)
		dStart[i] = INF;
	dStart[s] = 0;
	pq.push(make_pair(0, s));
	while (pq.size()) {
		int64 dist = pq.top().first;
		int u = pq.top().second;
		pq.pop();
		if (dist > dStart[u]) continue;
		for (int i = 0; i < adj[u].size(); ++i) {
			int v = adj[u][i].first, w = adj[u][i].second;
			if (w == 0) {
				if (d[u][v] != 0) {
					w = d[u][v];
				}
				else if (dFinish[v] == INF) {
					d[u][v] = d[v][u] = 1;
					w = 1;
				}
				else {
					int64 newW = max(1LL, L - dStart[u] - dFinish[v]);
					// if (newW <= 0) {
					// 	cout << u <<" "<<v << endl;
					// 	puts("NO");
					// 	return 0;
					// }
					d[u][v] = d[v][u] = newW;
					w = newW;
				}
			}
			if (dStart[v] > dStart[u] + w) {
				dStart[v] = dStart[u] + w;
				pq.push(make_pair(dStart[v], v));
			}
		}
	}
	// cout << dStart[3] << endl;

	if (dStart[t] == INF || dStart[t] != L) {
		puts("NO");
		return 0;
	}
	puts("YES");
	for (int i = 0; i < edges.size(); ++i) {
		if (d[edges[i].first][edges[i].second] <= 0)
			d[edges[i].first][edges[i].second] = L;
		cout << edges[i].first <<" "<<edges[i].second << " "<<d[edges[i].first][edges[i].second] << endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1005;
const int INF = 1E15 + 7;
typedef long long int64;

int n, m, L, s, t;
long long dFinish[MAXN], dStart[MAXN];

priority_queue <pair <long long, int>, vector <pair <long long, int> >, greater<pair<long long, int> > >
 pq;

vector <pair <int, int> > adj[MAXN], edges;

int d[MAXN][MAXN];

int main() {
	// freopen("input.txt", "r", stdin);
	cin >> n >> m >> L >> s >> t;
	for (int u = 0; u < n; ++u)
	for (int v = 0; v < n; ++v)
		d[u][v] = INF;
	for (int i = 0; i < m; ++i) {
		int u, v, w;
		cin >> u >> v >> w;
		adj[u].push_back(make_pair(v, w));
		adj[v].push_back(make_pair(u, w));
		d[u][v] = d[v][u] = w;
		edges.push_back(make_pair(u, v));
	}
	for (int i = 0; i < n; ++i)
		dFinish[i] = INF;
	dFinish[t] = 0;
	pq.push(make_pair(0, t));
	while (pq.size()) {
		int dist = pq.top().first;
		int u = pq.top().second; pq.pop();
		if (dist > dFinish[u]) continue;
		for (int i = 0; i < adj[u].size(); ++i) {
			int v = adj[u][i].first, w = adj[u][i].second;
			if (w == 0) continue;
			if (dFinish[v] > dFinish[u] + w) {
				dFinish[v] = dFinish[u] + w;
				pq.push(make_pair(dFinish[v], v));
			}
		}
	}

	if (dFinish[s] < INF) {
		if (dFinish[s] < L) {
			puts("NO");
			return 0;
		}
	}

	for (int i = 0; i < n; ++i)
		dStart[i] = INF;
	dStart[s] = 0;
	pq.push(make_pair(0, s));
	while (pq.size()) {
		int dist = pq.top().first;
		int u = pq.top().second;
		pq.pop();
		if (dist > dStart[u]) continue;
		for (int i = 0; i < adj[u].size(); ++i) {
			int v = adj[u][i].first, w = adj[u][i].second;
			if (w == 0) {
				if (d[u][v] != 0) {
					w = d[u][v];
				}
				else if (dFinish[v] == INF) {
					d[u][v] = d[v][u] = 1;
					w = 1;
				}
				else {
					int newW = L - dStart[u] - dFinish[v];
					if (newW <= 0) {
						puts("NO");
						return 0;
					}
					d[u][v] = d[v][u] = newW;
					w = newW;
				}
			}
			if (dStart[v] > dStart[u] + w) {
				dStart[v] = dStart[u] + w;
				pq.push(make_pair(dStart[v], v));
			}
		}
	}

	if (dStart[t] == INF || dStart[t] != L) {
		puts("NO");
		return 0;
	}
	puts("YES");
	for (int i = 0; i < edges.size(); ++i) {
		cout << edges[i].first <<" "<<edges[i].second << " "<<d[edges[i].first][edges[i].second] << endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1005;
const int INF = 1E9 + 7;
typedef long long int64;

int n, m, L, s, t;
long long dFinish[MAXN], dStart[MAXN];

priority_queue <pair <long long, int>, vector <pair <long long, int> >, greater<pair<long long, int> > >
 pq;

vector <pair <int, int> > adj[MAXN], edges;

int d[MAXN][MAXN];

int main() {
	// freopen("input.txt", "r", stdin);
	cin >> n >> m >> L >> s >> t;
	for (int u = 0; u < n; ++u)
	for (int v = 0; v < n; ++v)
		d[u][v] = INF;
	for (int i = 0; i < m; ++i) {
		int u, v, w;
		cin >> u >> v >> w;
		adj[u].push_back(make_pair(v, w));
		adj[v].push_back(make_pair(u, w));
		d[u][v] = d[v][u] = w;
		edges.push_back(make_pair(u, v));
	}
	for (int i = 0; i < n; ++i)
		dFinish[i] = INF;
	dFinish[t] = 0;
	pq.push(make_pair(0, t));
	while (pq.size()) {
		int dist = pq.top().first;
		int u = pq.top().second; pq.pop();
		if (dist > dFinish[u]) continue;
		for (int i = 0; i < adj[u].size(); ++i) {
			int v = adj[u][i].first, w = adj[u][i].second;
			if (w == 0) continue;
			if (dFinish[v] > dFinish[u] + w) {
				dFinish[v] = dFinish[u] + w;
				pq.push(make_pair(dFinish[v], v));
			}
		}
	}

	if (dFinish[s] < INF) {
		if (dFinish[s] < L) {
			puts("NO");
			return 0;
		}
	}

	for (int i = 0; i < n; ++i)
		dStart[i] = INF;
	dStart[s] = 0;
	pq.push(make_pair(0, s));
	while (pq.size()) {
		int dist = pq.top().first;
		int u = pq.top().second;
		pq.pop();
		if (dist > dStart[u]) continue;
		for (int i = 0; i < adj[u].size(); ++i) {
			int v = adj[u][i].first, w = adj[u][i].second;
			if (w == 0) {
				if (d[u][v] != 0) {
					w = d[u][v];
				}
				else if (dFinish[v] == INF) {
					d[u][v] = d[v][u] = 1;
					w = 1;
				}
				else {
					int newW = L - dStart[u] - dFinish[v];
					if (newW <= 0) {
						puts("NO");
						return 0;
					}
					d[u][v] = d[v][u] = newW;
					w = newW;
				}
			}
			if (dStart[v] > dStart[u] + w) {
				dStart[v] = dStart[u] + w;
				pq.push(make_pair(dStart[v], v));
			}
		}
	}

	if (dStart[t] == INF || dStart[t] != L) {
		puts("NO");
		return 0;
	}
	puts("YES");
	for (int i = 0; i < edges.size(); ++i) {
		cout << edges[i].first <<" "<<edges[i].second << " "<<d[edges[i].first][edges[i].second] << endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1005;
const long long INF = 1E15 + 7;
typedef long long int64;

int n, m, L, s, t;
long long dFinish[MAXN], dStart[MAXN];

priority_queue <pair <long long, int>, vector <pair <long long, int> >, greater<pair<long long, int> > >
 pq;

vector <pair <int, int64> > adj[MAXN];

vector <pair <int, int> > edges;

int64 d[MAXN][MAXN];

int main() {
	// freopen("input.txt", "r", stdin);
	cin >> n >> m >> L >> s >> t;
	for (int u = 0; u < n; ++u)
	for (int v = 0; v < n; ++v)
		d[u][v] = INF;
	for (int i = 0; i < m; ++i) {
		int u, v;
		int64 w;
		cin >> u >> v >> w;
		adj[u].push_back(make_pair(v, w));
		adj[v].push_back(make_pair(u, w));
		d[u][v] = d[v][u] = w;
		edges.push_back(make_pair(u, v));
	}
	for (int i = 0; i < n; ++i)
		dFinish[i] = INF;
	dFinish[t] = 0;
	pq.push(make_pair(0, t));
	while (pq.size()) {
		int64 dist = pq.top().first;
		int u = pq.top().second; pq.pop();
		if (dist > dFinish[u]) continue;
		for (int i = 0; i < adj[u].size(); ++i) {
			int v = adj[u][i].first, w = adj[u][i].second;
			if (w == 0) continue;
			if (dFinish[v] > dFinish[u] + w) {
				dFinish[v] = dFinish[u] + w;
				pq.push(make_pair(dFinish[v], v));
			}
		}
	}

	if (dFinish[s] < INF) {
		if (dFinish[s] < L) {
			puts("NO");
			return 0;
		}
	}

	for (int i = 0; i < n; ++i)
		dStart[i] = INF;
	dStart[s] = 0;
	pq.push(make_pair(0, s));
	while (pq.size()) {
		int64 dist = pq.top().first;
		int u = pq.top().second;
		pq.pop();
		if (dist > dStart[u]) continue;
		for (int i = 0; i < adj[u].size(); ++i) {
			int v = adj[u][i].first, w = adj[u][i].second;
			if (w == 0) {
				if (d[u][v] != 0) {
					w = d[u][v];
				}
				else if (dFinish[v] == INF) {
					d[u][v] = d[v][u] = 1;
					w = 1;
				}
				else {
					int64 newW = L - dStart[u] - dFinish[v];
					if (newW <= 0) {
						puts("NO");
						return 0;
					}
					d[u][v] = d[v][u] = newW;
					w = newW;
				}
			}
			if (dStart[v] > dStart[u] + w) {
				dStart[v] = dStart[u] + w;
				pq.push(make_pair(dStart[v], v));
			}
		}
	}

	if (dStart[t] == INF || dStart[t] != L) {
		puts("NO");
		return 0;
	}
	puts("YES");
	for (int i = 0; i < edges.size(); ++i) {
		cout << edges[i].first <<" "<<edges[i].second << " "<<d[edges[i].first][edges[i].second] << endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1005;
const long long INF = 1E15 + 7;
typedef long long int64;

int n, m, L, s, t;
long long dFinish[MAXN], dStart[MAXN];

priority_queue <pair <long long, int>, vector <pair <long long, int> >, greater<pair<long long, int> > >
 pq;

vector <pair <int, int64> > adj[MAXN];

vector <pair <int, int> > edges;

int64 d[MAXN][MAXN];

int main() {
	// freopen("input.txt", "r", stdin);
	cin >> n >> m >> L >> s >> t;
	for (int u = 0; u < n; ++u)
	for (int v = 0; v < n; ++v)
		d[u][v] = INF;
	for (int i = 0; i < m; ++i) {
		int u, v;
		int64 w;
		cin >> u >> v >> w;
		adj[u].push_back(make_pair(v, w));
		adj[v].push_back(make_pair(u, w));
		d[u][v] = d[v][u] = w;
		edges.push_back(make_pair(u, v));
	}
	for (int i = 0; i < n; ++i)
		dFinish[i] = INF;
	dFinish[t] = 0;
	pq.push(make_pair(0, t));
	while (pq.size()) {
		int64 dist = pq.top().first;
		int u = pq.top().second; pq.pop();
		if (dist > dFinish[u]) continue;
		for (int i = 0; i < adj[u].size(); ++i) {
			int v = adj[u][i].first, w = adj[u][i].second;
			if (w == 0) continue;
			if (dFinish[v] > dFinish[u] + w) {
				dFinish[v] = dFinish[u] + w;
				pq.push(make_pair(dFinish[v], v));
			}
		}
	}

	if (dFinish[s] < INF) {
		if (dFinish[s] < L) {
			puts("NO");
			return 0;
		}
	}

	for (int i = 0; i < n; ++i)
		dStart[i] = INF;
	dStart[s] = 0;
	pq.push(make_pair(0, s));
	while (pq.size()) {
		int64 dist = pq.top().first;
		int u = pq.top().second;
		pq.pop();
		if (dist > dStart[u]) continue;
		for (int i = 0; i < adj[u].size(); ++i) {
			int v = adj[u][i].first, w = adj[u][i].second;
			if (w == 0) {
				if (d[u][v] != 0) {
					w = d[u][v];
				}
				else if (dFinish[v] == INF) {
					d[u][v] = d[v][u] = 1;
					w = 1;
				}
				else {
					int64 newW = L - dStart[u] - dFinish[v];
					if (newW <= 0) {
						puts("NO");
						return 0;
					}
					d[u][v] = d[v][u] = newW;
					w = newW;
				}
			}
			if (dStart[v] > dStart[u] + w) {
				dStart[v] = dStart[u] + w;
				pq.push(make_pair(dStart[v], v));
			}
		}
	}

	if (dStart[t] == INF || dStart[t] != L) {
		puts("NO");
		return 0;
	}
	puts("YES");
	for (int i = 0; i < edges.size(); ++i) {
		if (d[edges[i].first][edges[i].second] == 0)
			d[edges[i].first][edges[i].second] = L;
		cout << edges[i].first <<" "<<edges[i].second << " "<<d[edges[i].first][edges[i].second] << endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1005;
const long long INF = 1E15 + 7;
typedef long long int64;

int n, m, L, s, t;
long long dFinish[MAXN], dStart[MAXN];

priority_queue <pair <long long, int>, vector <pair <long long, int> >, greater<pair<long long, int> > >
 pq;

vector <pair <int, int64> > adj[MAXN];

vector <pair <int, int> > edges;

int64 d[MAXN][MAXN];

int main() {
	freopen("input.txt", "r", stdin);
	cin >> n >> m >> L >> s >> t;
	for (int u = 0; u < n; ++u)
	for (int v = 0; v < n; ++v)
		d[u][v] = INF;
	for (int i = 0; i < m; ++i) {
		int u, v;
		int64 w;
		cin >> u >> v >> w;
		adj[u].push_back(make_pair(v, w));
		adj[v].push_back(make_pair(u, w));
		d[u][v] = d[v][u] = w;
		edges.push_back(make_pair(u, v));
	}
	for (int i = 0; i < n; ++i)
		dFinish[i] = INF;
	dFinish[t] = 0;
	pq.push(make_pair(0, t));
	while (pq.size()) {
		int64 dist = pq.top().first;
		int u = pq.top().second; pq.pop();
		if (dist > dFinish[u]) continue;
		for (int i = 0; i < adj[u].size(); ++i) {
			int v = adj[u][i].first, w = adj[u][i].second;
			if (w == 0) continue;
			if (dFinish[v] > dFinish[u] + w) {
				dFinish[v] = dFinish[u] + w;
				pq.push(make_pair(dFinish[v], v));
			}
		}
	}

	if (dFinish[s] < INF) {
		if (dFinish[s] < L) {
			puts("NO");
			return 0;
		}
	}

	for (int i = 0; i < n; ++i)
		dStart[i] = INF;
	dStart[s] = 0;
	pq.push(make_pair(0, s));
	while (pq.size()) {
		int64 dist = pq.top().first;
		int u = pq.top().second;
		pq.pop();
		if (dist > dStart[u]) continue;
		for (int i = 0; i < adj[u].size(); ++i) {
			int v = adj[u][i].first, w = adj[u][i].second;
			if (w == 0) {
				if (d[u][v] != 0) {
					w = d[u][v];
				}
				else if (dFinish[v] == INF) {
					d[u][v] = d[v][u] = 1;
					w = 1;
				}
				else {
					int64 newW = max(1LL, L - dStart[u] - dFinish[v]);
					// if (newW <= 0) {
					// 	cout << u <<" "<<v << endl;
					// 	puts("NO");
					// 	return 0;
					// }
					d[u][v] = d[v][u] = newW;
					w = newW;
				}
			}
			if (dStart[v] > dStart[u] + w) {
				dStart[v] = dStart[u] + w;
				pq.push(make_pair(dStart[v], v));
			}
		}
	}
	// cout << dStart[3] << endl;

	if (dStart[t] == INF || dStart[t] != L) {
		puts("NO");
		return 0;
	}
	puts("YES");
	for (int i = 0; i < edges.size(); ++i) {
		if (d[edges[i].first][edges[i].second] <= 0)
			d[edges[i].first][edges[i].second] = L;
		cout << edges[i].first <<" "<<edges[i].second << " "<<d[edges[i].first][edges[i].second] << endl;
	}
}


#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcount(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 1003;
const int M = 10004;

int n, m, L, st, en;
int ff[M], tt[M], cc[M];
vector<int> adj[N];
ll dist[N];
int par[N];
int ee[N][N];

bool dij() {
	MMS(dist, 0x3f);
	MMS(par, -1);
	priority_queue<pair<ll, int>, vector<pair<ll, int> >, greater<pair<ll, int> > > Q;
	Q.push(mp(0, st));
	dist[st] = 0;
	while (SZ(Q)) {
		int cur = Q.top().second;
		ll d = Q.top().first;
		Q.pop();
		if (d != dist[cur])
			continue;
		if (cur == en) {
			if (d > L)
				return 0;
			bool f = 1;
			int cnt = 0;
			for (int u = cur, nxt = par[u]; nxt != -1; u = nxt, nxt = par[nxt]) {
				cnt += !cc[ee[u][nxt]];
			}
			int len = d - cnt;
			int v = (L - len) / cnt, r = L - len - v * (cnt - 1);
			for (int u = cur, nxt = par[u]; nxt != -1; u = nxt, nxt = par[nxt]) {
				if (cc[ee[u][nxt]] == 0) {
					cc[ee[u][nxt]] = v;
					if (f) {
						cc[ee[u][nxt]] = r;
						f = 0;
					}
				}
			}
			return 1;
		}
		for (int i = 0; i < SZ(adj[cur]); i++) {
			int e = adj[cur][i];
			int to = (ff[e] == cur) ? tt[e] : ff[e];
			ll dd = d + cc[e];
			if (cc[e] == 0) {
				dd += 1;
			}
			if (dist[to] > dd) {
				par[to] = cur;
				dist[to] = dd;
				Q.push(mp(dd, to));
			}
		}
	}
	return 0;
}

ll dij0() {
	MMS(dist, 0x3f);
	priority_queue<pair<ll, int>, vector<pair<ll, int> >, greater<pair<ll, int> > > Q;
	Q.push(mp(0, st));
	dist[st] = 0;
	while (SZ(Q)) {
		int cur = Q.top().second;
		ll d = Q.top().first;
		Q.pop();
		if (d != dist[cur])
			continue;
		if (cur == en) {
			return d;
		}
		for (int i = 0; i < SZ(adj[cur]); i++) {
			int e = adj[cur][i];
			int to = (ff[e] == cur) ? tt[e] : ff[e];
			ll dd = d + cc[e];
			if (cc[e] && dist[to] > dd) {
				par[to] = cur;
				dist[to] = dd;
				Q.push(mp(dd, to));
			}
		}
	}
	return -1;
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n >> m >> L >> st >> en;
	for (int i = 0; i < m; i++) {
		cin >> ff[i] >> tt[i] >> cc[i];
		adj[ff[i]].pb(i);
		adj[tt[i]].pb(i);
		ee[ff[i]][tt[i]] = ee[tt[i]][ff[i]] = i;
	}
	ll res = dij0();
	if (res != -1 && res <= L) {
		if (res < L) {
			cout << "NO\n";
		} else {
			cout << "YES\n";
			for (int i = 0; i < m; i++)
				cout << ff[i] << " " << tt[i] << " " << (cc[i] ? cc[i] : OO) << "\n";
		}
		return 0;
	} else if (dij()) {
		cout << "YES\n";
		for (int i = 0; i < m; i++)
			cout << ff[i] << " " << tt[i] << " " << (cc[i] ? cc[i] : OO) << "\n";
	} else {
		cout << "NO\n";
	}
	return 0;
}


#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcount(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 1003;
const int M = 10004;

int n, m, L, st, en;
int ff[M], tt[M];
ll cc[M];
vector<int> adj[N];
ll dist[N], distToEN[N];
int ee[N][N];

void dijEN() {
	MMS(distToEN, 0x3f);
	priority_queue<pair<ll, int>, vector<pair<ll, int> >, greater<pair<ll, int> > > Q;
	Q.push(mp(0, en));
	distToEN[en] = 0;
	while (SZ(Q)) {
		int cur = Q.top().second;
		ll d = Q.top().first;
		Q.pop();
		if (d != distToEN[cur])
			continue;
		for (int i = 0; i < SZ(adj[cur]); i++) {
			int e = adj[cur][i];
			int to = (ff[e] == cur) ? tt[e] : ff[e];
			ll dd = d + cc[e];
			if (cc[e] == 0) {
				dd += 1;
			}
			if (distToEN[to] > dd) {
				distToEN[to] = dd;
				Q.push(mp(dd, to));
			}
		}
	}
}

void dijST() {
	MMS(dist, 0x3f);
	priority_queue<pair<ll, int>, vector<pair<ll, int> >, greater<pair<ll, int> > > Q;
	Q.push(mp(0, st));
	dist[st] = 0;
	while (SZ(Q)) {
		int cur = Q.top().second;
		ll d = Q.top().first;
		Q.pop();
		if (d != dist[cur])
			continue;
		for (int i = 0; i < SZ(adj[cur]); i++) {
			int e = adj[cur][i];
			int to = (ff[e] == cur) ? tt[e] : ff[e];
			if (cc[e] == 0) {
				cc[e] = max(1LL, L - d - distToEN[to]);
			}
			ll dd = d + cc[e];
			if (dist[to] > dd) {
				dist[to] = dd;
				Q.push(mp(dd, to));
			}
		}
	}
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n >> m >> L >> st >> en;
	for (int i = 0; i < m; i++) {
		cin >> ff[i] >> tt[i] >> cc[i];
		adj[ff[i]].pb(i);
		adj[tt[i]].pb(i);
		ee[ff[i]][tt[i]] = ee[tt[i]][ff[i]] = i;
	}
	dijEN();
	if (distToEN[st] > L) {
		cout << "NO\n";
	} else {
		dijST();
		cout << "YES\n";
		for (int i = 0; i < m; i++)
			cout << ff[i] << " " << tt[i] << " " << (cc[i] ? cc[i] : OO) << "\n";
	}
	return 0;
}


#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcount(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 1003;
const int M = 10004;

int n, m, L, st, en;
int ff[M], tt[M];
ll cc[M];
vector<int> adj[N];
ll dist[N], distToEN[N];
int ee[N][N];

ll dij0() {
	MMS(dist, 0x3f);
	priority_queue<pair<ll, int>, vector<pair<ll, int> >, greater<pair<ll, int> > > Q;
	Q.push(mp(0, st));
	dist[st] = 0;
	while (SZ(Q)) {
		int cur = Q.top().second;
		ll d = Q.top().first;
		Q.pop();
		if (d != dist[cur])
			continue;
		if (cur == en) {
			return d;
		}
		for (int i = 0; i < SZ(adj[cur]); i++) {
			int e = adj[cur][i];
			int to = (ff[e] == cur) ? tt[e] : ff[e];
			ll dd = d + cc[e];
			if (cc[e] && dist[to] > dd) {
				dist[to] = dd;
				Q.push(mp(dd, to));
			}
		}
	}
	return -1;
}

bool dijEN() {
	MMS(distToEN, 0x3f);
	priority_queue<pair<ll, int>, vector<pair<ll, int> >, greater<pair<ll, int> > > Q;
	Q.push(mp(0, en));
	distToEN[en] = 0;
	while (SZ(Q)) {
		int cur = Q.top().second;
		ll d = Q.top().first;
		Q.pop();
		if (d != distToEN[cur])
			continue;
		if (cur == st) {
			return d <= L;
		}
		for (int i = 0; i < SZ(adj[cur]); i++) {
			int e = adj[cur][i];
			int to = (ff[e] == cur) ? tt[e] : ff[e];
			ll dd = d + cc[e];
			if (cc[e] == 0) {
				dd += 1;
			}
			if (distToEN[to] > dd) {
				distToEN[to] = dd;
				Q.push(mp(dd, to));
			}
		}
	}
	return 0;
}

bool dijST() {
	MMS(dist, 0x3f);
	priority_queue<pair<ll, int>, vector<pair<ll, int> >, greater<pair<ll, int> > > Q;
	Q.push(mp(0, st));
	dist[st] = 0;
	while (SZ(Q)) {
		int cur = Q.top().second;
		ll d = Q.top().first;
		Q.pop();
		if (d != dist[cur])
			continue;
		if (cur == en) {
			return 1;
		}
		for (int i = 0; i < SZ(adj[cur]); i++) {
			int e = adj[cur][i];
			int to = (ff[e] == cur) ? tt[e] : ff[e];
			ll dd = d + cc[e];
			if (cc[e] == 0) {
				dd += max(1LL, L - d - distToEN[to]);
			}
			if (dist[to] > dd) {
				if (cc[e] == 0)
					cc[e] = max(1LL, L - d - distToEN[to]);
				dist[to] = dd;
				Q.push(mp(dd, to));
			}
		}
	}
	return 0;
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n >> m >> L >> st >> en;
	for (int i = 0; i < m; i++) {
		cin >> ff[i] >> tt[i] >> cc[i];
		adj[ff[i]].pb(i);
		adj[tt[i]].pb(i);
		ee[ff[i]][tt[i]] = ee[tt[i]][ff[i]] = i;
	}
	ll res = dij0();
	if (res != -1 && res <= L) {
		if (res < L) {
			cout << "NO\n";
		} else {
			cout << "YES\n";
			for (int i = 0; i < m; i++)
				cout << ff[i] << " " << tt[i] << " " << (cc[i] ? cc[i] : OO) << "\n";
		}
		return 0;
	} else if (dijEN()) {
		dijST();
		cout << "YES\n";
		for (int i = 0; i < m; i++)
			cout << ff[i] << " " << tt[i] << " " << (cc[i] ? cc[i] : OO) << "\n";
	} else {
		cout << "NO\n";
	}
	return 0;
}