#include<bits/stdc++.h>
#define pb push_back
//#define mp make_pair
#define fastread ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define openfile freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define f(i, x, y) for(int i = x; i < y; i++)
#define all(X) X.begin(), X.end()
#define int long long
#define key pair<int, int>
#define keyd pair<double, double>
#define ff first
#define ss second
#define double long double
int mod = 1e9 + 7;
const int inf = 2e8;
using namespace std;

int dist[3][1001], pre[1001];
vector<key> g[1001];
int x = 0, n;

class cmp{
    public:
        bool operator()(int a, int b)
        {
            return dist[x][a] < dist[x][b] || (dist[x][a] == dist[x][b] && a < b);
        }
};

void bfs(int x, int src)
{
    f(i, 0, 1001) dist[x][i] = inf;
    dist[x][src] = 0;
    pre[src] = -1;
    set<int, cmp> s; s.insert(src);
    while(!s.empty())
    {
        int t = *s.begin(); s.erase(s.begin());
        for(key i : g[t])
        {
            if(dist[x][i.ff] > dist[x][t] + i.ss)
            {
                if(s.find(t) != s.end())
                    s.erase(t);
                dist[x][i.ff] = dist[x][t] + i.ss;
                s.insert(i.ff);
                pre[i.ff] = t;
            }
        }
    }
//    cout<<x<<"      "; f(i, 0, n) cout<<dist[x][i]<<" "; cout<<"\n";
}

main()
{
    int M, L, S,  T; cin>>n>>M>>L>>S>>T;
    map<key, int> m;
    set<key> ss;

    f(i, 0, M)
    {
        int s, d, w; cin>>s>>d>>w;
        if(w == 0)
        {
            g[s].pb({d, inf}); g[d].pb({s, inf});
        }
        else
        {
            g[s].pb({d, w}); g[d].pb({s, w});
        }
        m[{s, d}] = w; m[{d, s}] = w;
        ss.insert({s, d});
    }
  //  f(i, 0, n){ f(j, 0, g[i].size()) cout<<g[i][j].ff<<" "<<g[i][j].ss<<"   "; cout<<"\n"; }
     bfs(0, S); bfs(1, T);

    f(i, 0, n)
        f(j, 0, g[i].size())
            if(g[i][j].ss == inf)
                g[i][j].ss = 1;
    bfs(2, T);

    if(dist[2][S] > L)
    {
        cout<<"NO"; return 0;
    }

//    f(i, 0, n) cout<<pre[i]<<" "; cout<<"\n";
    int cnt = 0, s = S;
    vector<int> v; v.pb(s);
    while(s != T)
    {
        int t = pre[s];
        if(m[{s, t}] == 0) cnt++;
        s = t;  v.pb(s);
    }
//    cout<<cnt<<"\n";
    s = S;
    int tl = L;
    L -= (dist[2][S] - cnt);
    int sum = 0;
 //   for(int i : v) cout<<i<<" "; cout<<"\n";
    f(i, 0, v.size()-1)
    {
        if(m[{v[i], v[i+1]}] != 0)
        {
            sum += m[{v[i], v[i+1]}]; continue;
        }
        int t = sum, y = dist[0][v[i+1]] - sum;
    //    cout<<y<<" ";
        f(j, i+1, v.size() - 1)
        {
            if(m[{v[j], v[j+1]}] == 0) t++;
            else t += m[{v[j], v[j+1]}];
            y = min(y, dist[0][v[j+1]] - t);
    //        cout<<i<<" "<<j<<" "<<t<<" "<<y<<"\n";
        }
        //cout<<y<<" ";
        y = min(y, L-cnt+1); L -= y; cnt--;
        m[{v[i], v[i+1]}] = m[{v[i+1], v[i]}] = y;
        sum += y;
    //    cout<<v[i]<<" "<<v[i+1]<<" "<<L<<" "<<y<<" "<<cnt<<" "<<sum<<"\n\n";
    }

    f(i, 0, n)
        f(j, 0, g[i].size())
            g[i][j].ss = m[{i, g[i][j].ff}] = ((m[{i, g[i][j].ff}] <= 0)? 1e15 : m[{i, g[i][j].ff}]);
 //   f(i, 0, n){ f(j, 0, g[i].size()) cout<<g[i][j].ff<<" "<<g[i][j].ss<<"   "; cout<<"\n"; }
    bfs(0, S);

    if(dist[0][T] != tl)
    {
        cout<<"NO"; return 0;
    }

    cout<<"YES\n";
    for(pair<key, int> k : m)
    {
        if(ss.find(k.ff) == ss.end()) continue;
        cout<<k.ff.ff<<" "<<k.ff.ss<<" "<<k.ss<<"\n";
    }
}


#include<bits/stdc++.h>
#define pb push_back
//#define mp make_pair
#define fastread ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define openfile freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define f(i, x, y) for(int i = x; i < y; i++)
#define all(X) X.begin(), X.end()
#define int long long
#define key pair<int, int>
#define keyd pair<double, double>
#define ff first
#define ss second
#define double long double
int mod = 1e9 + 7;
const int inf = 2e18;
using namespace std;

int dist[3][1001], pre[1001];
vector<key> g[1001];
int x = 0, n;

class cmp{
    public:
        bool operator()(int a, int b)
        {
            return dist[x][a] < dist[x][b] || (dist[x][a] == dist[x][b] && a < b);
        }
};

void bfs(int x, int src)
{
    f(i, 0, 1001) dist[x][i] = inf;
    dist[x][src] = 0;
    pre[src] = -1;
    set<int, cmp> s; s.insert(src);
    while(!s.empty())
    {
        int t = *s.begin(); s.erase(s.begin());
        for(key i : g[t])
        {
            if(dist[x][i.ff] > dist[x][t] + i.ss)
            {
                if(s.find(t) != s.end())
                    s.erase(t);
                dist[x][i.ff] = dist[x][t] + i.ss;
                s.insert(i.ff);
                pre[i.ff] = t;
            }
        }
    }
//    cout<<x<<"      "; f(i, 0, n) cout<<dist[x][i]<<" "; cout<<"\n";
}

main()
{
    fastread;
    int M, L, S,  T; cin>>n>>M>>L>>S>>T;
    int m[1001][1001];
    f(i, 0, 1001) f(j, 0, 1001) m[i][j] = inf;
    set<key> ss;

    f(i, 0, M)
    {
        int s, d, w; cin>>s>>d>>w;
        if(w == 0)
        {
            g[s].pb({d, inf}); g[d].pb({s, inf});
        }
        else
        {
            g[s].pb({d, w}); g[d].pb({s, w});
        }
        m[s][d] = w; m[d][s] = w;
        ss.insert({s, d});
    }
  //  f(i, 0, n){ f(j, 0, g[i].size()) cout<<g[i][j].ff<<" "<<g[i][j].ss<<"   "; cout<<"\n"; }
     bfs(0, S); bfs(1, T);

    f(i, 0, n)
        f(j, 0, g[i].size())
            if(g[i][j].ss == inf)
                g[i][j].ss = 1;
    bfs(2, T);

    if(dist[2][S] > L)
    {
        cout<<"NO"; return 0;
    }

//    f(i, 0, n) cout<<pre[i]<<" "; cout<<"\n";
    int cnt = 0, s = S;
    vector<int> v; v.pb(s);
    while(s != T)
    {
        int t = pre[s];
        if(m[s][t] == 0) cnt++;
        s = t;  v.pb(s);
    }
//    cout<<cnt<<"\n";
    s = S;
    int tl = L;
    L -= (dist[2][S] - cnt);
    int sum = 0;
 //   for(int i : v) cout<<i<<" "; cout<<"\n";
    f(i, 0, v.size()-1)
    {
        if(m[v[i]][v[i+1]] != 0)
        {
            sum += m[v[i]][v[i+1]]; continue;
        }
        int t = sum, y = dist[0][v[i+1]] - sum;
    //    cout<<y<<" ";
        f(j, i+1, v.size() - 1)
        {
            if(m[v[j]][v[j+1]] == 0) t++;
            else t += m[v[j]][v[j+1]];
            y = min(y, dist[0][v[j+1]] - t);
    //        cout<<i<<" "<<j<<" "<<t<<" "<<y<<"\n";
        }
        //cout<<y<<" ";
        y = min(y, L-cnt+1); L -= y; cnt--;
        m[v[i]][v[i+1]] = m[v[i+1]][v[i]] = y;
        sum += y;
    //    cout<<v[i]<<" "<<v[i+1]<<" "<<L<<" "<<y<<" "<<cnt<<" "<<sum<<"\n\n";
    }

    f(i, 0, n)
        f(j, 0, g[i].size())
            g[i][j].ss = m[i][g[i][j].ff] = ((m[i][g[i][j].ff] <= 0)? 1e15 : m[i][g[i][j].ff]);
 //   f(i, 0, n){ f(j, 0, g[i].size()) cout<<g[i][j].ff<<" "<<g[i][j].ss<<"   "; cout<<"\n"; }
    bfs(0, S);

    if(dist[0][T] != tl)
    {
        cout<<"NO"; return 0;
    }

    cout<<"YES\n";
    f(i, 0, n)
    {
        f(j, 0, n)
        {
            if(ss.find({i, j}) == ss.end()) continue;
            cout<<i<<" "<<j<<" "<<m[i][j]<<"\n";
        }
    }
}


#include<bits/stdc++.h>
#define pb push_back
//#define mp make_pair
#define fastread ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define openfile freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define f(i, x, y) for(int i = x; i < y; i++)
#define all(X) X.begin(), X.end()
#define int long long
#define key pair<int, int>
#define keyd pair<double, double>
#define ff first
#define ss second
#define double long double
int mod = 1e9 + 7;
const int inf = 2e18;
using namespace std;

int dist[3][1001], pre[1001];
vector<key> g[1001];
int x = 0, n;

class cmp{
    public:
        bool operator()(int a, int b)
        {
            return dist[x][a] < dist[x][b] || (dist[x][a] == dist[x][b] && a < b);
        }
};

void bfs(int x, int src)
{
    int cnt = 0;
    f(i, 0, 1001) dist[x][i] = inf;
    dist[x][src] = 0;
    pre[src] = -1;
    set<int, cmp> s; s.insert(src);
    while(!s.empty())
    {
        int t = *s.begin(); s.erase(s.begin());
        for(key i : g[t])
        {
            cnt++;
            if(dist[x][i.ff] > dist[x][t] + i.ss)
            {
                if(s.find(t) != s.end())
                    s.erase(t);
                dist[x][i.ff] = dist[x][t] + i.ss;
                s.insert(i.ff);
                pre[i.ff] = t;
            }
            if(cnt > 2e5)
            {
                cout<<t<<" "<<i.ff<<" "<<i.ss<<"\n";
                return ;
            }
        }
    }
//    cout<<x<<"      "; f(i, 0, n) cout<<dist[x][i]<<" "; cout<<"\n";
}

main()
{
    fastread;
    int M, L, S,  T; cin>>n>>M>>L>>S>>T;
    int m[1001][1001];
    f(i, 0, 1001) f(j, 0, 1001) m[i][j] = inf;
    set<key> ss;

    f(i, 0, M)
    {
        int s, d, w; cin>>s>>d>>w;
        if(w == 0)
        {
            g[s].pb({d, inf}); g[d].pb({s, inf});
        }
        else
        {
            g[s].pb({d, w}); g[d].pb({s, w});
        }
        m[s][d] = w; m[d][s] = w;
        ss.insert({s, d});
    }
  //  f(i, 0, n){ f(j, 0, g[i].size()) cout<<g[i][j].ff<<" "<<g[i][j].ss<<"   "; cout<<"\n"; }
     bfs(0, S); bfs(1, T);

    f(i, 0, n)
        f(j, 0, g[i].size())
            if(g[i][j].ss == inf)
                g[i][j].ss = 1;
    bfs(2, T);

    if(dist[2][S] > L)
    {
        cout<<"NO"; return 0;
    }

//    f(i, 0, n) cout<<pre[i]<<" "; cout<<"\n";
    int cnt = 0, s = S;
    vector<int> v; v.pb(s);
    while(s != T)
    {
        int t = pre[s];
        if(m[s][t] == 0) cnt++;
        s = t;  v.pb(s);
    }
//    cout<<cnt<<"\n";
    s = S;
    int tl = L;
    L -= (dist[2][S] - cnt);
    int sum = 0;
 //   for(int i : v) cout<<i<<" "; cout<<"\n";
    f(i, 0, v.size()-1)
    {
        if(m[v[i]][v[i+1]] != 0)
        {
            sum += m[v[i]][v[i+1]]; continue;
        }
        int t = sum, y = dist[0][v[i+1]] - sum;
    //    cout<<y<<" ";
        f(j, i+1, v.size() - 1)
        {
            if(m[v[j]][v[j+1]] == 0) t++;
            else t += m[v[j]][v[j+1]];
            y = min(y, dist[0][v[j+1]] - t);
    //        cout<<i<<" "<<j<<" "<<t<<" "<<y<<"\n";
        }
        //cout<<y<<" ";
        y = min(y, L-cnt+1); L -= y; cnt--;
        m[v[i]][v[i+1]] = m[v[i+1]][v[i]] = y;
        sum += y;
    //    cout<<v[i]<<" "<<v[i+1]<<" "<<L<<" "<<y<<" "<<cnt<<" "<<sum<<"\n\n";
    }

    f(i, 0, n)
        f(j, 0, g[i].size())
            g[i][j].ss = m[i][g[i][j].ff] = ((m[i][g[i][j].ff] <= 0)? 1e15 : m[i][g[i][j].ff]);
 //   f(i, 0, n){ f(j, 0, g[i].size()) cout<<g[i][j].ff<<" "<<g[i][j].ss<<"   "; cout<<"\n"; }
    bfs(0, S);

    if(dist[0][T] != tl)
    {
        cout<<"NO"; return 0;
    }

    cout<<"YES\n";
    f(i, 0, n)
    {
        f(j, 0, n)
        {
            if(ss.find({i, j}) == ss.end()) continue;
            cout<<i<<" "<<j<<" "<<m[i][j]<<"\n";
        }
    }
}


#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <math.h>
#include <map>
#include <set>
#include <stdio.h>
#include <stack>
#include <unordered_map>
#define ll long long
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pib pair<int, bool>
#define pdd pair<double, double>
#define pss pair<string, string>
#pragma comment(linker, "/STACK:251777215")
using namespace std;

const ll maxn = 1011;
const ll maxm = 10001;
const ll maxk = 1001;
const ll maxq = 1000001;
const ll margin = 1001;
const ll maxseg = 262144;
const ll secret_number = -87468267;
const pii secret_pair = make_pair(secret_number, secret_number);
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const int iinf = 2147483647 / 2;
const double pi = 3.141592653589793238462643383279502884;
const double eps = 1e-7;
const string something_very_long = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
const string govno = "g";
string impossible = "-1";

void printout(string str)
{
	cout << str;
	exit(0);
}

void Impossible()
{
	printout(impossible);
}

void print(char x, int numb)
{
	for (int i = 0; i < numb; ++i)
		cout << x;
}

int n, m, L, S, T;
vector<ll> edges[maxn];
vector<ll> weights[maxn];
vector<ll> numbers[maxn];
ll distances[maxn];
ll distances2[maxn];
priority_queue<pll> q;

void set_edge_len(int v, int numb, ll val)
{
	weights[v][numb] = val;
	weights[edges[v][numb]][numbers[v][numb]] = val;
}

void update(int v, int numb, ll* dist)
{
	if (dist[edges[v][numb]] > dist[v] + weights[v][numb])
	{
		dist[edges[v][numb]] = dist[v] + weights[v][numb];
		q.push(pll(-dist[edges[v][numb]], edges[v][numb]));
	}
}

void say_yes()
{
	cout << "YES\n";
	for (int i = 0; i < maxn; ++i)
		for (int j = 0; j < edges[i].size(); ++j)
			if (i < edges[i][j])
				cout << i << ' ' << edges[i][j] << ' ' << ((weights[i][j] == 0) ? (ll)1e15 : weights[i][j]) << '\n';
	exit(0);
}

void say_no()
{
	printout("NO");
}

int main()
{
	fill(distances, distances + maxn, inf);
	fill(distances2, distances2 + maxn, inf);
	cin >> n >> m >> L >> S >> T;
	for (int i = 0; i < m; ++i)
	{
		int x, y, w;
		cin >> x >> y >> w;
		edges[x].push_back(y);
		edges[y].push_back(x);
		weights[x].push_back(w);
		weights[y].push_back(w);
		numbers[x].push_back(edges[y].size() - 1);
		numbers[y].push_back(edges[x].size() - 1);
	}

	q.push(pll(0, S));
	distances[S] = 0;
	while (!q.empty())
	{
		ll cur_elem = q.top().ss;
		q.pop();
		for (int i = 0; i < edges[cur_elem].size(); ++i)
			if (weights[cur_elem][i] != 0)
				update(cur_elem, i, distances);
	}
	if (distances[T] < L)
		say_no();

	// here solution starts
	q.push(pll(0, T));
	distances2[T] = 0;
	while (!q.empty())
	{
		ll cur_elem = q.top().ss;
		q.pop();
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			if (weights[cur_elem][i] == 0)
				set_edge_len(cur_elem, i, max((ll)1, L - distances2[cur_elem] - distances[next]));
			update(cur_elem, i, distances2);
			if (L == distances2[cur_elem] + distances[next])
				say_yes();
		}
	}
	say_no();
	return 0;
}
/*

*/


#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <math.h>
#include <map>
#include <set>
#include <stdio.h>
#include <stack>
#include <unordered_map>
#define ll long long
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pib pair<int, bool>
#define pdd pair<double, double>
#define pss pair<string, string>
#pragma comment(linker, "/STACK:251777215")
using namespace std;

const ll maxn = 1001;
const ll maxm = 10001;
const ll maxk = 1001;
const ll maxq = 1000001;
const ll margin = 1001;
const ll maxseg = 262144;
const ll secret_number = -87468267;
const pii secret_pair = make_pair(secret_number, secret_number);
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const int iinf = 2147483647 / 2;
const double pi = 3.141592653589793238462643383279502884;
const double eps = 1e-7;
const string something_very_long = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
const string govno = "g";
string impossible = "-1";

void printout(string str)
{
	cout << str;
	exit(0);
}

void Impossible()
{
	printout(impossible);
}

void print(char x, int numb)
{
	for (int i = 0; i < numb; ++i)
		cout << x;
}

int n, m, L, S, T;
vector<ll> edges[maxn];
vector<ll> weights[maxn];
vector<ll> numbers[maxn];
ll distances[maxn];
ll distances2[maxn];

void say_yes()
{
	cout << "YES\n";
	map<pii, int> weightes;
	for (int i = 0; i < maxn; ++i)
	{
		for (int j = 0; j < edges[i].size(); ++j)
		{
			if (weights[i][j] == 0)
				continue;
			if (i <= edges[i][j])
				weightes[pii(i, edges[i][j])] = weights[i][j];
			else
				weightes[pii(edges[i][j], i)] = weights[i][j];
		}
	}
	for (auto it = weightes.begin(); it != weightes.end(); it++)
	{
		cout << it->first.first << ' ' << it->first.second << ' ' << it->second << '\n';
	}
}

void say_no()
{
	printout("NO");
}

int main()
{
	for (int i = 0; i < maxn; ++i)
		distances[i] = inf;
	for (int i = 0; i < maxn; ++i)
		distances2[i] = inf;
	cin >> n >> m >> L >> S >> T;
	for (int i = 0; i < m; ++i)
	{
		int x, y, w;
		cin >> x >> y >> w;
		edges[x].push_back(y);
		edges[y].push_back(x);
		weights[x].push_back(w);
		weights[y].push_back(w);
		numbers[x].push_back(edges[y].size() - 1);
		numbers[y].push_back(edges[x].size() - 1);
	}
	priority_queue<pair<ll, ll>> q;
	q.push(pll(0, S));
	distances[S] = 0;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
				continue;
			if (distances[next] > distances[cur_elem] + next_dist)
			{
				distances[next] = distances[cur_elem] + next_dist;
				q.push(pll(-distances[next], next));
			}
		}
	}
	if (distances[T] == L)
		say_yes();
	if (distances[T] < L)
		say_no();
	q.push(pll(0, T));
	distances2[T] = 0;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances2[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
				continue;
			if (distances2[next] > distances2[cur_elem] + next_dist)
			{
				distances2[next] = distances2[cur_elem] + next_dist;
				q.push(pll(-distances2[next], next));
			}
		}
	}

	// here solution starts
	q.push(pll(0, S));
	bool f = false;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
			{
				if (distances2[next] == inf)
				{
					distances[next] = distances[cur_elem] + 1;
					weights[cur_elem][i] = 1;
					weights[next][numbers[cur_elem][i]] = 1;
					q.push(pll(-distances[next], next));
				}
				else
				{
					weights[cur_elem][i] = max((ll)1, L - distances[cur_elem] - distances2[next]);
					weights[next][numbers[cur_elem][i]] = max((ll)1, L - distances[cur_elem] - distances2[next]);
					if (L - distances[cur_elem] - distances2[next] >= 1)
					{
						f = true;
						break;
					}
					distances[next] = distances[cur_elem] + weights[cur_elem][i];
					q.push(pll(-distances[next], next));
				}
			}
			else if (distances[next] >= distances[cur_elem] + next_dist)
			{
				distances[next] = distances[cur_elem] + next_dist;
				q.push(pll(-distances[next], next));
			}
		}
		if (f)
			break;
	}

	for (int i = 0; i < maxn; ++i)
	{
		for (int j = 0; j < weights[i].size(); ++i)
		{
			if (weights[i][j] == 0)
			{
				weights[i][j] = 1e15;
				weights[edges[i][j]][numbers[i][j]] = 1e15;
			}
		}
	}

	// check
	for (int i = 0; i < maxn; ++i)
		distances[i] = inf;
	q.push(pll(0, S));
	distances[S] = 0;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
				continue;
			if (distances[next] > distances[cur_elem] + next_dist)
			{
				distances[next] = distances[cur_elem] + next_dist;
				q.push(pll(-distances[next], next));
			}
		}
	}

	if (distances[T] == L)
		say_yes();
	else
		say_no();
	return 0;
}
/*
2 1 1000000000 1 0
0 1 999999999
*/


#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <math.h>
#include <map>
#include <set>
#include <stdio.h>
#include <stack>
#include <unordered_map>
#define ll long long
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pib pair<int, bool>
#define pdd pair<double, double>
#define pss pair<string, string>
#pragma comment(linker, "/STACK:251777215")
using namespace std;

const ll maxn = 1011;
const ll maxm = 10001;
const ll maxk = 1001;
const ll maxq = 1000001;
const ll margin = 1001;
const ll maxseg = 262144;
const ll secret_number = -87468267;
const pii secret_pair = make_pair(secret_number, secret_number);
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const int iinf = 2147483647 / 2;
const double pi = 3.141592653589793238462643383279502884;
const double eps = 1e-7;
const string something_very_long = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
const string govno = "g";
string impossible = "-1";

void printout(string str)
{
	cout << str;
	exit(0);
}

void Impossible()
{
	printout(impossible);
}

void print(char x, int numb)
{
	for (int i = 0; i < numb; ++i)
		cout << x;
}

int n, m, L, S, T;
vector<ll> edges[maxn];
vector<ll> weights[maxn];
vector<ll> numbers[maxn];
ll distances[maxn];
ll distances2[maxn];
priority_queue<pll> q;

void set_edge_len(int v, int numb, ll val)
{
	weights[v][numb] = val;
	weights[edges[v][numb]][numbers[v][numb]] = val;
}

void update(int v, int numb, ll* dist)
{
	if (dist[edges[v][numb]] > dist[v] + weights[v][numb])
	{
		dist[edges[v][numb]] = dist[v] + weights[v][numb];
		q.push(pll(-dist[edges[v][numb]], edges[v][numb]));
	}
}

void say_yes()
{
	cout << "YES\n";
	for (int i = 0; i < maxn; ++i)
		for (int j = 0; j < edges[i].size(); ++j)
			if (i < edges[i][j])
				cout << i << ' ' << edges[i][j] << ' ' << ((weights[i][j] == 0) ? (ll)1e15 : weights[i][j]) << '\n';
	exit(0);
}

void say_no()
{
	printout("NO");
}

int main()
{
	fill(distances, distances + maxn, inf);
	fill(distances2, distances2 + maxn, inf);
	cin >> n >> m >> L >> S >> T;
	for (int i = 0; i < m; ++i)
	{
		int x, y, w;
		cin >> x >> y >> w;
		edges[x].push_back(y);
		edges[y].push_back(x);
		weights[x].push_back(w);
		weights[y].push_back(w);
		numbers[x].push_back(edges[y].size() - 1);
		numbers[y].push_back(edges[x].size() - 1);
	}

	q.push(pll(0, S));
	distances[S] = 0;
	while (!q.empty())
	{
		ll cur_elem = q.top().ss;
		q.pop();
		for (int i = 0; i < edges[cur_elem].size(); ++i)
			if (weights[cur_elem][i] != 0)
				update(cur_elem, i, distances);
	}
	if (distances[T] == L)
		say_yes();
	if (distances[T] < L)
		say_no();

	// here solution starts
	q.push(pll(0, T));
	distances2[T] = 0;
	while (!q.empty())
	{
		ll cur_elem = q.top().ss;
		q.pop();
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			if (weights[cur_elem][i] == 0)
				set_edge_len(cur_elem, i, max((ll)1, L - distances2[cur_elem] - distances[next]));
			if (L - distances2[cur_elem] - distances[next] >= 1)
				say_yes();
			update(cur_elem, i, distances2);
		}
	}
	say_no();
	return 0;
}
/*

*/


#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <math.h>
#include <map>
#include <set>
#include <stdio.h>
#include <stack>
#include <unordered_map>
#define ll long long
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pib pair<int, bool>
#define pdd pair<double, double>
#define pss pair<string, string>
#pragma comment(linker, "/STACK:251777215")
using namespace std;

const ll maxn = 1001;
const ll maxm = 10001;
const ll maxk = 1001;
const ll maxq = 1000001;
const ll margin = 1001;
const ll maxseg = 262144;
const ll secret_number = -87468267;
const pii secret_pair = make_pair(secret_number, secret_number);
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const int iinf = 2147483647 / 2;
const double pi = 3.141592653589793238462643383279502884;
const double eps = 1e-7;
const string something_very_long = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
const string govno = "g";
string impossible = "-1";

void printout(string str)
{
	cout << str;
	exit(0);
}

void Impossible()
{
	printout(impossible);
}

void print(char x, int numb)
{
	for (int i = 0; i < numb; ++i)
		cout << x;
}

int n, m, L, S, T;
vector<ll> edges[maxn];
vector<ll> weights[maxn];
vector<ll> numbers[maxn];
ll distances[maxn];
ll distances2[maxn];

void say_yes()
{
	cout << "YES\n";
	map<pii, int> weightes;
	for (int i = 0; i < maxn; ++i)
	{
		for (int j = 0; j < edges[i].size(); ++j)
		{
			if (weights[i][j] == 0)
				continue;
			if (i <= edges[i][j])
				weightes[pii(i, edges[i][j])] = weights[i][j];
			else
				weightes[pii(edges[i][j], i)] = weights[i][j];
		}
	}
	for (auto it = weightes.begin(); it != weightes.end(); it++)
	{
		cout << it->first.first << ' ' << it->first.second << ' ' << it->second << '\n';
	}
	exit(0);
}

void say_no()
{
	printout("NO");
}

int main()
{
	for (int i = 0; i < maxn; ++i)
		distances[i] = inf;
	for (int i = 0; i < maxn; ++i)
		distances2[i] = inf;
	cin >> n >> m >> L >> S >> T;
	for (int i = 0; i < m; ++i)
	{
		int x, y, w;
		cin >> x >> y >> w;
		edges[x].push_back(y);
		edges[y].push_back(x);
		weights[x].push_back(w);
		weights[y].push_back(w);
		numbers[x].push_back(edges[y].size() - 1);
		numbers[y].push_back(edges[x].size() - 1);
	}
	priority_queue<pair<ll, ll>> q;
	q.push(pll(0, S));
	distances[S] = 0;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
				continue;
			if (distances[next] > distances[cur_elem] + next_dist)
			{
				distances[next] = distances[cur_elem] + next_dist;
				q.push(pll(-distances[next], next));
			}
		}
	}
	if (distances[T] == L)
		say_yes();
	if (distances[T] < L)
		say_no();
	q.push(pll(0, T));
	distances2[T] = 0;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances2[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
				continue;
			if (distances2[next] > distances2[cur_elem] + next_dist)
			{
				distances2[next] = distances2[cur_elem] + next_dist;
				q.push(pll(-distances2[next], next));
			}
		}
	}

	// here solution starts
	q.push(pll(0, S));
	bool f = false;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
			{
				if (distances2[next] == inf)
				{
					distances[next] = distances[cur_elem] + 1;
					weights[cur_elem][i] = 1;
					weights[next][numbers[cur_elem][i]] = 1;
					q.push(pll(-distances[next], next));
				}
				else
				{
					weights[cur_elem][i] = max((ll)1, L - distances[cur_elem] - distances2[next]);
					weights[next][numbers[cur_elem][i]] = max((ll)1, L - distances[cur_elem] - distances2[next]);
					if (L - distances[cur_elem] - distances2[next] >= 1)
					{
						f = true;
						break;
					}
					distances[next] = distances[cur_elem] + weights[cur_elem][i];
					q.push(pll(-distances[next], next));
				}
			}
			else if (distances[next] >= distances[cur_elem] + next_dist)
			{
				distances[next] = distances[cur_elem] + next_dist;
				q.push(pll(-distances[next], next));
			}
		}
		if (f)
			break;
	}

	for (int i = 0; i < maxn; ++i)
	{
		for (int j = 0; j < weights[i].size(); ++i)
		{
			if (weights[i][j] == 0)
			{
				weights[i][j] = 1e15;
				weights[edges[i][j]][numbers[i][j]] = 1e15;
			}
		}
	}

	// check
	for (int i = 0; i < maxn; ++i)
		distances[i] = inf;
	q.push(pll(0, S));
	distances[S] = 0;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
				continue;
			if (distances[next] > distances[cur_elem] + next_dist)
			{
				distances[next] = distances[cur_elem] + next_dist;
				q.push(pll(-distances[next], next));
			}
		}
	}

	if (distances[T] == L)
		say_yes();
	else
		say_no();
	return 0;
}
/*
2 1 1000000000 1 0
0 1 999999999
*/


#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <math.h>
#include <map>
#include <set>
#include <stdio.h>
#include <stack>
#include <unordered_map>
#define ll long long
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pib pair<int, bool>
#define pdd pair<double, double>
#define pss pair<string, string>
#pragma comment(linker, "/STACK:251777215")
using namespace std;

const ll maxn = 1011;
const ll maxm = 10001;
const ll maxk = 1001;
const ll maxq = 1000001;
const ll margin = 1001;
const ll maxseg = 262144;
const ll secret_number = -87468267;
const pii secret_pair = make_pair(secret_number, secret_number);
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const int iinf = 2147483647 / 2;
const double pi = 3.141592653589793238462643383279502884;
const double eps = 1e-7;
const string something_very_long = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
const string govno = "g";
string impossible = "-1";

void printout(string str)
{
	cout << str;
	exit(0);
}

void Impossible()
{
	printout(impossible);
}

void print(char x, int numb)
{
	for (int i = 0; i < numb; ++i)
		cout << x;
}

int n, m, L, S, T;
vector<ll> edges[maxn];
vector<ll> weights[maxn];
vector<ll> numbers[maxn];
ll distances[maxn];
ll distances2[maxn];

void say_yes()
{
	cout << "YES\n";
	map<pii, ll> weightes;
	for (int i = 0; i < maxn; ++i)
	{
		for (int j = 0; j < edges[i].size(); ++j)
		{
			if (weights[i][j] == 0)
			{
				weights[i][j] = 1e15;
				weights[edges[i][j]][numbers[i][j]] = 1e15;
			}
			if (i <= edges[i][j])
				weightes[pii(i, edges[i][j])] = weights[i][j];
			else
				weightes[pii(edges[i][j], i)] = weights[i][j];
		}
	}
	for (auto it = weightes.begin(); it != weightes.end(); it++)
	{
		cout << it->first.first << ' ' << it->first.second << ' ' << it->second << '\n';
	}
	exit(0);
}

void say_no()
{
	printout("NO");
}

int main()
{
	for (int i = 0; i < maxn; ++i)
		distances[i] = inf;
	for (int i = 0; i < maxn; ++i)
		distances2[i] = inf;
	cin >> n >> m >> L >> S >> T;
	for (int i = 0; i < m; ++i)
	{
		int x, y, w;
		cin >> x >> y >> w;
		edges[x].push_back(y);
		edges[y].push_back(x);
		weights[x].push_back(w);
		weights[y].push_back(w);
		numbers[x].push_back(edges[y].size() - 1);
		numbers[y].push_back(edges[x].size() - 1);
	}
	priority_queue<pair<ll, ll>> q;
	q.push(pll(0, S));
	distances[S] = 0;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
				continue;
			if (distances[next] > distances[cur_elem] + next_dist)
			{
				distances[next] = distances[cur_elem] + next_dist;
				q.push(pll(-distances[next], next));
			}
		}
	}
	if (distances[T] == L)
		say_yes();
	if (distances[T] < L)
		say_no();
	q.push(pll(0, T));
	distances2[T] = 0;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances2[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
				continue;
			if (distances2[next] > distances2[cur_elem] + next_dist)
			{
				distances2[next] = distances2[cur_elem] + next_dist;
				q.push(pll(-distances2[next], next));
			}
		}
	}

	// here solution starts
	q.push(pll(0, S));
	bool f = false;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
			{
				if (distances2[next] == inf)
				{
					weights[cur_elem][i] = 1;
					weights[next][numbers[cur_elem][i]] = 1;
					if (distances[cur_elem] + 1 < distances[next])
					{
						distances[next] = distances[cur_elem] + 1;
						q.push(pll(-distances[next], next));
					}
				}
				else
				{
					weights[cur_elem][i] = max((ll)1, L - distances[cur_elem] - distances2[next]);
					weights[next][numbers[cur_elem][i]] = max((ll)1, L - distances[cur_elem] - distances2[next]);
					if (L - distances[cur_elem] - distances2[next] >= 1)
					{
						f = true;
						break;
					}
					if (distances[cur_elem] + weights[cur_elem][i] < distances[next])
					{
						distances[next] = distances[cur_elem] + weights[cur_elem][i];
						q.push(pll(-distances[next], next));
					}
				}
			}
			else if (distances[next] >= distances[cur_elem] + next_dist)
			{
				distances[next] = distances[cur_elem] + next_dist;
				q.push(pll(-distances[next], next));
			}
		}
		if (f)
			break;
	}

	if (f)
		say_yes();
	else
		say_no();
	return 0;
}
/*
1000 50 1000 13 0
0 1 0
0 2 0
0 3 0
0 4 0
0 5 0
1 2 0
1 3 0
1 4 0
1 5 0
1 6 0
2 3 0
2 4 0
2 5 0
2 6 0
2 7 0
3 4 0
3 5 0
3 6 0
3 7 0
3 8 0
4 5 0
4 6 0
4 7 0
4 8 0
4 9 0
5 6 0
5 7 0
5 8 0
5 9 0
5 10 0
6 7 0
6 8 0
6 9 0
6 10 0
6 11 0
7 8 0
7 9 0
7 10 0
7 11 0
7 12 0
8 9 0
8 10 0
8 11 0
8 12 0
8 13 0
9 10 0
9 11 0
9 12 0
9 13 0
9 14 0

*/


#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <math.h>
#include <map>
#include <set>
#include <stdio.h>
#include <stack>
#include <unordered_map>
#define ll long long
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pib pair<int, bool>
#define pdd pair<double, double>
#define pss pair<string, string>
#pragma comment(linker, "/STACK:251777215")
using namespace std;

const ll maxn = 1011;
const ll maxm = 10001;
const ll maxk = 1001;
const ll maxq = 1000001;
const ll margin = 1001;
const ll maxseg = 262144;
const ll secret_number = -87468267;
const pii secret_pair = make_pair(secret_number, secret_number);
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const int iinf = 2147483647 / 2;
const double pi = 3.141592653589793238462643383279502884;
const double eps = 1e-7;
const string something_very_long = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
const string govno = "g";
string impossible = "-1";

void printout(string str)
{
	cout << str;
	exit(0);
}

void Impossible()
{
	printout(impossible);
}

void print(char x, int numb)
{
	for (int i = 0; i < numb; ++i)
		cout << x;
}

int n, m, L, S, T;
vector<ll> edges[maxn];
vector<ll> weights[maxn];
vector<ll> numbers[maxn];
ll distances[maxn];
ll distances2[maxn];

void set_edge_len(int v, int numb, ll val)
{
	weights[v][numb] = val;
	weights[edges[v][numb]][numbers[v][numb]] = val;
}

void update(int v, int numb, ll* dist, priority_queue<pll> q)
{
	if (dist[edges[v][numb]] < dist[v] + weights[v][numb])
		dist[edges[v][numb]] = dist[v] + weights[v][numb], q.push(pll(-dist[edges[v][numb]], edges[v][numb]));
}

void say_yes()
{
	cout << "YES\n";
	for (int i = 0; i < maxn; ++i)
		for (int j = 0; j < edges[i].size(); ++j)
			if (i < edges[i][j])
				cout << i << ' ' << edges[i][j] << ' ' << ((weights[i][j] == 0) ? 1e15 : weights[i][j]) << '\n';
	exit(0);
}

void say_no()
{
	printout("NO");
}

int main()
{
	fill(distances, distances + maxn, inf);
	fill(distances2, distances2 + maxn, inf);
	cin >> n >> m >> L >> S >> T;
	for (int i = 0; i < m; ++i)
	{
		int x, y, w;
		cin >> x >> y >> w;
		edges[x].push_back(y);
		edges[y].push_back(x);
		weights[x].push_back(w);
		weights[y].push_back(w);
		numbers[x].push_back(edges[y].size() - 1);
		numbers[y].push_back(edges[x].size() - 1);
	}
	priority_queue<pair<ll, ll>> q;
	q.push(pll(0, S));
	distances[S] = 0;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
			if (weights[cur_elem][i] != 0)
				update(cur_elem, i, distances, q);
	}
	if (distances[T] == L)
		say_yes();
	if (distances[T] < L)
		say_no();

	// here solution starts
	q.push(pll(0, T));
	distances2[T] = 0;
	bool f = false;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances2[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
			{
				if (distances[next] == inf)
				{
					set_edge_len(cur_elem, i, 1);
					if (distances2[cur_elem] + 1 < distances2[next])
					{
						distances2[next] = distances2[cur_elem] + 1;
						q.push(pll(-distances2[next], next));
					}
				}
				else
				{
					weights[cur_elem][i] = max((ll)1, L - distances2[cur_elem] - distances[next]);
					weights[next][numbers[cur_elem][i]] = max((ll)1, L - distances2[cur_elem] - distances[next]);
					if (L - distances2[cur_elem] - distances[next] >= 1)
					{
						f = true;
						break;
					}
					if (distances2[cur_elem] + weights[cur_elem][i] < distances2[next])
					{
						distances2[next] = distances2[cur_elem] + weights[cur_elem][i];
						q.push(pll(-distances2[next], next));
					}
				}
			}
			else if (distances2[next] >= distances2[cur_elem] + next_dist)
			{
				distances2[next] = distances2[cur_elem] + next_dist;
				q.push(pll(-distances2[next], next));
			}
		}
		if (f)
			break;
	}

	if (f)
		say_yes();
	else
		say_no();
	return 0;
}
/*

*/


#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <math.h>
#include <map>
#include <set>
#include <stdio.h>
#include <stack>
#include <unordered_map>
#define ll long long
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pib pair<int, bool>
#define pdd pair<double, double>
#define pss pair<string, string>
#pragma comment(linker, "/STACK:251777215")
using namespace std;

const ll maxn = 1001;
const ll maxm = 10001;
const ll maxk = 1001;
const ll maxq = 1000001;
const ll margin = 1001;
const ll maxseg = 262144;
const ll secret_number = -87468267;
const pii secret_pair = make_pair(secret_number, secret_number);
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const int iinf = 2147483647 / 2;
const double pi = 3.141592653589793238462643383279502884;
const double eps = 1e-7;
const string something_very_long = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
const string govno = "g";
string impossible = "-1";

void printout(string str)
{
	cout << str;
	exit(0);
}

void Impossible()
{
	printout(impossible);
}

void print(char x, int numb)
{
	for (int i = 0; i < numb; ++i)
		cout << x;
}

int n, m, L, S, T;
vector<ll> edges[maxn];
vector<ll> weights[maxn];
vector<ll> numbers[maxn];
ll distances[maxn];
ll distances2[maxn];

void say_yes()
{
	cout << "YES\n";
	map<pii, int> weightes;
	for (int i = 0; i < maxn; ++i)
	{
		for (int j = 0; j < edges[i].size(); ++j)
		{
			if (weights[i][j] == 0)
			{
				weights[i][j] = 1e15;
				weights[edges[i][j]][numbers[i][j]] = 1e15;
			}
			if (i <= edges[i][j])
				weightes[pii(i, edges[i][j])] = weights[i][j];
			else
				weightes[pii(edges[i][j], i)] = weights[i][j];
		}
	}
	for (auto it = weightes.begin(); it != weightes.end(); it++)
	{
		cout << it->first.first << ' ' << it->first.second << ' ' << it->second << '\n';
	}
	exit(0);
}

void say_no()
{
	printout("NO");
}

int main()
{
	for (int i = 0; i < maxn; ++i)
		distances[i] = inf;
	for (int i = 0; i < maxn; ++i)
		distances2[i] = inf;
	cin >> n >> m >> L >> S >> T;
	for (int i = 0; i < m; ++i)
	{
		int x, y, w;
		cin >> x >> y >> w;
		edges[x].push_back(y);
		edges[y].push_back(x);
		weights[x].push_back(w);
		weights[y].push_back(w);
		numbers[x].push_back(edges[y].size() - 1);
		numbers[y].push_back(edges[x].size() - 1);
	}
	priority_queue<pair<ll, ll>> q;
	q.push(pll(0, S));
	distances[S] = 0;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
				continue;
			if (distances[next] > distances[cur_elem] + next_dist)
			{
				distances[next] = distances[cur_elem] + next_dist;
				q.push(pll(-distances[next], next));
			}
		}
	}
	if (distances[T] == L)
		say_yes();
	if (distances[T] < L)
		say_no();
	q.push(pll(0, T));
	distances2[T] = 0;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances2[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
				continue;
			if (distances2[next] > distances2[cur_elem] + next_dist)
			{
				distances2[next] = distances2[cur_elem] + next_dist;
				q.push(pll(-distances2[next], next));
			}
		}
	}

	// here solution starts
	q.push(pll(0, S));
	bool f = false;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
			{
				if (distances2[next] == inf)
				{
					distances[next] = distances[cur_elem] + 1;
					weights[cur_elem][i] = 1;
					weights[next][numbers[cur_elem][i]] = 1;
					q.push(pll(-distances[next], next));
				}
				else
				{
					weights[cur_elem][i] = max((ll)1, L - distances[cur_elem] - distances2[next]);
					weights[next][numbers[cur_elem][i]] = max((ll)1, L - distances[cur_elem] - distances2[next]);
					if (L - distances[cur_elem] - distances2[next] >= 1)
					{
						f = true;
						break;
					}
					distances[next] = distances[cur_elem] + weights[cur_elem][i];
					q.push(pll(-distances[next], next));
				}
			}
			else if (distances[next] >= distances[cur_elem] + next_dist)
			{
				distances[next] = distances[cur_elem] + next_dist;
				q.push(pll(-distances[next], next));
			}
		}
		if (f)
			break;
	}

	for (int i = 0; i < maxn; ++i)
	{
		for (int j = 0; j < weights[i].size(); ++i)
		{
			if (weights[i][j] == 0)
			{
				weights[i][j] = 1e15;
				weights[edges[i][j]][numbers[i][j]] = 1e15;
			}
		}
	}

	// check
	for (int i = 0; i < maxn; ++i)
		distances[i] = inf;
	q.push(pll(0, S));
	distances[S] = 0;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
				continue;
			if (distances[next] > distances[cur_elem] + next_dist)
			{
				distances[next] = distances[cur_elem] + next_dist;
				q.push(pll(-distances[next], next));
			}
		}
	}

	if (distances[T] == L)
		say_yes();
	else
		say_no();
	return 0;
}
/*
2 1 1000000000 1 0
0 1 999999999
*/


#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <math.h>
#include <map>
#include <set>
#include <stdio.h>
#include <stack>
#include <unordered_map>
#define ll long long
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pib pair<int, bool>
#define pdd pair<double, double>
#define pss pair<string, string>
#pragma comment(linker, "/STACK:251777215")
using namespace std;

const ll maxn = 1011;
const ll maxm = 10001;
const ll maxk = 1001;
const ll maxq = 1000001;
const ll margin = 1001;
const ll maxseg = 262144;
const ll secret_number = -87468267;
const pii secret_pair = make_pair(secret_number, secret_number);
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const int iinf = 2147483647 / 2;
const double pi = 3.141592653589793238462643383279502884;
const double eps = 1e-7;
const string something_very_long = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
const string govno = "g";
string impossible = "-1";

void printout(string str)
{
	cout << str;
	exit(0);
}

void Impossible()
{
	printout(impossible);
}

void print(char x, int numb)
{
	for (int i = 0; i < numb; ++i)
		cout << x;
}

int n, m, L, S, T;
vector<ll> edges[maxn];
vector<ll> weights[maxn];
vector<ll> numbers[maxn];
ll distances[maxn];
ll distances2[maxn];
priority_queue<pll> q;

void set_edge_len(int v, int numb, ll val)
{
	weights[v][numb] = val;
	weights[edges[v][numb]][numbers[v][numb]] = val;
}

void update(int v, int numb, ll* dist)
{
	if (dist[edges[v][numb]] > dist[v] + weights[v][numb])
	{
		dist[edges[v][numb]] = dist[v] + weights[v][numb];
		q.push(pll(-dist[edges[v][numb]], edges[v][numb]));
	}
}

void say_yes()
{
	cout << "YES\n";
	for (int i = 0; i < maxn; ++i)
		for (int j = 0; j < edges[i].size(); ++j)
			if (i < edges[i][j])
				cout << i << ' ' << edges[i][j] << ' ' << ((weights[i][j] == 0) ? (ll)1e15 : weights[i][j]) << '\n';
	exit(0);
}

void say_no()
{
	printout("NO");
}

int main()
{
	fill(distances, distances + maxn, inf);
	fill(distances2, distances2 + maxn, inf);
	cin >> n >> m >> L >> S >> T;
	for (int i = 0; i < m; ++i)
	{
		int x, y, w;
		cin >> x >> y >> w;
		edges[x].push_back(y);
		edges[y].push_back(x);
		weights[x].push_back(w);
		weights[y].push_back(w);
		numbers[x].push_back(edges[y].size() - 1);
		numbers[y].push_back(edges[x].size() - 1);
	}

	q.push(pll(0, S));
	distances[S] = 0;
	while (!q.empty())
	{
		ll cur_elem = q.top().ss;
		q.pop();
		for (int i = 0; i < edges[cur_elem].size(); ++i)
			if (weights[cur_elem][i] != 0)
				update(cur_elem, i, distances);
	}
	if (distances[T] < L)
		say_no();

	// here solution starts
	q.push(pll(0, T));
	distances2[T] = 0;
	while (!q.empty())
	{
		ll cur_elem = q.top().ss;
		q.pop();
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			if (weights[cur_elem][i] == 0)
				set_edge_len(cur_elem, i, max((ll)1, L - distances2[cur_elem] - distances[next]));
			if (L - distances2[cur_elem] - distances[next] >= 1)
				say_yes();
			update(cur_elem, i, distances2);
		}
	}
	say_no();
	return 0;
}
/*

*/


#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <math.h>
#include <map>
#include <set>
#include <stdio.h>
#include <stack>
#include <unordered_map>
#define ll long long
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pib pair<int, bool>
#define pdd pair<double, double>
#define pss pair<string, string>
#pragma comment(linker, "/STACK:251777215")
using namespace std;

const ll maxn = 1011;
const ll maxm = 10001;
const ll maxk = 1001;
const ll maxq = 1000001;
const ll margin = 1001;
const ll maxseg = 262144;
const ll secret_number = -87468267;
const pii secret_pair = make_pair(secret_number, secret_number);
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const int iinf = 2147483647 / 2;
const double pi = 3.141592653589793238462643383279502884;
const double eps = 1e-7;
const string something_very_long = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
const string govno = "g";
string impossible = "-1";

void printout(string str)
{
	cout << str;
	exit(0);
}

void Impossible()
{
	printout(impossible);
}

void print(char x, int numb)
{
	for (int i = 0; i < numb; ++i)
		cout << x;
}

int n, m, L, S, T;
vector<ll> edges[maxn];
vector<ll> weights[maxn];
vector<ll> numbers[maxn];
ll distances[maxn];
ll distances2[maxn];

void say_yes()
{
	cout << "YES\n";
	map<pii, ll> weightes;
	for (int i = 0; i < maxn; ++i)
	{
		for (int j = 0; j < edges[i].size(); ++j)
		{
			if (weights[i][j] == 0)
			{
				weights[i][j] = 1e15;
				weights[edges[i][j]][numbers[i][j]] = 1e15;
			}
			if (i <= edges[i][j])
				weightes[pii(i, edges[i][j])] = weights[i][j];
			else
				weightes[pii(edges[i][j], i)] = weights[i][j];
		}
	}
	for (auto it = weightes.begin(); it != weightes.end(); it++)
	{
		cout << it->first.first << ' ' << it->first.second << ' ' << it->second << '\n';
	}
	exit(0);
}

void say_no()
{
	printout("NO");
}

int main()
{
	for (int i = 0; i < maxn; ++i)
		distances[i] = inf;
	for (int i = 0; i < maxn; ++i)
		distances2[i] = inf;
	cin >> n >> m >> L >> S >> T;
	for (int i = 0; i < m; ++i)
	{
		int x, y, w;
		cin >> x >> y >> w;
		edges[x].push_back(y);
		edges[y].push_back(x);
		weights[x].push_back(w);
		weights[y].push_back(w);
		numbers[x].push_back(edges[y].size() - 1);
		numbers[y].push_back(edges[x].size() - 1);
	}
	priority_queue<pair<ll, ll>> q;
	q.push(pll(0, S));
	distances[S] = 0;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
				continue;
			if (distances[next] > distances[cur_elem] + next_dist)
			{
				distances[next] = distances[cur_elem] + next_dist;
				q.push(pll(-distances[next], next));
			}
		}
	}
	if (distances[T] == L)
		say_yes();
	if (distances[T] < L)
		say_no();
	q.push(pll(0, T));
	distances2[T] = 0;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances2[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
				continue;
			if (distances2[next] > distances2[cur_elem] + next_dist)
			{
				distances2[next] = distances2[cur_elem] + next_dist;
				q.push(pll(-distances2[next], next));
			}
		}
	}

	// here solution starts
	q.push(pll(0, S));
	bool f = false;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
			{
				if (distances2[next] == inf)
				{
					distances[next] = distances[cur_elem] + 1;
					weights[cur_elem][i] = 1;
					weights[next][numbers[cur_elem][i]] = 1;
					q.push(pll(-distances[next], next));
				}
				else
				{
					weights[cur_elem][i] = max((ll)1, L - distances[cur_elem] - distances2[next]);
					weights[next][numbers[cur_elem][i]] = max((ll)1, L - distances[cur_elem] - distances2[next]);
					if (L - distances[cur_elem] - distances2[next] >= 1)
					{
						f = true;
						break;
					}
					distances[next] = distances[cur_elem] + weights[cur_elem][i];
					q.push(pll(-distances[next], next));
				}
			}
			else if (distances[next] >= distances[cur_elem] + next_dist)
			{
				distances[next] = distances[cur_elem] + next_dist;
				q.push(pll(-distances[next], next));
			}
		}
		if (f)
			break;
	}

	for (int i = 0; i < maxn; ++i)
	{
		for (int j = 0; j < weights[i].size(); ++i)
		{
			if (weights[i][j] == 0)
			{
				weights[i][j] = 1e15;
				weights[edges[i][j]][numbers[i][j]] = 1e15;
			}
		}
	}

	// check
	for (int i = 0; i < maxn; ++i)
		distances[i] = inf;
	q.push(pll(0, S));
	distances[S] = 0;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
				continue;
			if (distances[next] > distances[cur_elem] + next_dist)
			{
				distances[next] = distances[cur_elem] + next_dist;
				q.push(pll(-distances[next], next));
			}
		}
	}
	if (distances[T] < L)
	{
		printout("shit");
	}
	if (distances[T] == L)
		say_yes();
	else
		say_no();
	return 0;
}
/*
1000 50 1000 13 0
0 1 0
0 2 0
0 3 0
0 4 0
0 5 0
1 2 0
1 3 0
1 4 0
1 5 0
1 6 0
2 3 0
2 4 0
2 5 0
2 6 0
2 7 0
3 4 0
3 5 0
3 6 0
3 7 0
3 8 0
4 5 0
4 6 0
4 7 0
4 8 0
4 9 0
5 6 0
5 7 0
5 8 0
5 9 0
5 10 0
6 7 0
6 8 0
6 9 0
6 10 0
6 11 0
7 8 0
7 9 0
7 10 0
7 11 0
7 12 0
8 9 0
8 10 0
8 11 0
8 12 0
8 13 0
9 10 0
9 11 0
9 12 0
9 13 0
9 14 0

*/


#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <math.h>
#include <map>
#include <set>
#include <stdio.h>
#include <stack>
#include <unordered_map>
#define ll long long
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pib pair<int, bool>
#define pdd pair<double, double>
#define pss pair<string, string>
#pragma comment(linker, "/STACK:251777215")
using namespace std;

const ll maxn = 1011;
const ll maxm = 10001;
const ll maxk = 1001;
const ll maxq = 1000001;
const ll margin = 1001;
const ll maxseg = 262144;
const ll secret_number = -87468267;
const pii secret_pair = make_pair(secret_number, secret_number);
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const int iinf = 2147483647 / 2;
const double pi = 3.141592653589793238462643383279502884;
const double eps = 1e-7;
const string something_very_long = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
const string govno = "g";
string impossible = "-1";

void printout(string str)
{
	cout << str;
	exit(0);
}

void Impossible()
{
	printout(impossible);
}

void print(char x, int numb)
{
	for (int i = 0; i < numb; ++i)
		cout << x;
}

int n, m, L, S, T;
vector<ll> edges[maxn];
vector<ll> weights[maxn];
vector<ll> numbers[maxn];
ll distances[maxn];
ll distances2[maxn];

void say_yes()
{
	cout << "YES\n";
	map<pii, ll> weightes;
	for (int i = 0; i < maxn; ++i)
	{
		for (int j = 0; j < edges[i].size(); ++j)
		{
			if (weights[i][j] == 0)
			{
				weights[i][j] = 1e15;
				weights[edges[i][j]][numbers[i][j]] = 1e15;
			}
			if (i <= edges[i][j])
				weightes[pii(i, edges[i][j])] = weights[i][j];
			else
				weightes[pii(edges[i][j], i)] = weights[i][j];
		}
	}
	for (auto it = weightes.begin(); it != weightes.end(); it++)
	{
		cout << it->first.first << ' ' << it->first.second << ' ' << it->second << '\n';
	}
	exit(0);
}

void say_no()
{
	printout("NO");
}

int main()
{
	for (int i = 0; i < maxn; ++i)
		distances[i] = inf;
	for (int i = 0; i < maxn; ++i)
		distances2[i] = inf;
	cin >> n >> m >> L >> S >> T;
	for (int i = 0; i < m; ++i)
	{
		int x, y, w;
		cin >> x >> y >> w;
		edges[x].push_back(y);
		edges[y].push_back(x);
		weights[x].push_back(w);
		weights[y].push_back(w);
		numbers[x].push_back(edges[y].size() - 1);
		numbers[y].push_back(edges[x].size() - 1);
	}
	priority_queue<pair<ll, ll>> q;
	q.push(pll(0, S));
	distances[S] = 0;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
				continue;
			if (distances[next] > distances[cur_elem] + next_dist)
			{
				distances[next] = distances[cur_elem] + next_dist;
				q.push(pll(-distances[next], next));
			}
		}
	}
	if (distances[T] == L)
		say_yes();
	if (distances[T] < L)
		say_no();
	q.push(pll(0, T));
	distances2[T] = 0;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances2[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
				continue;
			if (distances2[next] > distances2[cur_elem] + next_dist)
			{
				distances2[next] = distances2[cur_elem] + next_dist;
				q.push(pll(-distances2[next], next));
			}
		}
	}

	// here solution starts
	q.push(pll(0, S));
	bool f = false;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
			{
				if (distances2[next] == inf)
				{
					weights[cur_elem][i] = 1;
					weights[next][numbers[cur_elem][i]] = 1;
					if (distances[cur_elem] + 1 < distances[next])
					{
						distances[next] = distances[cur_elem] + 1;
						q.push(pll(-distances[next], next));
					}
				}
				else
				{
					weights[cur_elem][i] = max((ll)1, L - distances[cur_elem] - distances2[next]);
					weights[next][numbers[cur_elem][i]] = max((ll)1, L - distances[cur_elem] - distances2[next]);
					if (L - distances[cur_elem] - distances2[next] >= 1)
					{
						f = true;
						break;
					}
					if (distances[cur_elem] + weights[cur_elem][i] < distances[next])
					{
						distances[next] = distances[cur_elem] + weights[cur_elem][i];
						q.push(pll(-distances[next], next));
					}
				}
			}
			else if (distances[next] >= distances[cur_elem] + next_dist)
			{
				distances[next] = distances[cur_elem] + next_dist;
				q.push(pll(-distances[next], next));
			}
		}
		if (f)
			break;
	}

	for (int i = 0; i < maxn; ++i)
	{
		for (int j = 0; j < weights[i].size(); ++i)
		{
			if (weights[i][j] == 0)
			{
				weights[i][j] = 1e15;
				weights[edges[i][j]][numbers[i][j]] = 1e15;
			}
		}
	}

	// check
	for (int i = 0; i < maxn; ++i)
		distances[i] = inf;
	q.push(pll(0, S));
	distances[S] = 0;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
				continue;
			if (distances[next] > distances[cur_elem] + next_dist)
			{
				distances[next] = distances[cur_elem] + next_dist;
				q.push(pll(-distances[next], next));
			}
		}
	}
	if (distances[T] == L)
		say_yes();
	else
		say_no();
	return 0;
}
/*
1000 50 1000 13 0
0 1 0
0 2 0
0 3 0
0 4 0
0 5 0
1 2 0
1 3 0
1 4 0
1 5 0
1 6 0
2 3 0
2 4 0
2 5 0
2 6 0
2 7 0
3 4 0
3 5 0
3 6 0
3 7 0
3 8 0
4 5 0
4 6 0
4 7 0
4 8 0
4 9 0
5 6 0
5 7 0
5 8 0
5 9 0
5 10 0
6 7 0
6 8 0
6 9 0
6 10 0
6 11 0
7 8 0
7 9 0
7 10 0
7 11 0
7 12 0
8 9 0
8 10 0
8 11 0
8 12 0
8 13 0
9 10 0
9 11 0
9 12 0
9 13 0
9 14 0

*/


#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <math.h>
#include <map>
#include <set>
#include <stdio.h>
#include <stack>
#include <unordered_map>
#define ll long long
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pib pair<int, bool>
#define pdd pair<double, double>
#define pss pair<string, string>
#pragma comment(linker, "/STACK:251777215")
using namespace std;

const ll maxn = 1011;
const ll maxm = 10001;
const ll maxk = 1001;
const ll maxq = 1000001;
const ll margin = 1001;
const ll maxseg = 262144;
const ll secret_number = -87468267;
const pii secret_pair = make_pair(secret_number, secret_number);
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const int iinf = 2147483647 / 2;
const double pi = 3.141592653589793238462643383279502884;
const double eps = 1e-7;
const string something_very_long = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
const string govno = "g";
string impossible = "-1";

void printout(string str)
{
	cout << str;
	exit(0);
}

void Impossible()
{
	printout(impossible);
}

void print(char x, int numb)
{
	for (int i = 0; i < numb; ++i)
		cout << x;
}

int n, m, L, S, T;
vector<ll> edges[maxn];
vector<ll> weights[maxn];
vector<ll> numbers[maxn];
ll distances[maxn];
ll distances2[maxn];

void say_yes()
{
	cout << "YES\n";
	map<pii, ll> weightes;
	for (int i = 0; i < maxn; ++i)
	{
		for (int j = 0; j < edges[i].size(); ++j)
		{
			if (weights[i][j] == 0)
			{
				weights[i][j] = 1e15;
				weights[edges[i][j]][numbers[i][j]] = 1e15;
			}
			if (i <= edges[i][j])
				weightes[pii(i, edges[i][j])] = weights[i][j];
			else
				weightes[pii(edges[i][j], i)] = weights[i][j];
		}
	}
	for (auto it = weightes.begin(); it != weightes.end(); it++)
	{
		cout << it->first.first << ' ' << it->first.second << ' ' << it->second << '\n';
	}
	exit(0);
}

void say_no()
{
	printout("NO");
}

int main()
{
	for (int i = 0; i < maxn; ++i)
		distances[i] = inf;
	for (int i = 0; i < maxn; ++i)
		distances2[i] = inf;
	cin >> n >> m >> L >> S >> T;
	for (int i = 0; i < m; ++i)
	{
		int x, y, w;
		cin >> x >> y >> w;
		edges[x].push_back(y);
		edges[y].push_back(x);
		weights[x].push_back(w);
		weights[y].push_back(w);
		numbers[x].push_back(edges[y].size() - 1);
		numbers[y].push_back(edges[x].size() - 1);
	}
	priority_queue<pair<ll, ll>> q;
	q.push(pll(0, S));
	distances[S] = 0;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
				continue;
			if (distances[next] > distances[cur_elem] + next_dist)
			{
				distances[next] = distances[cur_elem] + next_dist;
				q.push(pll(-distances[next], next));
			}
		}
	}
	if (distances[T] == L)
		say_yes();
	if (distances[T] < L)
		say_no();
	q.push(pll(0, T));
	distances2[T] = 0;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances2[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
				continue;
			if (distances2[next] > distances2[cur_elem] + next_dist)
			{
				distances2[next] = distances2[cur_elem] + next_dist;
				q.push(pll(-distances2[next], next));
			}
		}
	}

	// here solution starts
	q.push(pll(0, S));
	bool f = false;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
			{
				if (distances2[next] == inf)
				{
					distances[next] = min(distances[next], distances[cur_elem] + 1);
					weights[cur_elem][i] = 1;
					weights[next][numbers[cur_elem][i]] = 1;
					q.push(pll(-distances[next], next));
				}
				else
				{
					weights[cur_elem][i] = max((ll)1, L - distances[cur_elem] - distances2[next]);
					weights[next][numbers[cur_elem][i]] = max((ll)1, L - distances[cur_elem] - distances2[next]);
					if (L - distances[cur_elem] - distances2[next] >= 1)
					{
						f = true;
						break;
					}
					distances[next] = min(distances[next], distances[cur_elem] + weights[cur_elem][i]);
					q.push(pll(-distances[next], next));
				}
			}
			else if (distances[next] >= distances[cur_elem] + next_dist)
			{
				distances[next] = distances[cur_elem] + next_dist;
				q.push(pll(-distances[next], next));
			}
		}
		if (f)
			break;
	}

	for (int i = 0; i < maxn; ++i)
	{
		for (int j = 0; j < weights[i].size(); ++i)
		{
			if (weights[i][j] == 0)
			{
				weights[i][j] = 1e15;
				weights[edges[i][j]][numbers[i][j]] = 1e15;
			}
		}
	}

	// check
	for (int i = 0; i < maxn; ++i)
		distances[i] = inf;
	q.push(pll(0, S));
	distances[S] = 0;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
				continue;
			if (distances[next] > distances[cur_elem] + next_dist)
			{
				distances[next] = distances[cur_elem] + next_dist;
				q.push(pll(-distances[next], next));
			}
		}
	}
	if (distances[T] == L)
		say_yes();
	else
		say_no();
	return 0;
}
/*
1000 50 1000 13 0
0 1 0
0 2 0
0 3 0
0 4 0
0 5 0
1 2 0
1 3 0
1 4 0
1 5 0
1 6 0
2 3 0
2 4 0
2 5 0
2 6 0
2 7 0
3 4 0
3 5 0
3 6 0
3 7 0
3 8 0
4 5 0
4 6 0
4 7 0
4 8 0
4 9 0
5 6 0
5 7 0
5 8 0
5 9 0
5 10 0
6 7 0
6 8 0
6 9 0
6 10 0
6 11 0
7 8 0
7 9 0
7 10 0
7 11 0
7 12 0
8 9 0
8 10 0
8 11 0
8 12 0
8 13 0
9 10 0
9 11 0
9 12 0
9 13 0
9 14 0

*/


#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <math.h>
#include <map>
#include <set>
#include <stdio.h>
#include <stack>
#include <unordered_map>
#define ll long long
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pib pair<int, bool>
#define pdd pair<double, double>
#define pss pair<string, string>
#pragma comment(linker, "/STACK:251777215")
using namespace std;

const ll maxn = 1011;
const ll maxm = 10001;
const ll maxk = 1001;
const ll maxq = 1000001;
const ll margin = 1001;
const ll maxseg = 262144;
const ll secret_number = -87468267;
const pii secret_pair = make_pair(secret_number, secret_number);
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const int iinf = 2147483647 / 2;
const double pi = 3.141592653589793238462643383279502884;
const double eps = 1e-7;
const string something_very_long = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
const string govno = "g";
string impossible = "-1";

void printout(string str)
{
	cout << str;
	exit(0);
}

void Impossible()
{
	printout(impossible);
}

void print(char x, int numb)
{
	for (int i = 0; i < numb; ++i)
		cout << x;
}

int n, m, L, S, T;
vector<ll> edges[maxn];
vector<ll> weights[maxn];
vector<ll> numbers[maxn];
ll distances[maxn];
ll distances2[maxn];
priority_queue<pll> q;

void set_edge_len(int v, int numb, ll val)
{
	weights[v][numb] = val;
	weights[edges[v][numb]][numbers[v][numb]] = val;
}

void update(int v, int numb, ll* dist)
{
	if (dist[edges[v][numb]] > dist[v] + weights[v][numb])
	{
		dist[edges[v][numb]] = dist[v] + weights[v][numb];
		q.push(pll(-dist[edges[v][numb]], edges[v][numb]));
	}
}

void say_yes()
{
	cout << "YES\n";
	for (int i = 0; i < maxn; ++i)
		for (int j = 0; j < edges[i].size(); ++j)
			if (i < edges[i][j])
				cout << i << ' ' << edges[i][j] << ' ' << ((weights[i][j] == 0) ? (ll)1e15 : weights[i][j]) << '\n';
	exit(0);
}

void say_no()
{
	printout("NO");
}

int main()
{
	fill(distances, distances + maxn, inf);
	fill(distances2, distances2 + maxn, inf);
	cin >> n >> m >> L >> S >> T;
	for (int i = 0; i < m; ++i)
	{
		int x, y, w;
		cin >> x >> y >> w;
		edges[x].push_back(y);
		edges[y].push_back(x);
		weights[x].push_back(w);
		weights[y].push_back(w);
		numbers[x].push_back(edges[y].size() - 1);
		numbers[y].push_back(edges[x].size() - 1);
	}

	q.push(pll(0, S));
	distances[S] = 0;
	while (!q.empty())
	{
		ll cur_elem = q.top().ss;
		q.pop();
		for (int i = 0; i < edges[cur_elem].size(); ++i)
			if (weights[cur_elem][i] != 0)
				update(cur_elem, i, distances);
	}
	if (distances[T] < L)
		say_no();

	// here solution starts
	q.push(pll(0, T));
	distances2[T] = 0;
	while (!q.empty())
	{
		ll cur_elem = q.top().ss;
		q.pop();
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			if (weights[cur_elem][i] == 0)
				set_edge_len(cur_elem, i, max((ll)1, L - distances2[cur_elem] - distances[next]));
			update(cur_elem, i, distances2);
			if (L == distances2[cur_elem] + weights[cur_elem][i] + distances[next])
				say_yes();
		}
	}
	say_no();
	return 0;
}
/*

*/


#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <math.h>
#include <map>
#include <set>
#include <stdio.h>
#include <stack>
#include <unordered_map>
#define ll long long
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pib pair<int, bool>
#define pdd pair<double, double>
#define pss pair<string, string>
#pragma comment(linker, "/STACK:251777215")
using namespace std;

const ll maxn = 1011;
const ll maxm = 10001;
const ll maxk = 1001;
const ll maxq = 1000001;
const ll margin = 1001;
const ll maxseg = 262144;
const ll secret_number = -87468267;
const pii secret_pair = make_pair(secret_number, secret_number);
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const int iinf = 2147483647 / 2;
const double pi = 3.141592653589793238462643383279502884;
const double eps = 1e-7;
const string something_very_long = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
const string govno = "g";
string impossible = "-1";

void printout(string str)
{
	cout << str;
	exit(0);
}

void Impossible()
{
	printout(impossible);
}

void print(char x, int numb)
{
	for (int i = 0; i < numb; ++i)
		cout << x;
}

int n, m, L, S, T;
vector<ll> edges[maxn];
vector<ll> weights[maxn];
vector<ll> numbers[maxn];
ll distances[maxn];
ll distances2[maxn];

void set_edge_len(int v, int numb, ll val)
{
	weights[v][numb] = val;
	weights[edges[v][numb]][numbers[v][numb]] = val;
}

void update(int v, int numb, ll* dist, priority_queue<pll> &q)
{
	if (dist[edges[v][numb]] > dist[v] + weights[v][numb])
	{
		dist[edges[v][numb]] = dist[v] + weights[v][numb];
		q.push(pll(-dist[edges[v][numb]], edges[v][numb]));
	}
}

void say_yes()
{
	cout << "YES\n";
	for (int i = 0; i < maxn; ++i)
		for (int j = 0; j < edges[i].size(); ++j)
			if (i < edges[i][j])
				cout << i << ' ' << edges[i][j] << ' ' << ((weights[i][j] == 0) ? (ll)1e15 : weights[i][j]) << '\n';
	exit(0);
}

void say_no()
{
	printout("NO");
}

int main()
{
	fill(distances, distances + maxn, inf);
	fill(distances2, distances2 + maxn, inf);
	cin >> n >> m >> L >> S >> T;
	for (int i = 0; i < m; ++i)
	{
		int x, y, w;
		cin >> x >> y >> w;
		edges[x].push_back(y);
		edges[y].push_back(x);
		weights[x].push_back(w);
		weights[y].push_back(w);
		numbers[x].push_back(edges[y].size() - 1);
		numbers[y].push_back(edges[x].size() - 1);
	}
	priority_queue<pair<ll, ll>> q;
	q.push(pll(0, S));
	distances[S] = 0;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
			if (weights[cur_elem][i] != 0)
				update(cur_elem, i, distances, q);
	}
	if (distances[T] == L)
		say_yes();
	if (distances[T] < L)
		say_no();

	// here solution starts
	q.push(pll(0, T));
	distances2[T] = 0;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances2[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			if (weights[cur_elem][i] == 0)
			{
				set_edge_len(cur_elem, i, max((ll)1, L - distances2[cur_elem] - distances[next]));
				if (L - distances2[cur_elem] - distances[next] >= 1)
					say_yes();
			}
			update(cur_elem, i, distances2, q);
		}
	}
	say_no();
	return 0;
}
/*

*/


#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <math.h>
#include <map>
#include <set>
#include <stdio.h>
#include <stack>
#include <unordered_map>
#define ll long long
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pib pair<int, bool>
#define pdd pair<double, double>
#define pss pair<string, string>
#pragma comment(linker, "/STACK:251777215")
using namespace std;

const ll maxn = 1011;
const ll maxm = 10001;
const ll maxk = 1001;
const ll maxq = 1000001;
const ll margin = 1001;
const ll maxseg = 262144;
const ll secret_number = -87468267;
const pii secret_pair = make_pair(secret_number, secret_number);
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const int iinf = 2147483647 / 2;
const double pi = 3.141592653589793238462643383279502884;
const double eps = 1e-7;
const string something_very_long = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
const string govno = "g";
string impossible = "-1";

void printout(string str)
{
	cout << str;
	exit(0);
}

void Impossible()
{
	printout(impossible);
}

void print(char x, int numb)
{
	for (int i = 0; i < numb; ++i)
		cout << x;
}

int n, m, L, S, T;
vector<ll> edges[maxn];
vector<ll> weights[maxn];
vector<ll> numbers[maxn];
ll distances[maxn];
ll distances2[maxn];

void say_yes()
{
	cout << "YES\n";
	map<pii, ll> weightes;
	for (int i = 0; i < maxn; ++i)
	{
		for (int j = 0; j < edges[i].size(); ++j)
		{
			if (weights[i][j] == 0)
			{
				weights[i][j] = 1e15;
				weights[edges[i][j]][numbers[i][j]] = 1e15;
			}
			if (i <= edges[i][j])
				weightes[pii(i, edges[i][j])] = weights[i][j];
			else
				weightes[pii(edges[i][j], i)] = weights[i][j];
		}
	}
	for (auto it = weightes.begin(); it != weightes.end(); it++)
	{
		cout << it->first.first << ' ' << it->first.second << ' ' << it->second << '\n';
	}
	exit(0);
}

void say_no()
{
	printout("NO");
}

int main()
{
	for (int i = 0; i < maxn; ++i)
		distances[i] = inf;
	for (int i = 0; i < maxn; ++i)
		distances2[i] = inf;
	cin >> n >> m >> L >> S >> T;
	for (int i = 0; i < m; ++i)
	{
		int x, y, w;
		cin >> x >> y >> w;
		edges[x].push_back(y);
		edges[y].push_back(x);
		weights[x].push_back(w);
		weights[y].push_back(w);
		numbers[x].push_back(edges[y].size() - 1);
		numbers[y].push_back(edges[x].size() - 1);
	}
	priority_queue<pair<ll, ll>> q;
	q.push(pll(0, S));
	distances[S] = 0;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
				continue;
			if (distances[next] > distances[cur_elem] + next_dist)
			{
				distances[next] = distances[cur_elem] + next_dist;
				q.push(pll(-distances[next], next));
			}
		}
	}
	if (distances[T] == L)
		say_yes();
	if (distances[T] < L)
		say_no();

	// here solution starts
	q.push(pll(0, T));
	distances2[T] = 0;
	bool f = false;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances2[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
			{
				if (distances[next] == inf)
				{
					weights[cur_elem][i] = 1;
					weights[next][numbers[cur_elem][i]] = 1;
					if (distances2[cur_elem] + 1 < distances2[next])
					{
						distances2[next] = distances2[cur_elem] + 1;
						q.push(pll(-distances2[next], next));
					}
				}
				else
				{
					weights[cur_elem][i] = max((ll)1, L - distances2[cur_elem] - distances[next]);
					weights[next][numbers[cur_elem][i]] = max((ll)1, L - distances2[cur_elem] - distances[next]);
					if (L - distances2[cur_elem] - distances[next] >= 1)
					{
						f = true;
						break;
					}
					if (distances2[cur_elem] + weights[cur_elem][i] < distances2[next])
					{
						distances2[next] = distances2[cur_elem] + weights[cur_elem][i];
						q.push(pll(-distances2[next], next));
					}
				}
			}
			else if (distances2[next] >= distances2[cur_elem] + next_dist)
			{
				distances2[next] = distances2[cur_elem] + next_dist;
				q.push(pll(-distances2[next], next));
			}
		}
		if (f)
			break;
	}

	if (f)
		say_yes();
	else
		say_no();
	return 0;
}
/*

*/


#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <math.h>
#include <map>
#include <set>
#include <stdio.h>
#include <stack>
#include <unordered_map>
#define ll long long
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pib pair<int, bool>
#define pdd pair<double, double>
#define pss pair<string, string>
#pragma comment(linker, "/STACK:251777215")
using namespace std;

const ll maxn = 1011;
const ll maxm = 10001;
const ll maxk = 1001;
const ll maxq = 1000001;
const ll margin = 1001;
const ll maxseg = 262144;
const ll secret_number = -87468267;
const pii secret_pair = make_pair(secret_number, secret_number);
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const int iinf = 2147483647 / 2;
const double pi = 3.141592653589793238462643383279502884;
const double eps = 1e-7;
const string something_very_long = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
const string govno = "g";
string impossible = "-1";

void printout(string str)
{
	cout << str;
	exit(0);
}

void Impossible()
{
	printout(impossible);
}

void print(char x, int numb)
{
	for (int i = 0; i < numb; ++i)
		cout << x;
}

int n, m, L, S, T;
vector<ll> edges[maxn];
vector<ll> weights[maxn];
vector<ll> numbers[maxn];
ll distances[maxn];
ll distances2[maxn];
priority_queue<pll> q;

void set_edge_len(int v, int numb, ll val)
{
	weights[v][numb] = val;
	weights[edges[v][numb]][numbers[v][numb]] = val;
}

void update(int v, int numb, ll* dist)
{
	if (dist[edges[v][numb]] > dist[v] + weights[v][numb])
	{
		dist[edges[v][numb]] = dist[v] + weights[v][numb];
		q.push(pll(-dist[edges[v][numb]], edges[v][numb]));
	}
}

void say_yes()
{
	cout << "YES\n";
	for (int i = 0; i < maxn; ++i)
		for (int j = 0; j < edges[i].size(); ++j)
			if (i < edges[i][j])
				cout << i << ' ' << edges[i][j] << ' ' << ((weights[i][j] == 0) ? (ll)1e15 : weights[i][j]) << '\n';
	exit(0);
}

void say_no()
{
	printout("NO");
}

int main()
{
	fill(distances, distances + maxn, inf);
	fill(distances2, distances2 + maxn, inf);
	cin >> n >> m >> L >> S >> T;
	for (int i = 0; i < m; ++i)
	{
		int x, y, w;
		cin >> x >> y >> w;
		edges[x].push_back(y);
		edges[y].push_back(x);
		weights[x].push_back(w);
		weights[y].push_back(w);
		numbers[x].push_back(edges[y].size() - 1);
		numbers[y].push_back(edges[x].size() - 1);
	}

	q.push(pll(0, S));
	distances[S] = 0;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
			if (weights[cur_elem][i] != 0)
				update(cur_elem, i, distances);
	}
	if (distances[T] == L)
		say_yes();
	if (distances[T] < L)
		say_no();

	// here solution starts
	q.push(pll(0, T));
	distances2[T] = 0;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances2[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			if (weights[cur_elem][i] == 0)
			{
				set_edge_len(cur_elem, i, max((ll)1, L - distances2[cur_elem] - distances[next]));
				if (L - distances2[cur_elem] - distances[next] >= 1)
					say_yes();
			}
			update(cur_elem, i, distances2);
		}
	}
	say_no();
	return 0;
}
/*

*/


#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <math.h>
#include <map>
#include <set>
#include <stdio.h>
#include <stack>
#include <unordered_map>
#define ll long long
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pib pair<int, bool>
#define pdd pair<double, double>
#define pss pair<string, string>
#pragma comment(linker, "/STACK:251777215")
using namespace std;

const ll maxn = 1011;
const ll maxm = 10001;
const ll maxk = 1001;
const ll maxq = 1000001;
const ll margin = 1001;
const ll maxseg = 262144;
const ll secret_number = -87468267;
const pii secret_pair = make_pair(secret_number, secret_number);
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const int iinf = 2147483647 / 2;
const double pi = 3.141592653589793238462643383279502884;
const double eps = 1e-7;
const string something_very_long = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
const string govno = "g";
string impossible = "-1";

void printout(string str)
{
	cout << str;
	exit(0);
}

void Impossible()
{
	printout(impossible);
}

void print(char x, int numb)
{
	for (int i = 0; i < numb; ++i)
		cout << x;
}

int n, m, L, S, T;
vector<ll> edges[maxn];
vector<ll> weights[maxn];
vector<ll> numbers[maxn];
ll distances[maxn];
ll distances2[maxn];

void set_edge_len(int v, int numb, ll val)
{
	weights[v][numb] = val;
	weights[edges[v][numb]][numbers[v][numb]] = val;
}

void update(int v, int numb, ll* dist, priority_queue<pll> &q)
{
	if (dist[edges[v][numb]] > dist[v] + weights[v][numb])
	{
		dist[edges[v][numb]] = dist[v] + weights[v][numb];
		q.push(pll(-dist[edges[v][numb]], edges[v][numb]));
	}
}

void say_yes()
{
	cout << "YES\n";
	for (int i = 0; i < maxn; ++i)
		for (int j = 0; j < edges[i].size(); ++j)
			if (i < edges[i][j])
				cout << i << ' ' << edges[i][j] << ' ' << ((weights[i][j] == 0) ? (ll)1e15 : weights[i][j]) << '\n';
	exit(0);
}

void say_no()
{
	printout("NO");
}

int main()
{
	fill(distances, distances + maxn, inf);
	fill(distances2, distances2 + maxn, inf);
	cin >> n >> m >> L >> S >> T;
	for (int i = 0; i < m; ++i)
	{
		int x, y, w;
		cin >> x >> y >> w;
		edges[x].push_back(y);
		edges[y].push_back(x);
		weights[x].push_back(w);
		weights[y].push_back(w);
		numbers[x].push_back(edges[y].size() - 1);
		numbers[y].push_back(edges[x].size() - 1);
	}
	priority_queue<pair<ll, ll>> q;
	q.push(pll(0, S));
	distances[S] = 0;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
			if (weights[cur_elem][i] != 0)
				update(cur_elem, i, distances, q);
	}
	if (distances[T] == L)
		say_yes();
	if (distances[T] < L)
		say_no();

	// here solution starts
	q.push(pll(0, T));
	distances2[T] = 0;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances2[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
			{
				if (distances[next] == inf)
					set_edge_len(cur_elem, i, 1);
				else
				{
					set_edge_len(cur_elem, i, max((ll)1, L - distances2[cur_elem] - distances[next]));
					if (L - distances2[cur_elem] - distances[next] >= 1)
						say_yes();
				}
			}
			update(cur_elem, i, distances2, q);
		}
	}
	say_no();
	return 0;
}
/*

*/


#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <math.h>
#include <map>
#include <set>
#include <stdio.h>
#include <stack>
#include <unordered_map>
#define ll long long
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pib pair<int, bool>
#define pdd pair<double, double>
#define pss pair<string, string>
#pragma comment(linker, "/STACK:251777215")
using namespace std;

const ll maxn = 1011;
const ll maxm = 10001;
const ll maxk = 1001;
const ll maxq = 1000001;
const ll margin = 1001;
const ll maxseg = 262144;
const ll secret_number = -87468267;
const pii secret_pair = make_pair(secret_number, secret_number);
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const int iinf = 2147483647 / 2;
const double pi = 3.141592653589793238462643383279502884;
const double eps = 1e-7;
const string something_very_long = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
const string govno = "g";
string impossible = "-1";

void printout(string str)
{
	cout << str;
	exit(0);
}

void Impossible()
{
	printout(impossible);
}

void print(char x, int numb)
{
	for (int i = 0; i < numb; ++i)
		cout << x;
}

int n, m, L, S, T;
vector<ll> edges[maxn];
vector<ll> weights[maxn];
vector<ll> numbers[maxn];
ll distances[maxn];
ll distances2[maxn];

void set_edge_len(int v, int numb, ll val)
{
	weights[v][numb] = val;
	weights[edges[v][numb]][numbers[v][numb]] = val;
}

void say_yes()
{
	cout << "YES\n";
	for (int i = 0; i < maxn; ++i)
		for (int j = 0; j < edges[i].size(); ++j)
			if (i < edges[i][j])
				cout << i << ' ' << edges[i][j] << ' ' << (weights[i][j] == 0) ? 1e15 : weights[i][j] << '\n';
	exit(0);
}

void say_no()
{
	printout("NO");
}

int main()
{
	for (int i = 0; i < maxn; ++i)
		distances[i] = inf;
	for (int i = 0; i < maxn; ++i)
		distances2[i] = inf;
	cin >> n >> m >> L >> S >> T;
	for (int i = 0; i < m; ++i)
	{
		int x, y, w;
		cin >> x >> y >> w;
		edges[x].push_back(y);
		edges[y].push_back(x);
		weights[x].push_back(w);
		weights[y].push_back(w);
		numbers[x].push_back(edges[y].size() - 1);
		numbers[y].push_back(edges[x].size() - 1);
	}
	priority_queue<pair<ll, ll>> q;
	q.push(pll(0, S));
	distances[S] = 0;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
				continue;
			if (distances[next] > distances[cur_elem] + next_dist)
			{
				distances[next] = distances[cur_elem] + next_dist;
				q.push(pll(-distances[next], next));
			}
		}
	}
	if (distances[T] == L)
		say_yes();
	if (distances[T] < L)
		say_no();

	// here solution starts
	q.push(pll(0, T));
	distances2[T] = 0;
	bool f = false;
	while (!q.empty())
	{
		pll cur_pair = q.top();
		q.pop();
		ll cur_elem = cur_pair.ss;
		if (distances2[cur_elem] != -cur_pair.ff)
			continue;
		for (int i = 0; i < edges[cur_elem].size(); ++i)
		{
			ll next = edges[cur_elem][i];
			ll next_dist = weights[cur_elem][i];
			if (next_dist == 0)
			{
				if (distances[next] == inf)
				{
					weights[cur_elem][i] = 1;
					weights[next][numbers[cur_elem][i]] = 1;
					if (distances2[cur_elem] + 1 < distances2[next])
					{
						distances2[next] = distances2[cur_elem] + 1;
						q.push(pll(-distances2[next], next));
					}
				}
				else
				{
					weights[cur_elem][i] = max((ll)1, L - distances2[cur_elem] - distances[next]);
					weights[next][numbers[cur_elem][i]] = max((ll)1, L - distances2[cur_elem] - distances[next]);
					if (L - distances2[cur_elem] - distances[next] >= 1)
					{
						f = true;
						break;
					}
					if (distances2[cur_elem] + weights[cur_elem][i] < distances2[next])
					{
						distances2[next] = distances2[cur_elem] + weights[cur_elem][i];
						q.push(pll(-distances2[next], next));
					}
				}
			}
			else if (distances2[next] >= distances2[cur_elem] + next_dist)
			{
				distances2[next] = distances2[cur_elem] + next_dist;
				q.push(pll(-distances2[next], next));
			}
		}
		if (f)
			break;
	}

	if (f)
		say_yes();
	else
		say_no();
	return 0;
}
/*

*/