#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define LC(x) (x<<1)
#define RC(x) ((x<<1)+1)
#define MID(x,y) ((x+y)>>1)
#define fin(name) freopen(name,"r",stdin)
#define fout(name) freopen(name,"w",stdout)
#define CLR(arr,val) memset(arr,val,sizeof(arr))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);
typedef pair<int, int> pii;
typedef long long LL;
const double PI = acos(-1.0);
const int N = 1e5 + 7;
const LL mod = 1e9 + 7;
int st[N], cnt[71], POW[N];
LL dp[2][(1 << 19) + 10];
vector<int>P;

inline bool prime(int x)
{
	for (int i = 2; i * i <= x; ++i)
		if (x % i == 0)
			return 0;
	return 1;
}
int main(void)
{
	int n, i, j;
	for (i = 2; i <= 70; ++i)
		if (prime(i))
			P.push_back(i);
	POW[0] = 1;
	for (i = 1; i < N; ++i)
		POW[i] = POW[i - 1] * 2LL % mod;
	for (i = 1; i <= 70; ++i)
	{
		int x = i;
		for (j = 0; j < 19; ++j)
		{
			if (x % P[j] == 0)
			{
				int up = 0;
				while (x % P[j] == 0)
				{
					++up;
					x /= P[j];
				}
				if (up & 1)
					st[i] |= (1 << j);
			}
		}
	}
	scanf("%d", &n);
	for (i = 1; i <= n; ++i)
	{
		int x;
		scanf("%d", &x);
		++cnt[x];
	}
	dp[0][0] = 1LL;
	int pre = 0, cur = 1;
	for (i = 1; i <= 70; ++i)
	{
		CLR(dp[cur], 0);
		if (!cnt[i])
		{
			for (j = 0; j < (1 << 19); ++j)
				dp[cur][j] = dp[pre][j];
		}
		else
		{
			for (j = 0; j < (1 << 19); ++j)
			{
				dp[cur][j ^ st[i]] = (dp[cur][j ^ st[i]] + dp[pre][j] * POW[cnt[i] - 1] % mod) % mod;
				dp[cur][j] = (dp[cur][j] + dp[pre][j] * POW[cnt[i] - 1] % mod) % mod;
			}
		}
		swap(cur, pre);
	}
	printf("%I64d\n", (dp[pre][0] - 1LL + mod) % mod);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define LC(x) (x<<1)
#define RC(x) ((x<<1)+1)
#define MID(x,y) ((x+y)>>1)
#define fin(name) freopen(name,"r",stdin)
#define fout(name) freopen(name,"w",stdout)
#define CLR(arr,val) memset(arr,val,sizeof(arr))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);
typedef pair<int, int> pii;
typedef long long LL;
const double PI = acos(-1.0);
const int N = 1e5 + 7;
const LL mod = 1e9 + 7;
int arr[N], st[N], cnt[N], POW[N];
LL dp[2][1 << 19];
vector<int>P;

inline bool prime(int x)
{
    for(int i = 2; i * i <= x; ++i)
        if(x % i == 0)
            return 0;
    return 1;
}
inline LL mul(LL a, LL b)
{
    LL r = 0;
    while(b)
    {
        if(b & 1)
            r = (r + a) % mod;
        a = (a + a) % mod;
        b >>= 1;
    }
    return r;
}
int main(void)
{
    int n, i, j;
    for(i = 2; i <= 70; ++i)
        if(prime(i))
            P.push_back(i);
    POW[0] = 1;
    for(i = 1; i < N; ++i)
        POW[i] = POW[i - 1] * 2LL % mod;
    cin >> n;
    for(i = 1; i <= n; ++i)
    {
        cin >> arr[i];
        ++cnt[arr[i]];
        for(j = 0; j < 19; ++j)
        {
            if(arr[i] % P[j] == 0)
            {
                int up = 0;
                while(arr[i] % P[j] == 0)
                {
                    ++up;
                    arr[i] /= P[j];
                }
                if(up & 1)
                    st[i] |= (1 << j);
            }
        }
    }
    dp[0][0] = 1;
    int cur = 0, nxt = 1;
    for(i = 1; i <= 70; ++i)
    {
        CLR(dp[nxt], 0);
        if(cnt[i] == 0)
        {
            for(int j = 0; j < (1 << 19); ++j)
                dp[nxt][j] = dp[cur][j];
        }
        else
        {
            for(int j = 0; j < (1 << 19); ++j)
            {
                dp[nxt][j ^ st[i]] = (dp[nxt][j ^ st[i]] + mul(dp[cur][j], POW[cnt[i] - 1])) % mod;
                dp[nxt][j] = (dp[nxt][j] + mul(dp[cur][j], POW[cnt[i] - 1])) % mod;
            }
        }
        swap(nxt, cur);
    }
    cout << (dp[cur][0] - 1LL + mod) % mod << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define LC(x) (x<<1)
#define RC(x) ((x<<1)+1)
#define MID(x,y) ((x+y)>>1)
#define fin(name) freopen(name,"r",stdin)
#define fout(name) freopen(name,"w",stdout)
#define CLR(arr,val) memset(arr,val,sizeof(arr))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);
typedef pair<int, int> pii;
typedef long long LL;
const double PI = acos(-1.0);
const int N = 1e5 + 7;
const LL mod = 1e9 + 7;
int st[N], cnt[71], POW[N];
int dp[2][(1 << 19) + 10];
vector<int>P;

inline bool prime(int x)
{
	for (int i = 2; i * i <= x; ++i)
		if (x % i == 0)
			return 0;
	return 1;
}
int main(void)
{
	int n, i, j;
	for (i = 2; i <= 70; ++i)
		if (prime(i))
			P.push_back(i);
	POW[0] = 1;
	for (i = 1; i < N; ++i)
		POW[i] = POW[i - 1] * 2LL % mod;
	scanf("%d", &n);
	for (i = 1; i <= n; ++i)
	{
		int x;
		scanf("%d", &x);
		++cnt[x];
		for (j = 0; j < 19; ++j)
		{
			if (x % P[j] == 0)
			{
				int up = 0;
				while (x % P[j] == 0)
				{
					++up;
					x /= P[j];
				}
				if (up & 1)
					st[i] |= (1 << j);
			}
		}
	}
	for (i = 1; i <= 70; ++i)
	{
		int x = i;
		for (j = 0; j < 19; ++j)
		{
			if (x % P[j] == 0)
			{
				int up = 0;
				while (x % P[j] == 0)
				{
					++up;
					x /= P[j];
				}
				if (up & 1)
					st[i] |= (1 << j);
			}
		}
	}
	dp[0][0] = 1LL;
	int pre = 0, cur = 1;
	for (i = 1; i <= 70; ++i)
	{
		CLR(dp[cur], 0);
		if (!cnt[i])
		{
			for (j = 0; j < (1 << 19); ++j)
				dp[cur][j] = dp[pre][j];
		}
		else
		{
			for (j = 0; j < (1 << 19); ++j)
			{
				dp[cur][j ^ st[i]] = 1LL * (1LL * dp[cur][j ^ st[i]] + 1LL * dp[pre][j] * POW[cnt[i] - 1]) % mod;
				dp[cur][j] = 1LL * (1LL * dp[cur][j] + 1LL * dp[pre][j] * 1LL * POW[cnt[i] - 1]) % mod;
			}
		}
		swap(cur, pre);
	}
	printf("%d\n", (dp[pre][0] - 1LL + mod) % mod);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define LC(x) (x<<1)
#define RC(x) ((x<<1)+1)
#define MID(x,y) ((x+y)>>1)
#define fin(name) freopen(name,"r",stdin)
#define fout(name) freopen(name,"w",stdout)
#define CLR(arr,val) memset(arr,val,sizeof(arr))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);
typedef pair<int, int> pii;
typedef long long LL;
const double PI = acos(-1.0);
const int N = 1e5 + 7;
const LL mod = 1e9 + 7;
int st[N], cnt[71], POW[N];
int dp[2][(1 << 19) + 10];
vector<int>P;

inline bool prime(int x)
{
	for (int i = 2; i * i <= x; ++i)
		if (x % i == 0)
			return 0;
	return 1;
}
int main(void)
{
	int n, i, j;
	for (i = 2; i <= 70; ++i)
		if (prime(i))
			P.push_back(i);
	POW[0] = 1;
	for (i = 1; i < N; ++i)
		POW[i] = POW[i - 1] * 2LL % mod;
	scanf("%d", &n);
	for (i = 1; i <= n; ++i)
	{
		int x;
		scanf("%d", &x);
		++cnt[x];
		for (j = 0; j < 19; ++j)
		{
			if (x % P[j] == 0)
			{
				int up = 0;
				while (x % P[j] == 0)
				{
					++up;
					x /= P[j];
				}
				if (up & 1)
					st[i] |= (1 << j);
			}
		}
	}
	for (i = 1; i <= 70; ++i)
	{
		int x = i;
		for (j = 0; j < 19; ++j)
		{
			if (x % P[j] == 0)
			{
				int up = 0;
				while (x % P[j] == 0)
				{
					++up;
					x /= P[j];
				}
				if (up & 1)
					st[i] |= (1 << j);
			}
		}
	}
	dp[0][0] = 1LL;
	int pre = 0, cur = 1;
	for (i = 1; i <= 70; ++i)
	{
		CLR(dp[cur], 0);
		if (!cnt[i])
		{
			for (j = 0; j < (1 << 19); ++j)
				dp[cur][j] = dp[pre][j];
		}
		else
		{
			for (j = 0; j < (1 << 19); ++j)
			{
				dp[cur][j ^ st[i]] = 1LL * (1LL * dp[cur][j ^ st[i]] + 1LL * dp[pre][j] * POW[cnt[i] - 1]) % mod;
				dp[cur][j] = 1LL * (1LL * dp[cur][j] + 1LL * dp[pre][j] * 1LL * POW[cnt[i] - 1]) % mod;
			}
		}
		swap(cur, pre);
	}
	printf("%d\n", (dp[cur][0] - 1LL + mod) % mod);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = (1 << 19) + 2;
const int mod = 1e9 + 7;
int n, cnt[75];
int spf[75], pidx[70];
int mem[72][N], mask[72];

void sieve() {
	for (int i = 2; i <= 70; i++) {
		spf[i] = i;
	}

	for (int i = 2; i * i <= 70; i++) {
		if (spf[i] != i) continue;

		for (int j = i * i; j <= 70; j += i) {
			spf[j] = min(spf[j],  i);
		}
	}

	int p = 0;
	for (int i =2; i <= 70; i++) {
		if (spf[i] == i) {
			pidx[i] = p++;
		}
	}
}

int to_bit(int x) {
	int bit = 0;
	while (x > 1) {
		bit ^= (1 << pidx[spf[x]]);
		x /= spf[x];
	}
	return bit;
}

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

	sieve();
	for (int i = 1; i <= 70; i++) {
		mask[i] = to_bit(i);
	}

	cin >> n;

	int x;
	for (int i = 0; i < n; i++) {
		cin >> x;
		cnt[x]++;
	}

	mem[0][0] = 1;
	for (int i = 1; i <= 70; i++) {
		int cntInc = cnt[i] ? (1 << (cnt[i] - 1)) : 0;
		int cntExc = cnt[i] ? (1 << (cnt[i] - 1)) : 1;
		for (int j = 0; j < N; j++) {
			mem[i][j] = (mem[i - 1][j] * 1LL * cntExc) % mod;
			mem[i][j] = (mem[i][j] + (mem[i - 1][j ^ mask[i]] * 1LL * cntInc) % mod) % mod;
		}
	}

	cout << mem[70][0] - 1 << '\n';
}


#include <bits/stdc++.h>
using namespace std;
const int N = (1 << 19) + 2;
const int mod = 1e9 + 7;
int n, cnt[75];
int spf[75], pidx[70];
int mem[N][72], mask[72];

void sieve() {

	for (int i = 2; i <= 70; i++) {
		spf[i] = i;
	}

	int p = 0;

	for (int i = 2; i * i <= 70; i++) {
		if (spf[i] != i) continue;

		pidx[i] = p++;
		for (int j = i * i; j <= 70; j += i) {
			spf[j] = min(spf[j],  i);
		}
	}
}

int to_bit(int x) {
	int bit = 0;
	while (x > 1) {
		bit ^= (1 << pidx[spf[x]]);
		x /= spf[x];
	}
	return bit;
}

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

	sieve();
	for (int i = 1; i <= 70; i++) {
		mask[i] = to_bit(i);
	}

	cin >> n;

	int x;
	for (int i = 0; i < n; i++) {
		cin >> x;
		cnt[x]++;
	}

	mem[0][0] = 1;
	for (int i = 1; i <= 70; i++) {
		for (int j = 0; j < N; j++) {
			mem[i][j] = (mem[i - 1][j] * 1LL * (cnt[i] ? (1 << (cnt[i] - 1)) : 1)) % mod;
			mem[i][j] = (mem[i][j] + (mem[i - 1][j ^ mask[i]] * 1LL * (cnt[i] ? (1 << (cnt[i] - 1)) : 0)) % mod) % mod;
		}
	}

	cout << mem[70][0] - 1 << '\n';
}


#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const int N=1e3+20;
int n,m,s,t,L,first[N],tot;
ll dis[N];
bool vis[N];
struct node
{
    int v,next,flag;
    ll w;
} e[N*20];
void add(int u,int v,ll w)
{
    e[tot].v=v;
    e[tot].w=w;
    if(w==0)e[tot].flag=1;
    e[tot].next=first[u];
    first[u]=tot++;
}
struct point
{
    point(int a,ll b)
    {
        x=a,val=b;
    }
    int x;
    ll val;
    bool friend operator <(point A,point B)
    {
        return A.val>B.val;
    }
};
void spfa()
{
    for(int i=0;i<n;i++)
        dis[i]=1000000000000000000,vis[i]=0;
    priority_queue<point>q;
    dis[s]=0;
    q.push(point(s,0));
    while(!q.empty())
    {
        point u=q.top();
        q.pop();
        for(int i=first[u.x]; ~i; i=e[i].next)
        {
            int v=e[i].v;
            if(e[i].w==0)continue;
            if(dis[v]>u.val+e[i].w)
            {
                dis[v]=u.val+e[i].w;
                q.push(point(v,dis[v]));
            }
        }
    }
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    mem(first,-1);
    int u,v;
    ll w;
    cin>>n>>m>>L>>s>>t;
    for(int i=0; i<m; i++)
    {
        cin>>u>>v>>w;
        add(u,v,w);
        add(v,u,w);
    }
    spfa();
    if(dis[t]<L)puts("NO");
    else
    {
       for(int i=0;i<tot;i+=2)
       {
           if(!e[i].flag)continue;
           e[i].w=e[i^1].w=1;
           spfa();
           if(dis[t]<L)
               e[i].w=e[i^1].w=L-dis[t]+1;
       }
       if(dis[t]>L)puts("NO");
       else
       {
           puts("YES");
           for(int i=0;i<tot;i+=2)
            printf("%d %d %lld\n",e[i^1].v,e[i].v,e[i].w);
       }
    }
    return 0;
}


#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const int N=1e3+20;
int n,m,s,t,L,first[N],tot,pre[N];
ll dis[N];
bool vis[N];
struct node
{
    int v,next;
    ll w;
} e[N*20];
void add(int u,int v,ll w)
{
    e[tot].v=v;
    e[tot].w=w;
    e[tot].next=first[u];
    first[u]=tot++;
}
void spfa(bool flag)
{
    mem(dis,0x3f);
    mem(pre,-1);
    mem(vis,0);
    queue<int>q;
    q.push(s);
    vis[s]=1;
    dis[s]=0;
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        vis[u]=0;
        for(int i=first[u]; ~i; i=e[i].next)
        {
            int v=e[i].v;
            if(flag&&e[i].w==0)continue;
            if(dis[v]>dis[u]+e[i].w)
            {
                dis[v]=dis[u]+e[i].w;
                pre[v]=i;
                if(!vis[v])
                {
                    vis[v]=1;
                    q.push(v);
                }
            }
        }
    }
}
int main()
{
    mem(first,-1);
    int u,v,w;
    cin>>n>>m>>L>>s>>t;
    for(int i=0; i<m; i++)
    {
        cin>>u>>v>>w;
        add(u,v,w);
        add(v,u,w);
    }
    spfa(1);
    if(dis[t]<L)puts("NO");
    else if(dis[t]==L)
    {
        puts("YES");
        for(int i=0; i<tot; i+=2)
        {
            printf("%d %d ",e[i^1].v,e[i].v);
            if(!e[i].w)
                printf("1000000000000000000\n");
            else
                printf("%d\n",e[i].w);
        }
    }
    else
    {
        spfa(0);
        int ans=0;
        for(int i=pre[t]; ~i; i=pre[e[i^1].v])if(e[i].w==0)ans++;
        if(ans==0&&(dis[t]<L||dis[t]>L))puts("NO");
        else if(ans==0&&dis[t]==L)
        {
            printf("YES\n");
            for(int i=0; i<tot; i+=2)
            {
                printf("%d %d ",e[i^1].v,e[i].v);
                if(!e[i].w)printf("1000000000000000000\n");
                else printf("%d\n",e[i].w);
            }
        }
        else if(ans!=0)
        {
            if(dis[t]+ans>L)printf("NO\n");
            else
            {
                printf("YES\n");
                ll x=1ll*L-dis[t]-ans+1;
                for(int i=pre[t]; ~i; i=pre[e[i^1].v])
                {
                    if(!e[i].w)
                    {
                        if(ans!=1)
                            e[i].w=1;
                        else
                            e[i].w=x;
                    }
                }
                for(int i=0; i<tot; i+=2)
                {
                    printf("%d %d ",e[i^1].v,e[i].v);
                    if(!e[i].w)printf("1000000000000000000\n");
                    else printf("%d\n",e[i].w);
                }
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const int N=1e3+20;
int n,m,s,t,L,first[N],tot,pre[N];
ll dis[N];
bool vis[N];
struct node
{
    int v,w,next;
}e[N*20];
void add(int u,int v,int w)
{
    e[tot].v=v;
    e[tot].w=w;
    e[tot].next=first[u];
    first[u]=tot++;
}
void spfa()
{
    mem(dis,0x3f);
    mem(pre,-1);
    queue<int>q;
    q.push(s);
    vis[s]=1;
    dis[s]=0;
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        vis[u]=0;
        for(int i=first[u];~i;i=e[i].next)
        {
            int v=e[i].v;
            if(dis[v]>dis[u]+e[i].w)
            {
                dis[v]=dis[u]+e[i].w;
                pre[v]=i;
                if(!vis[v])
                {
                    vis[v]=1;
                    q.push(v);
                }
            }
        }
    }
    mem(vis,0);
    if(dis[t]>L)puts("NO");
    else
    {
        for(int i=pre[t];~i;i=pre[e[i^1].v])
        {
            vis[i]=1;
            if(e[i].w==0)
            {
                e[i].w=e[i^1].w=L-dis[t];
                L=dis[t];
            }
        }
        if(L!=dis[t])puts("NO");
        else
        {
            puts("YES");
            for(int i=0;i<tot;i+=2)
            {
                printf("%d %d %d\n",e[i^1].v,e[i].v,e[i].w);
            }
        }
    }
}
int main()
{
    mem(first,-1);
    int u,v,w;
    cin>>n>>m>>L>>s>>t;
    for(int i=0;i<m;i++)
    {
        cin>>u>>v>>w;
        add(u,v,w);
        add(v,u,w);
    }
    spfa();

    return 0;
}


#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const int N=1e3+20;
int n,m,s,t,L,first[N],tot,pre[N];
ll dis[N];
bool vis[N];
struct node
{
    int v,next;
    ll w;
} e[N*20];
void add(int u,int v,ll w)
{
    e[tot].v=v;
    e[tot].w=w;
    e[tot].next=first[u];
    first[u]=tot++;
}
void spfa(bool flag)
{
    mem(dis,0x3f);
    mem(pre,-1);
    mem(vis,0);
    queue<int>q;
    q.push(s);
    vis[s]=1;
    dis[s]=0;
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        vis[u]=0;
        for(int i=first[u]; ~i; i=e[i].next)
        {
            int v=e[i].v;
            if(flag&&e[i].w==0)continue;
            if(dis[v]>dis[u]+e[i].w)
            {
                dis[v]=dis[u]+e[i].w;
                pre[v]=i;
                if(!vis[v])
                {
                    vis[v]=1;
                    q.push(v);
                }
            }
        }
    }
}
int main()
{
    mem(first,-1);
    int u,v;
    ll w;
    cin>>n>>m>>L>>s>>t;
    for(int i=0; i<m; i++)
    {
        cin>>u>>v>>w;
        add(u,v,w);
        add(v,u,w);
    }
    spfa(1);
    if(dis[t]<L)puts("NO");
    else if(dis[t]==L)
    {
        puts("YES");
        for(int i=0; i<tot; i+=2)
        {
            printf("%d %d ",e[i^1].v,e[i].v);
            if(!e[i].w)
                printf("1000000000000000000\n");
            else
                printf("%lld\n",e[i].w);
        }
    }
    else
    {
        spfa(0);
        int ans=0;
        for(int i=pre[t]; ~i; i=pre[e[i^1].v])if(e[i].w==0)ans++;
        if(ans==0&&(dis[t]<L||dis[t]>L))puts("NO");
        else if(ans==0&&dis[t]==L)
        {
            printf("YES\n");
            for(int i=0; i<tot; i+=2)
            {
                printf("%d %d ",e[i^1].v,e[i].v);
                if(!e[i].w)printf("1000000000000000000\n");
                else printf("%lld\n",e[i].w);
            }
        }
        else if(ans!=0)
        {
            if(dis[t]+ans>L)printf("NO\n");
            else
            {
                printf("YES\n");
                ll x=1ll*L-dis[t]-ans+1;
                for(int i=pre[t]; ~i; i=pre[e[i^1].v])
                {
                    if(!e[i].w)
                    {
                        if(ans!=1)
                            e[i^1].w=e[i].w=1;
                        else
                            e[i^1].w=e[i].w=x;
                    }
                }
                for(int i=0; i<tot; i+=2)
                {
                    printf("%d %d ",e[i^1].v,e[i].v);
                    if(!e[i].w)printf("1000000000000000000\n");
                    else printf("%lld\n",e[i].w);
                }
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const int N=1e3+20;
int n,m,s,t,L,first[N],tot,pre[N];
ll dis[N];
bool vis[N];
struct node
{
    int v,w,next;
} e[N*20];
void add(int u,int v,int w)
{
    e[tot].v=v;
    e[tot].w=w;
    e[tot].next=first[u];
    first[u]=tot++;
}
void spfa(bool flag)
{
    mem(dis,0x3f);
    mem(pre,-1);
    mem(vis,0);
    queue<int>q;
    q.push(s);
    vis[s]=1;
    dis[s]=0;
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        vis[u]=0;
        for(int i=first[u]; ~i; i=e[i].next)
        {
            int v=e[i].v;
            if(flag&&e[i].w==0)continue;
            if(dis[v]>dis[u]+e[i].w)
            {
                dis[v]=dis[u]+e[i].w;
                pre[v]=i;
                if(!vis[v])
                {
                    vis[v]=1;
                    q.push(v);
                }
            }
        }
    }
}
int main()
{
    mem(first,-1);
    int u,v,w;
    cin>>n>>m>>L>>s>>t;
    for(int i=0; i<m; i++)
    {
        cin>>u>>v>>w;
        add(u,v,w);
        add(v,u,w);
    }
    spfa(1);
    if(dis[t]<L)puts("NO");
    else
    {
        spfa(0);
        if(dis[t]>L)puts("NO");
        else
        {
            for(int i=pre[t]; ~i; i=pre[e[i^1].v])
            {
                vis[i]=1;
                if(e[i].w==0)
                {
                    e[i].w=e[i^1].w=L-dis[t];
                    L=dis[t];
                }
            }
            if(L!=dis[t])puts("NO");
            else
            {
                puts("YES");
                for(int i=0; i<tot; i+=2)
                {
                    printf("%d %d %d\n",e[i^1].v,e[i].v,e[i].w);
                }
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const int N=1e3+20;
int n,m,s,t,L,first[N],tot;
ll dis[N];
struct node
{
    int v,next,flag;
    ll w;
} e[N*20];
struct point
{
    int x;
    ll val;
    bool friend operator <(point A,point B)
    {
        return A.val>B.val;
    }
};
void add(int u,int v,ll w)
{
    e[tot].v=v;
    e[tot].w=w;
    if(w==0)e[tot].flag=1;
    e[tot].next=first[u];
    first[u]=tot++;
}
void spfa()
{
    mem(dis,0x3f);
    priority_queue<point>q;
    point u;
    u.x=s;
    u.val=0;
    q.push(u);
    dis[s]=0;
    while(!q.empty())
    {
        u=q.top();
        q.pop();
        for(int i=first[u.x]; ~i; i=e[i].next)
        {
            int v=e[i].v;
            if(e[i].w==0)continue;
            if(dis[v]>u.val+e[i].w)
            {
                dis[v]=u.val+e[i].w;
                u.val=dis[v];
                u.x=v;
                q.push(u);
            }
        }
    }
}
int main()
{
    mem(first,-1);
    int u,v;
    ll w;
    cin>>n>>m>>L>>s>>t;
    for(int i=0; i<m; i++)
    {
        cin>>u>>v>>w;
        add(u,v,w);
        add(v,u,w);
    }
    spfa();
    if(dis[t]<L)puts("NO");
    else
    {
       for(int i=0;i<tot;i+=2)
       {
           if(!e[i].flag)continue;
           e[i].w=e[i^1].w=1;
           spfa();
           if(dis[t]<L)
               e[i].w=e[i^1].w=L-dis[t]+1;
       }
       if(dis[t]>L)puts("NO");
       else
       {
           puts("YES");
           for(int i=0;i<tot;i+=2)
            printf("%d %d %lld\n",e[i^1].v,e[i].v,e[i].w);
       }
    }
    return 0;
}


#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const int N=1e3+20;
int n,m,s,t,L,first[N],tot,pre[N];
ll dis[N];
bool vis[N];
struct node
{
    int v,next,flag;
    ll w;
} e[N*20];
void add(int u,int v,ll w)
{
    e[tot].v=v;
    e[tot].w=w;
    if(w==0)e[tot].flag=1;
    e[tot].next=first[u];
    first[u]=tot++;
}
void spfa()
{
    mem(dis,0x3f);
    mem(pre,-1);
    mem(vis,0);
    queue<int>q;
    q.push(s);
    vis[s]=1;
    dis[s]=0;
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        vis[u]=0;
        for(int i=first[u]; ~i; i=e[i].next)
        {
            int v=e[i].v;
            if(e[i].w==0)continue;
            if(dis[v]>dis[u]+e[i].w)
            {
                dis[v]=dis[u]+e[i].w;
                pre[v]=i;
                if(!vis[v])
                {
                    vis[v]=1;
                    q.push(v);
                }
            }
        }
    }
}
int main()
{
    mem(first,-1);
    int u,v;
    ll w;
    cin>>n>>m>>L>>s>>t;
    for(int i=0; i<m; i++)
    {
        cin>>u>>v>>w;
        add(u,v,w);
        add(v,u,w);
    }
    spfa();
    if(dis[t]<L)puts("NO");
    else
    {
        for(int i=0; i<tot; i+=2)
            if(e[i].flag)
                e[i].w=1;
        spfa();
        if(dis[t]>L)puts("NO");
        else
        {
            puts("YES");
            ll x=L-dis[t];
            for(int i=pre[t]; ~i; i=pre[e[i^1].v])
            {
                if(e[i].flag)
                {
                    e[i].w+=x;
                    e[i^1].w+=x;
                    x=0;
                    e[i].flag=0;
                }
            }
            for(int i=0; i<tot; i++)
                if(e[i].flag)
                    e[i].w=1000000000000000000;
            for(int i=0; i<tot; i+=2)
                printf("%d %d %lld\n",e[i^1].v,e[i].v,e[i].w);
        }
    }
    return 0;
}


#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const int N=1e3+20;
int n,m,s,t,L,first[N],tot,pre[N];
ll dis[N];
bool vis[N];
struct node
{
    int v,next;
    ll w;
} e[N*20];
void add(int u,int v,ll w)
{
    e[tot].v=v;
    e[tot].w=w;
    e[tot].next=first[u];
    first[u]=tot++;
}
void spfa(bool flag)
{
    mem(dis,0x3f);
    mem(pre,-1);
    mem(vis,0);
    queue<int>q;
    q.push(s);
    vis[s]=1;
    dis[s]=0;
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        vis[u]=0;
        for(int i=first[u]; ~i; i=e[i].next)
        {
            int v=e[i].v;
            if(flag&&e[i].w==0)continue;
            if(dis[v]>dis[u]+e[i].w)
            {
                dis[v]=dis[u]+e[i].w;
                pre[v]=i;
                if(!vis[v])
                {
                    vis[v]=1;
                    q.push(v);
                }
            }
        }
    }
}
int main()
{
    mem(first,-1);
    int u,v;
    ll w;
    cin>>n>>m>>L>>s>>t;
    for(int i=0; i<m; i++)
    {
        cin>>u>>v>>w;
        add(u,v,w);
        add(v,u,w);
    }
    spfa(1);
    if(dis[t]<L)puts("NO");
    else if(dis[t]==L)
    {
        puts("YES");
        for(int i=0; i<tot; i+=2)
        {
            printf("%d %d ",e[i^1].v,e[i].v);
            if(!e[i].w)
                printf("1000000000000000000\n");
            else
                printf("%lld\n",e[i].w);
        }
    }
    else
    {
        spfa(0);
        int ans=0;
        for(int i=pre[t]; ~i; i=pre[e[i^1].v])if(e[i].w==0)ans++;
        if(ans==0&&(dis[t]<L||dis[t]>L))puts("NO");
        else if(ans==0&&dis[t]==L)
        {
            printf("YES\n");
            for(int i=0; i<tot; i+=2)
            {
                printf("%d %d ",e[i^1].v,e[i].v);
                if(!e[i].w)printf("1000000000000000000\n");
                else printf("%lld\n",e[i].w);
            }
        }
        else if(ans!=0)
        {
            if(dis[t]+ans>L)printf("NO\n");
            else
            {
                printf("YES\n");
                ll x=1ll*L-dis[t]-ans+1;
                for(int i=pre[t]; ~i; i=pre[e[i^1].v])
                {
                    if(!e[i].w)
                    {
                        if(ans!=1)
                            e[i^1].w=e[i].w=1;
                        else
                            e[i^1].w=e[i].w=x;
                            ans--;
                    }
                }
                for(int i=0; i<tot; i+=2)
                {
                    printf("%d %d ",e[i^1].v,e[i].v);
                    if(!e[i].w)printf("1000000000000000000\n");
                    else printf("%lld\n",e[i].w);
                }
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const int N=1e3+20;
int n,m,s,t,L,first[N],tot,pre[N];
ll dis[N];
bool vis[N];
struct node
{
    int v,next,flag;
    ll w;
} e[N*20];
void add(int u,int v,ll w)
{
    e[tot].v=v;
    e[tot].w=w;
    if(w==0)e[tot].flag=1;
    e[tot].next=first[u];
    first[u]=tot++;
}
void spfa()
{
    mem(dis,0x3f);
    mem(pre,-1);
    mem(vis,0);
    queue<int>q;
    q.push(s);
    vis[s]=1;
    dis[s]=0;
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        vis[u]=0;
        for(int i=first[u]; ~i; i=e[i].next)
        {
            int v=e[i].v;
            if(e[i].w==0)continue;
            if(dis[v]>dis[u]+e[i].w)
            {
                dis[v]=dis[u]+e[i].w;
                pre[v]=i;
                if(!vis[v])
                {
                    vis[v]=1;
                    q.push(v);
                }
            }
        }
    }
}
int main()
{
    mem(first,-1);
    int u,v;
    ll w;
    cin>>n>>m>>L>>s>>t;
    for(int i=0; i<m; i++)
    {
        cin>>u>>v>>w;
        add(u,v,w);
        add(v,u,w);
    }
    spfa();
    if(dis[t]<L)puts("NO");
    else
    {
       for(int i=0;i<tot;i+=2)
       {
           if(!e[i].flag)continue;
           e[i].w=e[i^1].w=1;
           spfa();
           if(dis[t]<L)
               e[i].w=e[i^1].w=L-dis[t]+1;
       }
       if(dis[t]>L)puts("NO");
       else
       {
           puts("YES");
           for(int i=0;i<tot;i+=2)
            printf("%d %d %lld\n",e[i^1].v,e[i].v,e[i].w);
       }
    }
    return 0;
}


#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const int N=1e3+20;
int n,m,s,t,L,first[N],tot;
ll dis[N];
bool vis[N];
struct node
{
    int v,next,flag;
    ll w;
} e[N*20];
void add(int u,int v,ll w)
{
    e[tot].v=v;
    e[tot].w=w;
    if(w==0)e[tot].flag=1;
    e[tot].next=first[u];
    first[u]=tot++;
}
void spfa()
{
    for(int i=0;i<n;i++)
        dis[i]=1000000000000000000,vis[i]=0;
    queue<int>q;
    q.push(s);
    vis[s]=1;
    dis[s]=0;
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        vis[u]=0;
        for(int i=first[u]; ~i; i=e[i].next)
        {
            int v=e[i].v;
            if(e[i].w==0)continue;
            if(dis[v]>dis[u]+e[i].w)
            {
                dis[v]=dis[u]+e[i].w;
                if(!vis[v])
                {
                    vis[v]=1;
                    q.push(v);
                }
            }
        }
    }
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    mem(first,-1);
    int u,v;
    ll w;
    cin>>n>>m>>L>>s>>t;
    for(int i=0; i<m; i++)
    {
        cin>>u>>v>>w;
        add(u,v,w);
        add(v,u,w);
    }
    spfa();
    if(dis[t]<L)puts("NO");
    else
    {
       for(int i=0;i<tot;i+=2)
       {
           if(!e[i].flag)continue;
           e[i].w=e[i^1].w=1;
           spfa();
           if(dis[t]<L)
               e[i].w=e[i^1].w=L-dis[t]+1;
       }
       if(dis[t]>L)puts("NO");
       else
       {
           puts("YES");
           for(int i=0;i<tot;i+=2)
            printf("%d %d %lld\n",e[i^1].v,e[i].v,e[i].w);
       }
    }
    return 0;
}


#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const int N=1e3+20;
int n,m,s,t,L,first[N],tot;
ll dis[N];
struct node
{
    int v,next,flag;
    ll w;
} e[N*20];
struct point
{
    int x;
    ll val;
    bool friend operator <(point A,point B)
    {
        return A.val>B.val;
    }
};
void add(int u,int v,ll w)
{
    e[tot].v=v;
    e[tot].w=w;
    if(w==0)e[tot].flag=1;
    e[tot].next=first[u];
    first[u]=tot++;
}
void spfa()
{
    mem(dis,0x3f);
    priority_queue<point>q;
    point u;
    u.x=s;
    u.val=0;
    q.push(u);
    dis[s]=0;
    while(!q.empty())
    {
        u=q.top();
        q.pop();
        for(int i=first[u.x]; ~i; i=e[i].next)
        {
            int v=e[i].v;
            if(e[i].w==0)continue;
            if(dis[v]>dis[u.x]+e[i].w)
            {
                dis[v]=dis[u.x]+e[i].w;
                u.val=dis[v];
                u.x=v;
                q.push(u);
            }
        }
    }
}
int main()
{
    mem(first,-1);
    int u,v;
    ll w;
    cin>>n>>m>>L>>s>>t;
    for(int i=0; i<m; i++)
    {
        cin>>u>>v>>w;
        add(u,v,w);
        add(v,u,w);
    }
    spfa();
    if(dis[t]<L)puts("NO");
    else
    {
       for(int i=0;i<tot;i+=2)
       {
           if(!e[i].flag)continue;
           e[i].w=e[i^1].w=1;
           spfa();
           if(dis[t]<L)
               e[i].w=e[i^1].w=L-dis[t]+1;
       }
       if(dis[t]>L)puts("NO");
       else
       {
           puts("YES");
           for(int i=0;i<tot;i+=2)
            printf("%d %d %lld\n",e[i^1].v,e[i].v,e[i].w);
       }
    }
    return 0;
}


#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const int N=1e3+20;
int n,m,s,t,L,first[N],tot,pre[N];
ll dis[N];
bool vis[N];
struct node
{
    int v,next,flag;
    ll w;
} e[N*20];
void add(int u,int v,ll w)
{
    e[tot].v=v;
    e[tot].w=w;
    if(w==0)e[tot].flag=1;
    e[tot].next=first[u];
    first[u]=tot++;
}
void spfa()
{
    mem(dis,0x3f);
    mem(pre,-1);
    mem(vis,0);
    queue<int>q;
    q.push(s);
    vis[s]=1;
    dis[s]=0;
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        vis[u]=0;
        for(int i=first[u]; ~i; i=e[i].next)
        {
            int v=e[i].v;
            if(e[i].w==0)continue;
            if(dis[v]>dis[u]+e[i].w)
            {
                dis[v]=dis[u]+e[i].w;
                pre[v]=i;
                if(!vis[v])
                {
                    vis[v]=1;
                    q.push(v);
                }
            }
        }
    }
}
int main()
{
    mem(first,-1);
    int u,v;
    ll w;
    cin>>n>>m>>L>>s>>t;
    for(int i=0; i<m; i++)
    {
        cin>>u>>v>>w;
        add(u,v,w);
        add(v,u,w);
    }
    spfa();
    if(dis[t]<L)puts("NO");
    else
    {
        for(int i=0; i<tot; i+=2)
            if(e[i].flag)
                e[i^1].w=e[i].w=1;
        spfa();
        if(dis[t]>L)puts("NO");
        else
        {
            puts("YES");
            ll x=L-dis[t];
            for(int i=pre[t]; ~i; i=pre[e[i^1].v])
            {
                if(e[i].flag)
                {
                    e[i].w+=x;
                    e[i^1].w+=x;
                    x=0;
                    e[i^1].flag=e[i].flag=0;
                }
            }
            for(int i=0; i<tot; i++)
                if(e[i].flag)
                    e[i^1].w=e[i].w=1000000000000000000;
            for(int i=0; i<tot; i+=2)
                printf("%d %d %lld\n",e[i^1].v,e[i].v,e[i].w);
        }
    }
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <locale>
using namespace std;
#define MS0(I) memset(I, 0, sizeof(I));
#define MS1(I) memset(I, -1, sizeof(I));
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, s, n) for(int i = (s); i < (n); ++i)
#define per1(i, a, b) for(int i = a; i >= b; --i)
#define DRI(A) int A; scanf("%d", &A);
#define DRII(A, B) int A, B; scanf("%d %d", &A, &B);
#define DRIII(A, B, C) int A, B, C; scanf("%d %d %d", &A, &B, &C);
#define DRL(A) long long A; scanf("%lld", &A);
#define DRLL(A, B) long long A, B; scanf("%lld %lld", &A, &B);
#define DRLLL(A, B, C) long long A, B, C; scanf("%lld %lld %lld", &A, &B, &C);
#define SZ(X) ((int)X.size() )
#define MP make_pair
#define pb push_back
#define F first
#define S second
#define ALL(I) (I).begin(), (I).end()
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;
typedef long double LDB;
typedef pair<int, int> PII;
typedef pair<int, LL> PIL;
typedef pair<LL, int> PLI;
typedef pair<LL, LL> PLL;
const double eps = 1e-7;
const double PI = acos(-1);
const LL INFF = 1e10;
const int INF = 1e9;
const int mod = 1e9+7;
const int MAX = 1e3+7;
int n, m, s, t;
int v1[MAX], v2[MAX];
LL D, w[MAX];
vector<int>edge[MAX];
LL dis[MAX][MAX];
bool ck[MAX];
void go(int st){
  priority_queue<PLI, vector<PLI>, greater<PLI>>pq;
  pq.push(MP(0, st)); MS0(ck);
  while(!pq.empty()){
    LL d; int u; tie(d, u) = pq.top(); pq.pop();
    if(ck[u]) continue; dis[u][st] = dis[st][u] = d; ck[u] = 1;
    for(int x : edge[u]){
      int v = v1[x] + v2[x] - u;
      if(ck[v]) continue;
      if(w[x]) pq.push(MP(d + w[x], v));
      else pq.push(MP(d + INFF, v));
    }
  }
  return ;
}
int main(void){
  scanf("%d %d", &n, &m);
  scanf("%lld %d %d", &D, &s, &t);
  rep1(i, 1, m+1){
    scanf("%d %d %lld", v1 + i, v2 + i, w + i);
    edge[ v1[i] ].pb(i);
    edge[ v2[i] ].pb(i);
  }
  rep(i, n) go(i);
  if(dis[s][t] < D){
    puts("NO"); return 0;
  }
  else{
    int p = -1;
    LL ans = 0;
    int u = s, v = t;
    rep1(i, 1, m+1) if(!w[i]){
      if(dis[ v1[i] ][u] + dis[ v2[i] ][v] < D
          && dis[ v1[i] ][u] + dis[ v2[i] ][v] <= dis[ v1[i] ][v] + dis[ v2[i] ][u]){
        p = i, ans = D - dis[ v1[i] ][u] - dis[ v2[i] ][v]; break;
      }
      if(dis[ v1[i] ][v] + dis[ v2[i] ][u] < D
          && dis[ v1[i] ][v] + dis[ v2[i] ][u] <= dis[ v1[i] ][u] + dis[ v2[i] ][v]){
        p = i, ans = D - dis[ v1[i] ][v] - dis[ v2[i] ][u]; break;
      }
    }
    if(p == -1) puts("NO");
    else{
      puts("YES");
      rep1(i, 1, m+1){
        if(i != p){
          if(!w[i]) w[i] = INFF;
          printf("%d %d %lld\n", v1[i], v2[i], w[i]);
        }
        else printf("%d %d %lld\n", v1[i], v2[i], ans);
      }
    }
  }
  return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <locale>
using namespace std;
#define MS0(I) memset(I, 0, sizeof(I));
#define MS1(I) memset(I, -1, sizeof(I));
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, s, n) for(int i = (s); i < (n); ++i)
#define per1(i, a, b) for(int i = a; i >= b; --i)
#define DRI(A) int A; scanf("%d", &A);
#define DRII(A, B) int A, B; scanf("%d %d", &A, &B);
#define DRIII(A, B, C) int A, B, C; scanf("%d %d %d", &A, &B, &C);
#define DRL(A) long long A; scanf("%lld", &A);
#define DRLL(A, B) long long A, B; scanf("%lld %lld", &A, &B);
#define DRLLL(A, B, C) long long A, B, C; scanf("%lld %lld %lld", &A, &B, &C);
#define SZ(X) ((int)X.size() )
#define MP make_pair
#define pb push_back
#define F first
#define S second
#define ALL(I) (I).begin(), (I).end()
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;
typedef long double LDB;
typedef pair<int, int> PII;
typedef pair<int, LL> PIL;
typedef pair<LL, int> PLI;
typedef pair<LL, LL> PLL;
const double eps = 1e-7;
const double PI = acos(-1);
const LL INFF = 1e10;
const int INF = 1e9;
const int mod = 1e9+7;
const int MAX = 1e3+7;
int n, m, s, t;
int v1[MAX*10], v2[MAX*10];
LL D, w[MAX*10];
vector<int>edge[MAX];
LL dis[MAX][MAX];
bool ck[MAX];
void go(int st){
  priority_queue<PLI, vector<PLI>, greater<PLI>>pq;
  pq.push(MP(0, st)); MS0(ck);
  while(!pq.empty()){
    LL d; int u; tie(d, u) = pq.top(); pq.pop();
    if(ck[u]) continue; dis[u][st] = dis[st][u] = d; ck[u] = 1;
    for(int x : edge[u]){
      int v = v1[x] + v2[x] - u;
      if(ck[v]) continue;
      if(w[x]) pq.push(MP(d + w[x], v));
      else pq.push(MP(d + INFF, v));
    }
  }
  return ;
}
int main(void){
  scanf("%d %d", &n, &m);
  scanf("%lld %d %d", &D, &s, &t);
  rep1(i, 1, m+1){
    scanf("%d %d %lld", v1 + i, v2 + i, w + i);
    edge[ v1[i] ].pb(i);
    edge[ v2[i] ].pb(i);
  }
  rep(i, n) go(i);
  if(dis[s][t] < D){
    puts("NO"); return 0;
  }
  else{
    int p = -1;
    LL ans = 0;
    int u = s, v = t;
    rep1(i, 1, m+1) if(!w[i]){
      if(dis[ v1[i] ][u] + dis[ v2[i] ][v] < D
          && dis[ v1[i] ][u] + dis[ v2[i] ][v] <= dis[ v1[i] ][v] + dis[ v2[i] ][u]){
        p = i, ans = D - dis[ v1[i] ][u] - dis[ v2[i] ][v]; break;
      }
      if(dis[ v1[i] ][v] + dis[ v2[i] ][u] < D
          && dis[ v1[i] ][v] + dis[ v2[i] ][u] <= dis[ v1[i] ][u] + dis[ v2[i] ][v]){
        p = i, ans = D - dis[ v1[i] ][v] - dis[ v2[i] ][u]; break;
      }
    }
    if(p == -1) puts("NO");
    else{
      puts("YES");
      rep1(i, 1, m+1){
        if(i != p){
          if(!w[i]) w[i] = INFF;
          printf("%d %d %lld\n", v1[i], v2[i], w[i]);
        }
        else printf("%d %d %lld\n", v1[i], v2[i], ans);
      }
    }
  }
  return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <locale>
using namespace std;
#define MS0(I) memset(I, 0, sizeof(I));
#define MS1(I) memset(I, -1, sizeof(I));
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, s, n) for(int i = (s); i < (n); ++i)
#define per1(i, a, b) for(int i = a; i >= b; --i)
#define DRI(A) int A; scanf("%d", &A);
#define DRII(A, B) int A, B; scanf("%d %d", &A, &B);
#define DRIII(A, B, C) int A, B, C; scanf("%d %d %d", &A, &B, &C);
#define DRL(A) long long A; scanf("%lld", &A);
#define DRLL(A, B) long long A, B; scanf("%lld %lld", &A, &B);
#define DRLLL(A, B, C) long long A, B, C; scanf("%lld %lld %lld", &A, &B, &C);
#define SZ(X) ((int)X.size() )
#define MP make_pair
#define pb push_back
#define F first
#define S second
#define ALL(I) (I).begin(), (I).end()
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;
typedef long double LDB;
typedef pair<int, int> PII;
typedef pair<int, LL> PIL;
typedef pair<LL, int> PLI;
typedef pair<LL, LL> PLL;
const double eps = 1e-7;
const double PI = acos(-1);
const LL INFF = 1e10;
const int INF = 1e9;
const int mod = 1e9+7;
const int MAX = 1e3+7;
int n, m, s, t;
int v1[MAX*10], v2[MAX*10];
LL D, w[MAX*10];
vector<int>edge[MAX];
LL dis[MAX][MAX];
bool ck[MAX];
void go(int st){
  priority_queue<PLI, vector<PLI>, greater<PLI>>pq;
  pq.push(MP(0, st)); MS0(ck);
  while(!pq.empty()){
    LL d; int u; tie(d, u) = pq.top(); pq.pop();
    if(ck[u]) continue; dis[u][st] = dis[st][u] = d; ck[u] = 1;
    for(int x : edge[u]){
      int v = v1[x] + v2[x] - u;
      if(ck[v]) continue;
      if(w[x]) pq.push(MP(d + w[x], v));
      else pq.push(MP(d + INFF, v));
    }
  }
  return ;
}
int main(void){
  scanf("%d %d", &n, &m);
  rep(i, n) rep(j, n) dis[i][j] = (LL)1e18;
  scanf("%lld %d %d", &D, &s, &t);
  rep1(i, 1, m+1){
    scanf("%d %d %lld", v1 + i, v2 + i, w + i);
    edge[ v1[i] ].pb(i);
    edge[ v2[i] ].pb(i);
  }
  go(s); go(t);
  if(dis[s][t] < D || dis[s][t] == (LL)1e18){
    puts("NO"); return 0;
  }
  else if(dis[s][t] == D){
    puts("YES");
    rep1(i, 1, m+1){
      if(!w[i]) w[i] = INFF;
      printf("%d %d %lld\n", v1[i], v2[i], w[i]);
    }
  }
  else{
    int p = -1;
    LL ans = 0;
    int u = s, v = t;
    rep1(i, 1, m+1) if(!w[i]){
      if(dis[ v1[i] ][u] + dis[ v2[i] ][v] < D
          && dis[ v1[i] ][u] + dis[ v2[i] ][v] <= dis[ v1[i] ][v] + dis[ v2[i] ][u]){
        p = i, ans = D - dis[ v1[i] ][u] - dis[ v2[i] ][v]; break;
      }
      else if(dis[ v1[i] ][v] + dis[ v2[i] ][u] < D
          && dis[ v1[i] ][v] + dis[ v2[i] ][u] <= dis[ v1[i] ][u] + dis[ v2[i] ][v]){
        p = i, ans = D - dis[ v1[i] ][v] - dis[ v2[i] ][u]; break;
      }
      else{
        w[i] = 1;
        go(s); go(t);
      }
    }
    if(p == -1) puts("NO");
    else{
      puts("YES");
      rep1(i, 1, m+1){
        if(i != p){
          if(!w[i]) w[i] = INFF;
          printf("%d %d %lld\n", v1[i], v2[i], w[i]);
        }
        else printf("%d %d %lld\n", v1[i], v2[i], ans);
      }
    }
  }
  return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <locale>
using namespace std;
#define MS0(I) memset(I, 0, sizeof(I));
#define MS1(I) memset(I, -1, sizeof(I));
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, s, n) for(int i = (s); i < (n); ++i)
#define per1(i, a, b) for(int i = a; i >= b; --i)
#define DRI(A) int A; scanf("%d", &A);
#define DRII(A, B) int A, B; scanf("%d %d", &A, &B);
#define DRIII(A, B, C) int A, B, C; scanf("%d %d %d", &A, &B, &C);
#define DRL(A) long long A; scanf("%lld", &A);
#define DRLL(A, B) long long A, B; scanf("%lld %lld", &A, &B);
#define DRLLL(A, B, C) long long A, B, C; scanf("%lld %lld %lld", &A, &B, &C);
#define SZ(X) ((int)X.size() )
#define MP make_pair
#define pb push_back
#define F first
#define S second
#define ALL(I) (I).begin(), (I).end()
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;
typedef long double LDB;
typedef pair<int, int> PII;
typedef pair<int, LL> PIL;
typedef pair<LL, int> PLI;
typedef pair<LL, LL> PLL;
const double eps = 1e-7;
const double PI = acos(-1);
const LL INFF = 1e10;
const int INF = 1e9;
const int mod = 1e9+7;
const int MAX = 1e3+7;
int n, m, s, t;
int v1[MAX], v2[MAX];
LL D, w[MAX*10];
vector<int>edge[MAX];
LL dis[MAX][MAX];
bool ck[MAX];
void go(int st){
  priority_queue<PLI, vector<PLI>, greater<PLI>>pq;
  pq.push(MP(0, st)); MS0(ck);
  while(!pq.empty()){
    LL d; int u; tie(d, u) = pq.top(); pq.pop();
    if(ck[u]) continue; dis[u][st] = dis[st][u] = d; ck[u] = 1;
    for(int x : edge[u]){
      int v = v1[x] + v2[x] - u;
      if(ck[v]) continue;
      if(w[x]) pq.push(MP(d + w[x], v));
      else pq.push(MP(d + INFF, v));
    }
  }
  return ;
}
int main(void){
  scanf("%d %d", &n, &m);
  scanf("%lld %d %d", &D, &s, &t);
  rep1(i, 1, m+1){
    scanf("%d %d %lld", v1 + i, v2 + i, w + i);
    edge[ v1[i] ].pb(i);
    edge[ v2[i] ].pb(i);
  }
  rep(i, n) go(i);
  if(dis[s][t] < D){
    puts("NO"); return 0;
  }
  else{
    int p = -1;
    LL ans = 0;
    int u = s, v = t;
    rep1(i, 1, m+1) if(!w[i]){
      if(dis[ v1[i] ][u] + dis[ v2[i] ][v] < D
          && dis[ v1[i] ][u] + dis[ v2[i] ][v] <= dis[ v1[i] ][v] + dis[ v2[i] ][u]){
        p = i, ans = D - dis[ v1[i] ][u] - dis[ v2[i] ][v]; break;
      }
      if(dis[ v1[i] ][v] + dis[ v2[i] ][u] < D
          && dis[ v1[i] ][v] + dis[ v2[i] ][u] <= dis[ v1[i] ][u] + dis[ v2[i] ][v]){
        p = i, ans = D - dis[ v1[i] ][v] - dis[ v2[i] ][u]; break;
      }
    }
    if(p == -1) puts("NO");
    else{
      puts("YES");
      rep1(i, 1, m+1){
        if(i != p){
          if(!w[i]) w[i] = INFF;
          printf("%d %d %lld\n", v1[i], v2[i], w[i]);
        }
        else printf("%d %d %lld\n", v1[i], v2[i], ans);
      }
    }
  }
  return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <locale>
using namespace std;
#define MS0(I) memset(I, 0, sizeof(I));
#define MS1(I) memset(I, -1, sizeof(I));
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, s, n) for(int i = (s); i < (n); ++i)
#define per1(i, a, b) for(int i = a; i >= b; --i)
#define DRI(A) int A; scanf("%d", &A);
#define DRII(A, B) int A, B; scanf("%d %d", &A, &B);
#define DRIII(A, B, C) int A, B, C; scanf("%d %d %d", &A, &B, &C);
#define DRL(A) long long A; scanf("%lld", &A);
#define DRLL(A, B) long long A, B; scanf("%lld %lld", &A, &B);
#define DRLLL(A, B, C) long long A, B, C; scanf("%lld %lld %lld", &A, &B, &C);
#define SZ(X) ((int)X.size() )
#define MP make_pair
#define pb push_back
#define F first
#define S second
#define ALL(I) (I).begin(), (I).end()
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;
typedef long double LDB;
typedef pair<int, int> PII;
typedef pair<int, LL> PIL;
typedef pair<LL, int> PLI;
typedef pair<LL, LL> PLL;
const double eps = 1e-7;
const double PI = acos(-1);
const LL INFF = 1e10;
const int INF = 1e9;
const int mod = 1e9+7;
const int MAX = 1e3+7;
int n, m, s, t;
int v1[MAX*10], v2[MAX*10];
LL D, w[MAX*10];
vector<int>edge[MAX];
LL dis[MAX][MAX];
bool ck[MAX];
void go(int st){
  priority_queue<PLI, vector<PLI>, greater<PLI>>pq;
  pq.push(MP(0, st)); MS0(ck);
  while(!pq.empty()){
    LL d; int u; tie(d, u) = pq.top(); pq.pop();
    if(ck[u]) continue; dis[u][st] = dis[st][u] = d; ck[u] = 1;
    for(int x : edge[u]){
      int v = v1[x] + v2[x] - u;
      if(ck[v]) continue;
      if(w[x]) pq.push(MP(d + w[x], v));
      else pq.push(MP(d + INFF, v));
    }
  }
  return ;
}
int main(void){
  scanf("%d %d", &n, &m);
  rep(i, n) rep(j, n) dis[i][j] = (LL)1e18;
  scanf("%lld %d %d", &D, &s, &t);
  rep1(i, 1, m+1){
    scanf("%d %d %lld", v1 + i, v2 + i, w + i);
    edge[ v1[i] ].pb(i);
    edge[ v2[i] ].pb(i);
  }
  go(s); go(t);
  if(dis[s][t] < D || dis[s][t] == (LL)1e18){
    puts("NO"); return 0;
  }
  else{
    int p = -1;
    LL ans = 0;
    int u = s, v = t;
    rep1(i, 1, m+1) if(!w[i]){
      if(dis[ v1[i] ][u] + dis[ v2[i] ][v] < D
          && dis[ v1[i] ][u] + dis[ v2[i] ][v] <= dis[ v1[i] ][v] + dis[ v2[i] ][u]){
        p = i, ans = D - dis[ v1[i] ][u] - dis[ v2[i] ][v]; break;
      }
      else if(dis[ v1[i] ][v] + dis[ v2[i] ][u] < D
          && dis[ v1[i] ][v] + dis[ v2[i] ][u] <= dis[ v1[i] ][u] + dis[ v2[i] ][v]){
        p = i, ans = D - dis[ v1[i] ][v] - dis[ v2[i] ][u]; break;
      }
      else{
        w[i] = 1;
        go(s); go(t);
      }
    }
    if(p == -1) puts("NO");
    else{
      puts("YES");
      rep1(i, 1, m+1){
        if(i != p){
          if(!w[i]) w[i] = INFF;
          printf("%d %d %lld\n", v1[i], v2[i], w[i]);
        }
        else printf("%d %d %lld\n", v1[i], v2[i], ans);
      }
    }
  }
  return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <locale>
using namespace std;
#define MS0(I) memset(I, 0, sizeof(I));
#define MS1(I) memset(I, -1, sizeof(I));
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, s, n) for(int i = (s); i < (n); ++i)
#define per1(i, a, b) for(int i = a; i >= b; --i)
#define DRI(A) int A; scanf("%d", &A);
#define DRII(A, B) int A, B; scanf("%d %d", &A, &B);
#define DRIII(A, B, C) int A, B, C; scanf("%d %d %d", &A, &B, &C);
#define DRL(A) long long A; scanf("%lld", &A);
#define DRLL(A, B) long long A, B; scanf("%lld %lld", &A, &B);
#define DRLLL(A, B, C) long long A, B, C; scanf("%lld %lld %lld", &A, &B, &C);
#define SZ(X) ((int)X.size() )
#define MP make_pair
#define pb push_back
#define F first
#define S second
#define ALL(I) (I).begin(), (I).end()
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;
typedef long double LDB;
typedef pair<int, int> PII;
typedef pair<int, LL> PIL;
typedef pair<LL, int> PLI;
typedef pair<LL, LL> PLL;
const double eps = 1e-7;
const double PI = acos(-1);
const LL INFF = 1e10;
const int INF = 1e9;
const int mod = 1e9+7;
const int MAX = 1e3+7;
int n, m, s, t;
int v1[MAX*10], v2[MAX*10];
LL D, w[MAX*10];
vector<int>edge[MAX];
LL dis[MAX][MAX];
bool ck[MAX];
void go(int st){
  priority_queue<PLI, vector<PLI>, greater<PLI>>pq;
  pq.push(MP(0, st)); MS0(ck);
  while(!pq.empty()){
    LL d; int u; tie(d, u) = pq.top(); pq.pop();
    if(ck[u]) continue; dis[u][st] = dis[st][u] = d; ck[u] = 1;
    for(int x : edge[u]){
      int v = v1[x] + v2[x] - u;
      if(ck[v]) continue;
      if(w[x]) pq.push(MP(d + w[x], v));
      else pq.push(MP(d + INFF, v));
    }
  }
  return ;
}
int main(void){
  scanf("%d %d", &n, &m);
  rep(i, n) rep(j, n) dis[i][j] = (LL)1e18;
  scanf("%lld %d %d", &D, &s, &t);
  rep1(i, 1, m+1){
    scanf("%d %d %lld", v1 + i, v2 + i, w + i);
    edge[ v1[i] ].pb(i);
    edge[ v2[i] ].pb(i);
  }
  go(s); go(t);
  if(dis[s][t] < D || dis[s][t] == (LL)1e18){
    puts("NO"); return 0;
  }
  else if(dis[s][t] == D){
    puts("YES");
    rep1(i, 1, m+1){
      if(!w[i]) w[i] = INFF;
      printf("%d %d %lld\n", v1[i], v2[i], w[i]);
    }
  }
  else{
    vector<int>al;
    rep1(i, 1, m+1) if(!w[i]) al.pb(i);
    int ll = 0, rr = SZ(al) - 1;
    while(ll <= rr){
      int mid = (ll + rr) >> 1;
      rep(i, mid) w[ al[i] ] = 1;
      rep1(i, mid, SZ(al)) w[ al[i] ] = 0;
      go(s); go(t);
      if(dis[s][t] < D) rr = mid - 1;
      else if(dis[s][t] == D){
        puts("YES");
        rep1(i, 1, m+1){
          if(!w[i]) w[i] = INFF;
          printf("%d %d %lld\n", v1[i], v2[i], w[i]);
        }
        return 0;
      }
      else{
        int p = -1, ii = al[mid]; LL ans = 0;
        int u = s, v = t;
        if(dis[ v1[ii] ][u] + dis[ v2[ii] ][v] < D
          && dis[ v1[ii] ][u] + dis[ v2[ii] ][v] <= dis[ v1[ii] ][v] + dis[ v2[ii] ][u]){
            p = ii, ans = D - dis[ v1[ii] ][u] - dis[ v2[ii] ][v];
        }
        else if(dis[ v1[ii] ][v] + dis[ v2[ii] ][u] < D
           && dis[ v1[ii] ][v] + dis[ v2[ii] ][u] <= dis[ v1[ii] ][u] + dis[ v2[ii] ][v]){
            p = ii, ans = D - dis[ v1[ii] ][v] - dis[ v2[ii] ][u];
        }
        if(p != -1){
          puts("YES");
          rep1(i, 1, m+1){
            if(i != p){
              if(!w[i]) w[i] = INFF;
              printf("%d %d %lld\n", v1[i], v2[i], w[i]);
            }
            else printf("%d %d %lld\n", v1[i], v2[i], ans);
          }
          return 0;
        }
        else ll = mid + 1;
      }
    }
    puts("NO");
  }
  return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <locale>
using namespace std;
#define MS0(I) memset(I, 0, sizeof(I));
#define MS1(I) memset(I, -1, sizeof(I));
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, s, n) for(int i = (s); i < (n); ++i)
#define per1(i, a, b) for(int i = a; i >= b; --i)
#define DRI(A) int A; scanf("%d", &A);
#define DRII(A, B) int A, B; scanf("%d %d", &A, &B);
#define DRIII(A, B, C) int A, B, C; scanf("%d %d %d", &A, &B, &C);
#define DRL(A) long long A; scanf("%lld", &A);
#define DRLL(A, B) long long A, B; scanf("%lld %lld", &A, &B);
#define DRLLL(A, B, C) long long A, B, C; scanf("%lld %lld %lld", &A, &B, &C);
#define SZ(X) ((int)X.size() )
#define MP make_pair
#define pb push_back
#define F first
#define S second
#define ALL(I) (I).begin(), (I).end()
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;
typedef long double LDB;
typedef pair<int, int> PII;
typedef pair<int, LL> PIL;
typedef pair<LL, int> PLI;
typedef pair<LL, LL> PLL;
const double eps = 1e-7;
const double PI = acos(-1);
const LL INFF = 1e10;
const int INF = 1e9;
const int mod = 1e9+7;
const int MAX = 1e3+7;
int n, m, s, t;
int v1[MAX*10], v2[MAX*10];
LL D, w[MAX*10];
vector<int>edge[MAX];
LL dis[MAX][MAX];
bool ck[MAX];
void go(int st){
  priority_queue<PLI, vector<PLI>, greater<PLI>>pq;
  pq.push(MP(0, st)); MS0(ck);
  while(!pq.empty()){
    LL d; int u; tie(d, u) = pq.top(); pq.pop();
    if(ck[u]) continue; dis[u][st] = dis[st][u] = d; ck[u] = 1;
    for(int x : edge[u]){
      int v = v1[x] + v2[x] - u;
      if(ck[v]) continue;
      if(w[x]) pq.push(MP(d + w[x], v));
      else pq.push(MP(d + INFF, v));
    }
  }
  return ;
}
int main(void){
  scanf("%d %d", &n, &m);
  rep(i, n) rep(j, n) dis[i][j] = (LL)1e18;
  scanf("%lld %d %d", &D, &s, &t);
  rep1(i, 1, m+1){
    scanf("%d %d %lld", v1 + i, v2 + i, w + i);
    edge[ v1[i] ].pb(i);
    edge[ v2[i] ].pb(i);
  }
  go(s); go(t);
  if(dis[s][t] < D || dis[s][t] == (LL)1e18){
    puts("NO"); return 0;
  }
  else if(dis[s][t] == D){
    puts("YES");
    rep1(i, 1, m+1){
      if(!w[i]) w[i] = INFF;
      printf("%d %d %lld\n", v1[i], v2[i], w[i]);
    }
  }
  else{
    vector<int>al;
    rep1(i, 1, m+1) if(!w[i]) al.pb(i);
    int ll = 0, rr = SZ(al) - 1;
    while(ll <= rr){
      int mid = (ll + rr) >> 1;
      rep(i, mid) w[ al[i] ] = 1;
      rep1(i, mid, SZ(al)) w[ al[i] ] = 0;
      go(s); go(t);
      if(dis[s][t] < D) rr = mid - 1;
      else if(dis[s][t] == D){
        puts("YES");
        rep1(i, 1, m+1){
          if(!w[i]) w[i] = INFF;
          printf("%d %d %lld\n", v1[i], v2[i], w[i]);
        }
        return 0;
      }
      else{
        int p = -1, ii = al[mid]; LL ans = 0;
        int u = s, v = t;
        if(dis[ v1[ii] ][u] + dis[ v2[ii] ][v] < D
          && dis[ v1[ii] ][u] + dis[ v2[ii] ][v] <= dis[ v1[ii] ][v] + dis[ v2[ii] ][u]){
            p = ii, ans = D - dis[ v1[ii] ][u] - dis[ v2[ii] ][v];
        }
        else if(dis[ v1[ii] ][v] + dis[ v2[ii] ][u] < D
           && dis[ v1[ii] ][v] + dis[ v2[ii] ][u] <= dis[ v1[ii] ][u] + dis[ v2[ii] ][v]){
            p = ii, ans = D - dis[ v1[ii] ][v] - dis[ v2[ii] ][u];
        }
        if(p != -1){
          puts("YES");
          rep1(i, 1, m+1){
            if(i != p){
              if(!w[i]) w[i] = INFF;
              printf("%d %d %lld\n", v1[i], v2[i], w[i]);
            }
            else printf("%d %d %lld\n", v1[i], v2[i], ans);
          }
          return 0;
        }
        else ll = mid + 1;
      }
      puts("NO");
    }
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define all(x) x.begin(), x.end()
#define endl '\n'
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;

/*
 * 3yza path been s and t ykon feh edges fadya
 * hashof el awl lw el shortest path 3moman mafehosh edges fdya w el value bta3to < L then no valid answer (assign empty edges b INF)
 * lw el shortest path == L ha assign el empty edges b INF w 5alas kda
 * now 3shan ageeb my own shortest path ha assign kol el empty edges b one w ageeb shortest path
 * lw tl3 > L then no valid answer
 * lw == L then zy mana
 * lw as3'ar mn L hazawd one of the edges ely kant empty w fel shortest path l3'ayt maywsal L
 * w ba2y el edges ely bara el shortest path w kano empty ha5alehom b INF
 * 1. build graph 3ady gdan
 * 2. arr for values of each edge 3shan ha3'ayaro kaza mara
 * 3. first assign each empty edge b INF (7aga msh hat overflow)
 * 4. run dijkstra lw el result < L return false, lw == L return answer
 * 5. ha assign all empty edges b 1 w a run dijkstra keeping track of the parent of each node 3shan ageeb el empty edges
 * 6. lw > L return false, lw == L return answer
 * 7. lw as3'ar ha5aly all empty edges bara el shortest path b INF w azawd wa7d mn el shortest path L - current
 */

const ll INF = 1e14;
const int N = 1005;
int n, m, s, t;
ll L, g[N][N];
bool emp[N][N];
vector<pair<int, int>>edg;
ll dij(){
	vector<ll>d(N, 1e18);
	vector<bool>vis(N, 0);
	vector<int>par(N, -1);
	priority_queue<pair<ll, int>>q;
	q.emplace(0, s);
	while(q.size()){
		ll cst = -q.top().first;
		int nd = q.top().second;
		q.pop();
		if(vis[nd])continue;
		vis[nd] = 1;
		for(int i = 0; i < n; i++){
			if(g[nd][i] == -1 || vis[i])continue;
			if(cst + g[nd][i] < d[i]){
				d[i] = cst + g[nd][i];
				par[i] = nd;
				q.emplace(-d[i], i);
			}
		}
	}
	int cur = t;
	while(par[cur] != -1){
		if(emp[cur][par[cur]])
			edg.emplace_back(cur, par[cur]);
		cur = par[cur];
	}
	return d[t];
}
void invalid(){
	cout << "NO";
	exit(0);
}
void valid(){
	cout << "YES" << endl;
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			if(g[i][j] != -1)
				cout << i << " " << j << " " << g[i][j] << endl;
	exit(0);
}

int main(){
	IO;

	memset(g, -1, sizeof g);
	cin >> n >> m >> L >> s >> t;

	vector<pair<int, int>>ers;
	for(int i = 0; i < m; i++){
		int u, v, c;
		cin >> u >> v >> c;
		g[u][v] = g[v][u] = c;
		if(c == 0)
			emp[u][v] = emp[v][u] = 1, ers.emplace_back(u, v);
	}
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			if(emp[i][j])
				g[i][j] = g[j][i] = INF;

	ll cur = dij();
	if(cur < L)
		invalid();
	if(cur == L)
		valid();

	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			if(emp[i][j])
				g[i][j] = g[j][i] = 1;

	cur = dij();
	if(cur > L)
		invalid();
	if(cur == L)
		valid();

	for(auto e: ers){
		int u = e.first, v = e.second;
		g[u][v] = g[v][u] = INF;
		edg.clear();
		ll tmp = dij();
		if(tmp == L)
			valid();
		if(tmp < L)continue;
		g[u][v] = g[v][u] = 1;
		tmp = dij();
		for(auto x: ers)
			g[x.first][x.second] = g[x.second][x.first] = INF;
		for(auto x: edg)
			g[x.first][x.second] = g[x.second][x.first] = 1;
		g[u][v] = g[v][u] = L - tmp + 1;
		valid();
	}
}


#include <bits/stdc++.h>

using namespace std;

#define all(x) x.begin(), x.end()
#define endl '\n'
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;

/*
 * 3yza path been s and t ykon feh edges fadya
 * hashof el awl lw el shortest path 3moman mafehosh edges fdya w el value bta3to < L then no valid answer (assign empty edges b INF)
 * lw el shortest path == L ha assign el empty edges b INF w 5alas kda
 * now 3shan ageeb my own shortest path ha assign kol el empty edges b one w ageeb shortest path
 * lw tl3 > L then no valid answer
 * lw == L then zy mana
 * lw as3'ar mn L hazawd one of the edges ely kant empty w fel shortest path l3'ayt maywsal L
 * w ba2y el edges ely bara el shortest path w kano empty ha5alehom b INF
 * 1. build graph 3ady gdan
 * 2. arr for values of each edge 3shan ha3'ayaro kaza mara
 * 3. first assign each empty edge b INF (7aga msh hat overflow)
 * 4. run dijkstra lw el result < L return false, lw == L return answer
 * 5. ha assign all empty edges b 1 w a run dijkstra keeping track of the parent of each node 3shan ageeb el empty edges
 * 6. lw > L return false, lw == L return answer
 * 7. lw as3'ar ha5aly all empty edges bara el shortest path b INF w azawd wa7d mn el shortest path L - current
 */

const ll INF = 1e14;
const int N = 1005;
int n, m, s, t;
ll L, g[N][N];
bool emp[N][N];
vector<pair<int, int>>edg;
ll dij(){
	vector<ll>d(N, 1e18);
	vector<bool>vis(N, 0);
	vector<int>par(N, -1);
	priority_queue<pair<ll, int>>q;
	q.emplace(0, s);
	while(q.size()){
		ll cst = -q.top().first;
		int nd = q.top().second;
		q.pop();
		if(vis[nd])continue;
		vis[nd] = 1;
		for(int i = 0; i < n; i++){
			if(g[nd][i] == -1 || vis[i])continue;
			if(cst + g[nd][i] < d[i]){
				d[i] = cst + g[nd][i];
				par[i] = nd;
				q.emplace(-d[i], i);
			}
		}
	}
	int cur = t;
	while(par[cur] != -1){
		if(emp[cur][par[cur]])
			edg.emplace_back(cur, par[cur]);
		cur = par[cur];
	}
	return d[t];
}
void invalid(){
	cout << "NO";
	exit(0);
}
void valid(){
	cout << "YES" << endl;
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			if(g[i][j] != -1)
				cout << i << " " << j << " " << g[i][j] << endl;
	exit(0);
}

int main(){
	IO;

	memset(g, -1, sizeof g);
	cin >> n >> m >> L >> s >> t;

	vector<pair<int, int>>ers;
	for(int i = 0; i < m; i++){
		int u, v, c;
		cin >> u >> v >> c;
		g[u][v] = g[v][u] = c;
		if(c == 0)
			emp[u][v] = emp[v][u] = 1, ers.emplace_back(u, v);
	}
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			if(emp[i][j])
				g[i][j] = g[j][i] = INF;

	ll cur = dij();
	if(cur < L)
		invalid();
	if(cur == L)
		valid();

	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			if(emp[i][j])
				g[i][j] = g[j][i] = 1;

	cur = dij();
	if(cur > L)
		invalid();
	if(cur == L)
		valid();

	for(auto e: ers){
		int u = e.first, v = e.second;
		g[u][v] = g[v][u] = INF;
		ll tmp = dij();
		if(tmp == L)
			valid();
		if(tmp < L)continue;
		for(auto x: ers)
			g[x.first][x.second] = g[x.second][x.first] = INF;
		for(auto x: edg)
			g[x.first][x.second] = g[x.second][x.first] = 1;
		tmp = dij();
		g[u][v] = g[v][u] = L - tmp + 1;
		valid();
	}
}


#include <bits/stdc++.h>

using namespace std;

#define all(x) x.begin(), x.end()
#define endl '\n'
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;

/*
 * 3yza path been s and t ykon feh edges fadya
 * hashof el awl lw el shortest path 3moman mafehosh edges fdya w el value bta3to < L then no valid answer (assign empty edges b INF)
 * lw el shortest path == L ha assign el empty edges b INF w 5alas kda
 * now 3shan ageeb my own shortest path ha assign kol el empty edges b one w ageeb shortest path
 * lw tl3 > L then no valid answer
 * lw == L then zy mana
 * lw as3'ar mn L hazawd one of the edges ely kant empty w fel shortest path l3'ayt maywsal L
 * w ba2y el edges ely bara el shortest path w kano empty ha5alehom b INF
 * 1. build graph 3ady gdan
 * 2. arr for values of each edge 3shan ha3'ayaro kaza mara
 * 3. first assign each empty edge b INF (7aga msh hat overflow)
 * 4. run dijkstra lw el result < L return false, lw == L return answer
 * 5. ha assign all empty edges b 1 w a run dijkstra keeping track of the parent of each node 3shan ageeb el empty edges
 * 6. lw > L return false, lw == L return answer
 * 7. lw as3'ar ha5aly all empty edges bara el shortest path b INF w azawd wa7d mn el shortest path L - current
 */

const ll INF = 1e14;
const int N = 1005;
int n, m;
ll L, g[N][N];
bool emp[N][N];
vector<pair<int, int>>edg;
pair<vector<ll>, vector<int>> dij(int s){
	vector<ll>d(N, 1e18);
	vector<bool>vis(N, 0);
	vector<int>par(N, -1);
	d[s] = 0;
	priority_queue<pair<ll, int>>q;
	q.emplace(0, s);
	while(q.size()){
		ll cst = -q.top().first;
		int nd = q.top().second;
		q.pop();
		if(vis[nd])continue;
		vis[nd] = 1;
		for(int i = 0; i < n; i++){
			if(g[nd][i] == -1 || vis[i])continue;
			if(cst + g[nd][i] < d[i]){
				d[i] = cst + g[nd][i];
				par[i] = nd;
				q.emplace(-d[i], i);
			}
		}
	}

	return {d, par};
}

void invalid(){
	cout << "NO";
	exit(0);
}
void valid(){
	cout << "YES" << endl;
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			if(g[i][j] != -1)
				cout << i << " " << j << " " << g[i][j] << endl;
	exit(0);
}

int main(){
	IO;

	int s, t;
	memset(g, -1, sizeof g);
	cin >> n >> m >> L >> s >> t;

	vector<pair<int, int>>ers;
	for(int i = 0; i < m; i++){
		int u, v, c;
		cin >> u >> v >> c;
		g[u][v] = g[v][u] = c;
		if(c == 0)
			emp[u][v] = emp[v][u] = 1, ers.emplace_back(u, v);
	}
	for(auto x: ers){
		int i = x.first, j = x.second;
		g[i][j] = g[j][i] = INF;
	}

	ll cur = dij(s).first[t];
	if(cur < L)
		invalid();
	if(cur == L)
		valid();

	for(auto x: ers){
		int i = x.first, j = x.second;
		g[i][j] = g[j][i] = 1;
	}

	for(int k = 0; k < ers.size(); k++){
		int u = ers[k].first, v = ers[k].second;
		g[u][v] = g[v][u] = INF;
		pair<vector<ll>, vector<int>> tmp = dij(s);
		pair<vector<ll>, vector<int>> tmp2 = dij(t);
		ll d1 = tmp.first[u], d2 = tmp2.first[v];
		if(d1 + d2 < L){
			for(auto e: ers){
				int i = e.first, j = e.second;
				g[i][j] = g[j][i] = INF;
			}
			int cur = u;
			while(tmp.second[cur] != -1){
				if(emp[cur][tmp.second[cur]])
					g[cur][tmp.second[cur]] = g[tmp.second[cur]][cur] = 1;
				cur = tmp.second[cur];
			}
			cur = v;
			while(tmp2.second[cur] != -1){
				if(emp[cur][tmp2.second[cur]])
					g[cur][tmp2.second[cur]] = g[tmp2.second[cur]][cur] = 1;
				cur = tmp2.second[cur];
			}
			g[u][v] = g[v][u] = L - d1 - d2;
			tmp = dij(s);
			if(tmp.first[t] == L)
				valid();
		}
		d1 = tmp.first[v], d2 = tmp2.first[u];
		if(d1 + d2 < L){
			for(auto e: ers){
				int i = e.first, j = e.second;
				g[i][j] = g[j][i] = INF;
			}
			int cur = u;
			while(tmp.second[cur] != -1){
				if(emp[cur][tmp.second[cur]])
					g[cur][tmp.second[cur]] = g[tmp.second[cur]][cur] = 1;
				cur = tmp.second[cur];
			}
			cur = v;
			while(tmp2.second[cur] != -1){
				if(emp[cur][tmp2.second[cur]])
					g[cur][tmp2.second[cur]] = g[tmp2.second[cur]][cur] = 1;
				cur = tmp2.second[cur];
			}
			g[u][v] = g[v][u] = L - d1 - d2;
			tmp = dij(s);
			if(tmp.first[t] == L)
				valid();
		}
	}
	invalid();
}


#include <bits/stdc++.h>

using namespace std;

#define all(x) x.begin(), x.end()
#define endl '\n'
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;

/*
 * 3yza path been s and t ykon feh edges fadya
 * hashof el awl lw el shortest path 3moman mafehosh edges fdya w el value bta3to < L then no valid answer (assign empty edges b INF)
 * lw el shortest path == L ha assign el empty edges b INF w 5alas kda
 * now 3shan ageeb my own shortest path ha assign kol el empty edges b one w ageeb shortest path
 * lw tl3 > L then no valid answer
 * lw == L then zy mana
 * lw as3'ar mn L hazawd one of the edges ely kant empty w fel shortest path l3'ayt maywsal L
 * w ba2y el edges ely bara el shortest path w kano empty ha5alehom b INF
 * 1. build graph 3ady gdan
 * 2. arr for values of each edge 3shan ha3'ayaro kaza mara
 * 3. first assign each empty edge b INF (7aga msh hat overflow)
 * 4. run dijkstra lw el result < L return false, lw == L return answer
 * 5. ha assign all empty edges b 1 w a run dijkstra keeping track of the parent of each node 3shan ageeb el empty edges
 * 6. lw > L return false, lw == L return answer
 * 7. lw as3'ar ha5aly all empty edges bara el shortest path b INF w azawd wa7d mn el shortest path L - current
 */

const ll INF = 1e14;
const int N = 1005;
int n, m;
ll L, g[N][N];
bool emp[N][N];
vector<pair<int, int>>edg;
ll dij(int s, int t, int a){
	vector<ll>d(N, 1e18);
	vector<bool>vis(N, 0);
	vector<int>par(N, -1);
	d[s] = 0;
	priority_queue<pair<ll, int>>q;
	q.emplace(0, s);
	while(q.size()){
		ll cst = -q.top().first;
		int nd = q.top().second;
		q.pop();
		if(vis[nd])continue;
		vis[nd] = 1;
		for(int i = 0; i < n; i++){
			if(g[nd][i] == -1 || vis[i] || (nd == s && i == a))continue;
			if(cst + g[nd][i] < d[i]){
				d[i] = cst + g[nd][i];
				par[i] = nd;
				q.emplace(-d[i], i);
			}
		}
	}
	int cur = t;
	while(par[cur] != -1){
		if(emp[cur][par[cur]])
			edg.emplace_back(cur, par[cur]);
		cur = par[cur];
	}
	return d[t];
}
void invalid(){
	cout << "NO";
	exit(0);
}
void valid(){
	cout << "YES" << endl;
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			if(g[i][j] != -1)
				cout << i << " " << j << " " << g[i][j] << endl;
	exit(0);
}

int main(){
	IO;

	int s, t;
	memset(g, -1, sizeof g);
	cin >> n >> m >> L >> s >> t;

	vector<pair<int, int>>ers;
	for(int i = 0; i < m; i++){
		int u, v, c;
		cin >> u >> v >> c;
		g[u][v] = g[v][u] = c;
		if(c == 0)
			emp[u][v] = emp[v][u] = 1, ers.emplace_back(u, v);
	}
	for(auto x: ers){
		int i = x.first, j = x.second;
		g[i][j] = g[j][i] = INF;
	}

	ll cur = dij(s, t, -1);
	if(cur < L)
		invalid();
	if(cur == L)
		valid();

	for(auto x: ers){
		int i = x.first, j = x.second;
		g[i][j] = g[j][i] = 1;
	}

	for(int k = 0; k < ers.size(); k++){
		int u = ers[k].first, v = ers[k].second;
		edg.clear();
		ll tmp = dij(u, s, v);
		ll tmp2 = dij(v, t, u);
		if(tmp + tmp2 < L){
			for(auto x: ers){
				int i = x.first, j = x.second;
				g[i][j] = g[j][i] = INF;
			}
			for(auto e: edg)
				g[e.first][e.second] = g[e.second][e.first] = 1;
			g[u][v] = g[v][u] = L - tmp - tmp2;
			if(dij(s, t, -1) == L)
				valid();
		}
		edg.clear();
		tmp = dij(u, t, v);
		tmp2 = dij(v, s, u);
		if(tmp + tmp2 < L){
			for(auto x: ers){
				int i = x.first, j = x.second;
				g[i][j] = g[j][i] = INF;
			}
			for(auto e: edg)
				g[e.first][e.second] = g[e.second][e.first] = 1;
			g[u][v] = g[v][u] = L - tmp - tmp2;
			if(dij(s, t, -1) == L)
				valid();
		}
	}
	invalid();
}


#include <bits/stdc++.h>

using namespace std;

#define all(x) x.begin(), x.end()
#define endl '\n'
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;

/*
 * 3yza path been s and t ykon feh edges fadya
 * hashof el awl lw el shortest path 3moman mafehosh edges fdya w el value bta3to < L then no valid answer (assign empty edges b INF)
 * lw el shortest path == L ha assign el empty edges b INF w 5alas kda
 * now 3shan ageeb my own shortest path ha assign kol el empty edges b one w ageeb shortest path
 * lw tl3 > L then no valid answer
 * lw == L then zy mana
 * lw as3'ar mn L hazawd one of the edges ely kant empty w fel shortest path l3'ayt maywsal L
 * w ba2y el edges ely bara el shortest path w kano empty ha5alehom b INF
 * 1. build graph 3ady gdan
 * 2. arr for values of each edge 3shan ha3'ayaro kaza mara
 * 3. first assign each empty edge b INF (7aga msh hat overflow)
 * 4. run dijkstra lw el result < L return false, lw == L return answer
 * 5. ha assign all empty edges b 1 w a run dijkstra keeping track of the parent of each node 3shan ageeb el empty edges
 * 6. lw > L return false, lw == L return answer
 * 7. lw as3'ar ha5aly all empty edges bara el shortest path b INF w azawd wa7d mn el shortest path L - current
 */
const ll INF = 1e14;
const int N = 1005;
int n, m, L, s, t;
ll g[N][N];
bool emp[N][N];
vector<pair<int, int>>edg;

void invalid(){
	cout << "NO";
	exit(0);
}
void valid(){
	cout << "YES" << endl;
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			if(g[i][j] != -1)
				cout << i << " " << j << " " << g[i][j] << endl;
	exit(0);
}

ll dij(){
	vector<bool>vis(N);
	vector<ll>dis(N, 1e18);
	vector<int>par(N, -1);
	priority_queue<pair<ll, int>> q;
	q.emplace(0, s);
	while(q.size()){
		ll cst = -q.top().first;
		int nd = q.top().second;
		q.pop();
		if(vis[nd])continue;
		vis[nd] = 1;
		for(int i = 0; i < n; i++){
			if(g[nd][i] == -1 || vis[i])continue;
			if(cst + g[nd][i] < dis[i]){
				dis[i] = cst + g[nd][i];
				par[i] = nd;
				q.emplace(-dis[i], i);
			}
		}
	}
	if(dis[t])
		invalid();
	edg.clear();
	int cur = t;
	while(par[cur] != -1){
		if(emp[cur][par[cur]])
			edg.emplace_back(cur, par[cur]);
		cur = par[cur];
	}
	return dis[t];
}

int main(){
	IO;

	memset(g, -1, sizeof g);

	cin >> n >> m >> L >> s >> t;
	for(int i = 0; i < m; i++){
		int u, v, c;
		cin >> u >> v >> c;
		if(c == 0)emp[u][v] = emp[v][u] = 1;
		g[u][v] = g[v][u] = c;
	}
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			if(emp[i][j])
				g[i][j] = g[j][i] = INF;

	ll cur = dij();
	if(cur < L)
		invalid();
	if(cur == L)
		valid();
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			if(emp[i][j])
				g[i][j] = g[j][i] = 1;
	cur = dij();

	if(cur > L)
		invalid();
	if(cur == L)
		valid();
	cur = L - cur;
	if(edg.empty())
		invalid();
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			if(emp[i][j])
				g[i][j] = g[j][i] = INF;

	for(auto e: edg)
		g[e.first][e.second] = g[e.second][e.first] = 1;
	g[edg.back().first][edg.back().second] = g[edg.back().second][edg.back().first] = cur + 1;
	valid();
}


#include <bits/stdc++.h>

using namespace std;

#define all(x) x.begin(), x.end()
#define endl '\n'
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;

/*
 * 3yza path been s and t ykon feh edges fadya
 * hashof el awl lw el shortest path 3moman mafehosh edges fdya w el value bta3to < L then no valid answer (assign empty edges b INF)
 * lw el shortest path == L ha assign el empty edges b INF w 5alas kda
 * now 3shan ageeb my own shortest path ha assign kol el empty edges b one w ageeb shortest path
 * lw tl3 > L then no valid answer
 * lw == L then zy mana
 * lw as3'ar mn L hazawd one of the edges ely kant empty w fel shortest path l3'ayt maywsal L
 * w ba2y el edges ely bara el shortest path w kano empty ha5alehom b INF
 * 1. build graph 3ady gdan
 * 2. arr for values of each edge 3shan ha3'ayaro kaza mara
 * 3. first assign each empty edge b INF (7aga msh hat overflow)
 * 4. run dijkstra lw el result < L return false, lw == L return answer
 * 5. ha assign all empty edges b 1 w a run dijkstra keeping track of the parent of each node 3shan ageeb el empty edges
 * 6. lw > L return false, lw == L return answer
 * 7. lw as3'ar ha5aly all empty edges bara el shortest path b INF w azawd wa7d mn el shortest path L - current
 */

const int INF = 1e9 + 10;
const int N = 1005;
int n, m;
int L, g[N][N];
bool emp[N][N];
vector<vector<int>>grph(N);
vector<pair<int, int>>edg;
pair<vector<int>, vector<int>> dij(int s){
	vector<int>d(N, 2e9);
	vector<bool>vis(N, 0);
	vector<int>par(N, -1);
	d[s] = 0;
	priority_queue<pair<int, int>>q;
	q.emplace(0, s);
	while(q.size()){
		int cst = -q.top().first;
		int nd = q.top().second;
		q.pop();
		if(vis[nd])continue;
		vis[nd] = 1;
		for(auto ch: grph[nd]){
			if(vis[ch])continue;
			if(cst + g[nd][ch] < d[ch]){
				d[ch] = cst + g[nd][ch];
				par[ch] = nd;
				q.emplace(-d[ch], ch);
			}
		}
	}

	return {d, par};
}

void invalid(){
	cout << "NO";
	exit(0);
}
void valid(){
	cout << "YES" << endl;
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			if(g[i][j] != -1)
				cout << i << " " << j << " " << g[i][j] << endl;
	exit(0);
}

int main(){
	IO;

	int s, t;
	memset(g, -1, sizeof g);
	cin >> n >> m >> L >> s >> t;

	vector<pair<int, int>>ers;
	for(int i = 0; i < m; i++){
		int u, v, c;
		cin >> u >> v >> c;
		g[u][v] = g[v][u] = c;
		grph[u].emplace_back(v);
		grph[v].emplace_back(u);
		if(c == 0)
			emp[u][v] = emp[v][u] = 1, ers.emplace_back(u, v);
	}
	for(auto x: ers){
		int i = x.first, j = x.second;
		g[i][j] = g[j][i] = INF;
	}

	int cur = dij(s).first[t];
	if(cur < L)
		invalid();
	if(cur == L)
		valid();

	for(auto x: ers){
		int i = x.first, j = x.second;
		g[i][j] = g[j][i] = 1;
	}

	for(int k = 0; k < ers.size(); k++){
		int u = ers[k].first, v = ers[k].second;
		g[u][v] = g[v][u] = INF;
		pair<vector<int>, vector<int>> tmp = dij(s);
		pair<vector<int>, vector<int>> tmp2 = dij(t);
		int d1 = tmp.first[u], d2 = tmp2.first[v];
		if(d1 *1ll + d2 < L *1ll){
			for(auto e: ers){
				int i = e.first, j = e.second;
				g[i][j] = g[j][i] = INF;
			}
			int cur = u;
			while(tmp.second[cur] != -1){
				if(emp[cur][tmp.second[cur]])
					g[cur][tmp.second[cur]] = g[tmp.second[cur]][cur] = 1;
				cur = tmp.second[cur];
			}
			cur = v;
			while(tmp2.second[cur] != -1){
				if(emp[cur][tmp2.second[cur]])
					g[cur][tmp2.second[cur]] = g[tmp2.second[cur]][cur] = 1;
				cur = tmp2.second[cur];
			}
			g[u][v] = g[v][u] = L - d1 - d2;
			tmp = dij(s);
			if(tmp.first[t] == L)
				valid();
		}
		d1 = tmp.first[v], d2 = tmp2.first[u];
		if(d1 *1ll + d2 < L *1ll){
			for(auto e: ers){
				int i = e.first, j = e.second;
				g[i][j] = g[j][i] = INF;
			}
			int cur = u;
			while(tmp.second[cur] != -1){
				if(emp[cur][tmp.second[cur]])
					g[cur][tmp.second[cur]] = g[tmp.second[cur]][cur] = 1;
				cur = tmp.second[cur];
			}
			cur = v;
			while(tmp2.second[cur] != -1){
				if(emp[cur][tmp2.second[cur]])
					g[cur][tmp2.second[cur]] = g[tmp2.second[cur]][cur] = 1;
				cur = tmp2.second[cur];
			}
			g[u][v] = g[v][u] = L - d1 - d2;
			tmp = dij(s);
			if(tmp.first[t] == L)
				valid();
		}
	}
	invalid();
}


#include <bits/stdc++.h>

using namespace std;

#define all(x) x.begin(), x.end()
#define endl '\n'
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;

/*
 * 3yza path been s and t ykon feh edges fadya
 * hashof el awl lw el shortest path 3moman mafehosh edges fdya w el value bta3to < L then no valid answer (assign empty edges b INF)
 * lw el shortest path == L ha assign el empty edges b INF w 5alas kda
 * now 3shan ageeb my own shortest path ha assign kol el empty edges b one w ageeb shortest path
 * lw tl3 > L then no valid answer
 * lw == L then zy mana
 * lw as3'ar mn L hazawd one of the edges ely kant empty w fel shortest path l3'ayt maywsal L
 * w ba2y el edges ely bara el shortest path w kano empty ha5alehom b INF
 * 1. build graph 3ady gdan
 * 2. arr for values of each edge 3shan ha3'ayaro kaza mara
 * 3. first assign each empty edge b INF (7aga msh hat overflow)
 * 4. run dijkstra lw el result < L return false, lw == L return answer
 * 5. ha assign all empty edges b 1 w a run dijkstra keeping track of the parent of each node 3shan ageeb el empty edges
 * 6. lw > L return false, lw == L return answer
 * 7. lw as3'ar ha5aly all empty edges bara el shortest path b INF w azawd wa7d mn el shortest path L - current
 */

const int INF = 1e9 + 10;
const int N = 1005;
int n, m, s, t;
int L, g[N][N];
bool emp[N][N];
vector<vector<int>>grph(N);
vector<pair<int, int>>edg;
int dij(){
	vector<int>d(N, 2e9);
	vector<bool>vis(N, 0);
	vector<int>par(N, -1);
	priority_queue<pair<int, int>>q;
	q.emplace(0, s);
	while(q.size()){
		int cst = -q.top().first;
		int nd = q.top().second;
		q.pop();
		if(vis[nd])continue;
		vis[nd] = 1;
		for(auto ch: grph[nd]){
			if(vis[ch])continue;
			if(cst + g[nd][ch] < d[ch] && cst + g[nd][ch] <= L){
				d[ch] = cst + g[nd][ch];
				par[ch] = nd;
				q.emplace(-d[ch], ch);
			}
		}
	}
	int cur = t;
	while(par[cur] != -1){
		if(emp[cur][par[cur]])
			edg.emplace_back(cur, par[cur]);
		cur = par[cur];
	}
	return d[t];
}
void invalid(){
	cout << "NO";
	exit(0);
}
void valid(){
	cout << "YES" << endl;
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			if(g[i][j] != -1)
				cout << i << " " << j << " " << g[i][j] << endl;
	exit(0);
}

int main(){
	IO;

	memset(g, -1, sizeof g);
	cin >> n >> m >> L >> s >> t;

	vector<pair<int, int>>ers;
	for(int i = 0; i < m; i++){
		int u, v, c;
		cin >> u >> v >> c;
		g[u][v] = g[v][u] = c;
		grph[u].emplace_back(v);
		grph[v].emplace_back(u);
		if(c == 0)
			emp[u][v] = emp[v][u] = 1, ers.emplace_back(u, v);
	}
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			if(emp[i][j])
				g[i][j] = g[j][i] = INF;

	int cur = dij();
	if(cur < L)
		invalid();
	if(cur == L)
		valid();

	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			if(emp[i][j])
				g[i][j] = g[j][i] = 1;

	cur = dij();
	if(cur > L)
		invalid();
	if(cur == L)
		valid();

	vector<bool>vis(ers.size());
	for(int i = 0; i < ers.size(); i++){
		int u = ers[i].first, v = ers[i].second;
		vis[i] = 1;
		g[u][v] = g[v][u] = INF;
		edg.clear();
		int tmp = dij();
		if(tmp == L)
			valid();
		if(tmp < L)continue;
		g[u][v] = g[v][u] = 1;
		tmp = dij();
		for(int x = 0; x < ers.size(); x++)
			if(!vis[x])g[ers[x].first][ers[x].second] = g[ers[x].second][ers[x].first] = INF;
		for(int x = 0; x < ers.size(); x++)
			if(!vis[x])g[ers[x].first][ers[x].second] = g[ers[x].second][ers[x].first] = 1;
		g[u][v] = g[v][u] = L - tmp + 1;
		valid();
	}
}


#include <bits/stdc++.h>

using namespace std;

#define all(x) x.begin(), x.end()
#define endl '\n'
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;

/*
 * 3yza path been s and t ykon feh edges fadya
 * hashof el awl lw el shortest path 3moman mafehosh edges fdya w el value bta3to < L then no valid answer (assign empty edges b INF)
 * lw el shortest path == L ha assign el empty edges b INF w 5alas kda
 * now 3shan ageeb my own shortest path ha assign kol el empty edges b one w ageeb shortest path
 * lw tl3 > L then no valid answer
 * lw == L then zy mana
 * lw as3'ar mn L hazawd one of the edges ely kant empty w fel shortest path l3'ayt maywsal L
 * w ba2y el edges ely bara el shortest path w kano empty ha5alehom b INF
 * 1. build graph 3ady gdan
 * 2. arr for values of each edge 3shan ha3'ayaro kaza mara
 * 3. first assign each empty edge b INF (7aga msh hat overflow)
 * 4. run dijkstra lw el result < L return false, lw == L return answer
 * 5. ha assign all empty edges b 1 w a run dijkstra keeping track of the parent of each node 3shan ageeb el empty edges
 * 6. lw > L return false, lw == L return answer
 * 7. lw as3'ar ha5aly all empty edges bara el shortest path b INF w azawd wa7d mn el shortest path L - current
 */

const int INF = 1e9 + 10;
const int N = 1005;
int n, m, s, t;
int L, g[N][N];
bool emp[N][N];
vector<pair<int, int>>edg;
int dij(){
	vector<int>d(N, 2e9);
	vector<bool>vis(N, 0);
	vector<int>par(N, -1);
	priority_queue<pair<int, int>>q;
	q.emplace(0, s);
	while(q.size()){
		int cst = -q.top().first;
		int nd = q.top().second;
		q.pop();
		if(vis[nd])continue;
		vis[nd] = 1;
		for(int i = 0; i < n; i++){
			if(g[nd][i] == -1 || vis[i])continue;
			if(cst + g[nd][i] < d[i] && cst + g[nd][i] <= L){
				d[i] = cst + g[nd][i];
				par[i] = nd;
				q.emplace(-d[i], i);
			}
		}
	}
	int cur = t;
	while(par[cur] != -1){
		if(emp[cur][par[cur]])
			edg.emplace_back(cur, par[cur]);
		cur = par[cur];
	}
	return d[t];
}
void invalid(){
	cout << "NO";
	exit(0);
}
void valid(){
	cout << "YES" << endl;
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			if(g[i][j] != -1)
				cout << i << " " << j << " " << g[i][j] << endl;
	exit(0);
}

int main(){
	IO;

	memset(g, -1, sizeof g);
	cin >> n >> m >> L >> s >> t;

	vector<pair<int, int>>ers;
	for(int i = 0; i < m; i++){
		int u, v, c;
		cin >> u >> v >> c;
		g[u][v] = g[v][u] = c;
		if(c == 0)
			emp[u][v] = emp[v][u] = 1, ers.emplace_back(u, v);
	}
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			if(emp[i][j])
				g[i][j] = g[j][i] = INF;

	int cur = dij();
	if(cur < L)
		invalid();
	if(cur == L)
		valid();

	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			if(emp[i][j])
				g[i][j] = g[j][i] = 1;

	cur = dij();
	if(cur > L)
		invalid();
	if(cur == L)
		valid();

	vector<bool>vis(ers.size());
	for(int i = 0; i < ers.size(); i++){
		int u = ers[i].first, v = ers[i].second;
		vis[i] = 1;
		g[u][v] = g[v][u] = INF;
		edg.clear();
		int tmp = dij();
		if(tmp == L)
			valid();
		if(tmp < L)continue;
		g[u][v] = g[v][u] = 1;
		tmp = dij();
		for(int x = 0; x < ers.size(); x++)
			if(!vis[x])g[ers[x].first][ers[x].second] = g[ers[x].second][ers[x].first] = INF;
		for(int x = 0; x < ers.size(); x++)
			if(!vis[x])g[ers[x].first][ers[x].second] = g[ers[x].second][ers[x].first] = 1;
		g[u][v] = g[v][u] = L - tmp + 1;
		valid();
	}
}


#include <bits/stdc++.h>

using namespace std;

#define all(x) x.begin(), x.end()
#define endl '\n'
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;

/*
 * 3yza path been s and t ykon feh edges fadya
 * hashof el awl lw el shortest path 3moman mafehosh edges fdya w el value bta3to < L then no valid answer (assign empty edges b INF)
 * lw el shortest path == L ha assign el empty edges b INF w 5alas kda
 * now 3shan ageeb my own shortest path ha assign kol el empty edges b one w ageeb shortest path
 * lw tl3 > L then no valid answer
 * lw == L then zy mana
 * lw as3'ar mn L hazawd one of the edges ely kant empty w fel shortest path l3'ayt maywsal L
 * w ba2y el edges ely bara el shortest path w kano empty ha5alehom b INF
 * 1. build graph 3ady gdan
 * 2. arr for values of each edge 3shan ha3'ayaro kaza mara
 * 3. first assign each empty edge b INF (7aga msh hat overflow)
 * 4. run dijkstra lw el result < L return false, lw == L return answer
 * 5. ha assign all empty edges b 1 w a run dijkstra keeping track of the parent of each node 3shan ageeb el empty edges
 * 6. lw > L return false, lw == L return answer
 * 7. lw as3'ar ha5aly all empty edges bara el shortest path b INF w azawd wa7d mn el shortest path L - current
 */

const ll INF = 1e14;
const int N = 1005;
int n, m;
ll L, g[N][N];
bool emp[N][N];
vector<pair<int, int>>edg;
ll dij(int s, int t, int a){
	vector<ll>d(N, 1e18);
	vector<bool>vis(N, 0);
	vector<int>par(N, -1);
	d[s] = 0;
	priority_queue<pair<ll, int>>q;
	q.emplace(0, s);
	while(q.size()){
		ll cst = -q.top().first;
		int nd = q.top().second;
		q.pop();
		if(vis[nd])continue;
		vis[nd] = 1;
		for(int i = 0; i < n; i++){
			if(g[nd][i] == -1 || vis[i] || (nd == s && i == a))continue;
			if(cst + g[nd][i] < d[i]){
				d[i] = cst + g[nd][i];
				par[i] = nd;
				q.emplace(-d[i], i);
			}
		}
	}
	int cur = t;
	while(par[cur] != -1){
		if(emp[cur][par[cur]])
			edg.emplace_back(cur, par[cur]);
		cur = par[cur];
	}
	return d[t];
}
void invalid(){
	cout << "NO";
	exit(0);
}
void valid(){
	cout << "YES" << endl;
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			if(g[i][j] != -1)
				cout << i << " " << j << " " << g[i][j] << endl;
	exit(0);
}

int main(){
	IO;

	int s, t;
	memset(g, -1, sizeof g);
	cin >> n >> m >> L >> s >> t;

	vector<pair<int, int>>ers;
	for(int i = 0; i < m; i++){
		int u, v, c;
		cin >> u >> v >> c;
		g[u][v] = g[v][u] = c;
		if(c == 0)
			emp[u][v] = emp[v][u] = 1, ers.emplace_back(u, v);
	}
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			if(emp[i][j])
				g[i][j] = g[j][i] = INF;

	ll cur = dij(s, t, -1);
	if(cur < L)
		invalid();
	if(cur == L)
		valid();

	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			if(emp[i][j])
				g[i][j] = g[j][i] = 1;

	for(int k = 0; k < ers.size(); k++){
		int u = ers[k].first, v = ers[k].second;
		edg.clear();
//		cerr << u << " " << v << endl;
		ll tmp = dij(u, s, v);
		ll tmp2 = dij(v, t, u);
//		cerr << "here " << tmp << " " << tmp2 << endl;
		if(tmp + tmp2 < L){
			for(int i = 0; i < n; i++)
				for(int j = i + 1; j < n; j++)
					if(emp[i][j])g[i][j] = g[j][i] = INF;
			for(auto e: edg)
				g[e.first][e.second] = g[e.second][e.first] = 1;
			g[u][v] = g[v][u] = L - tmp - tmp2;
			if(dij(s, t, -1) == L)
				valid();
		}
		edg.clear();
		tmp = dij(u, t, v);
		tmp2 = dij(v, s, u);
		if(tmp + tmp2 < L){
			for(int i = 0; i < n; i++)
				for(int j = i + 1; j < n; j++)
					if(emp[i][j])g[i][j] = g[j][i] = INF;
			for(auto e: edg)
				g[e.first][e.second] = g[e.second][e.first] = 1;
			g[u][v] = g[v][u] = L - tmp - tmp2;
			if(dij(s, t, -1) == L)
				valid();
		}
	}
	invalid();
}


#include <bits/stdc++.h>

using namespace std;

#define all(x) x.begin(), x.end()
#define endl '\n'
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;

/*
 * 3yza path been s and t ykon feh edges fadya
 * hashof el awl lw el shortest path 3moman mafehosh edges fdya w el value bta3to < L then no valid answer (assign empty edges b INF)
 * lw el shortest path == L ha assign el empty edges b INF w 5alas kda
 * now 3shan ageeb my own shortest path ha assign kol el empty edges b one w ageeb shortest path
 * lw tl3 > L then no valid answer
 * lw == L then zy mana
 * lw as3'ar mn L hazawd one of the edges ely kant empty w fel shortest path l3'ayt maywsal L
 * w ba2y el edges ely bara el shortest path w kano empty ha5alehom b INF
 * 1. build graph 3ady gdan
 * 2. arr for values of each edge 3shan ha3'ayaro kaza mara
 * 3. first assign each empty edge b INF (7aga msh hat overflow)
 * 4. run dijkstra lw el result < L return false, lw == L return answer
 * 5. ha assign all empty edges b 1 w a run dijkstra keeping track of the parent of each node 3shan ageeb el empty edges
 * 6. lw > L return false, lw == L return answer
 * 7. lw as3'ar ha5aly all empty edges bara el shortest path b INF w azawd wa7d mn el shortest path L - current
 */

const ll INF = 1e14;
const int N = 1005;
int n, m;
int L, g[N][N];
bool emp[N][N];
vector<vector<int>>grph(N);
vector<pair<int, int>>edg;
pair<vector<int>, vector<int>> dij(int s){
	vector<int>d(N, 2e9);
	vector<bool>vis(N, 0);
	vector<int>par(N, -1);
	d[s] = 0;
	priority_queue<pair<int, int>>q;
	q.emplace(0, s);
	while(q.size()){
		int cst = -q.top().first;
		int nd = q.top().second;
		q.pop();
		if(vis[nd])continue;
		vis[nd] = 1;
		for(auto ch: grph[nd]){
			if(vis[ch])continue;
			if(cst *1ll + g[nd][ch] < d[ch]){
				d[ch] = cst + g[nd][ch];
				par[ch] = nd;
				q.emplace(-d[ch], ch);
			}
		}
	}

	return {d, par};
}

void invalid(){
	cout << "NO";
	exit(0);
}
void valid(){
	cout << "YES" << endl;
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			if(g[i][j] != -1)
				cout << i << " " << j << " " << g[i][j] << endl;
	exit(0);
}

int main(){
	IO;

	int s, t;
	memset(g, -1, sizeof g);
	cin >> n >> m >> L >> s >> t;

	vector<pair<int, int>>ers;
	for(int i = 0; i < m; i++){
		int u, v, c;
		cin >> u >> v >> c;
		g[u][v] = g[v][u] = c;
		grph[u].emplace_back(v);
		grph[v].emplace_back(u);
		if(c == 0)
			emp[u][v] = emp[v][u] = 1, ers.emplace_back(u, v);
	}
	for(auto x: ers){
		int i = x.first, j = x.second;
		g[i][j] = g[j][i] = INF;
	}

	int cur = dij(s).first[t];
	if(cur < L)
		invalid();
	if(cur == L)
		valid();

	for(auto x: ers){
		int i = x.first, j = x.second;
		g[i][j] = g[j][i] = 1;
	}

	for(int k = 0; k < ers.size(); k++){
		int u = ers[k].first, v = ers[k].second;
		g[u][v] = g[v][u] = INF;
		pair<vector<int>, vector<int>> tmp = dij(s);
		pair<vector<int>, vector<int>> tmp2 = dij(t);
		int d1 = tmp.first[u], d2 = tmp2.first[v];
		if(d1 *1ll + d2 < L){
			for(auto e: ers){
				int i = e.first, j = e.second;
				g[i][j] = g[j][i] = INF;
			}
			int cur = u;
			while(tmp.second[cur] != -1){
				if(emp[cur][tmp.second[cur]])
					g[cur][tmp.second[cur]] = g[tmp.second[cur]][cur] = 1;
				cur = tmp.second[cur];
			}
			cur = v;
			while(tmp2.second[cur] != -1){
				if(emp[cur][tmp2.second[cur]])
					g[cur][tmp2.second[cur]] = g[tmp2.second[cur]][cur] = 1;
				cur = tmp2.second[cur];
			}
			g[u][v] = g[v][u] = L - d1 - d2;
			tmp = dij(s);
			if(tmp.first[t] == L)
				valid();
		}
		d1 = tmp.first[v], d2 = tmp2.first[u];
		if(d1 *1ll + d2 < L){
			for(auto e: ers){
				int i = e.first, j = e.second;
				g[i][j] = g[j][i] = INF;
			}
			int cur = u;
			while(tmp.second[cur] != -1){
				if(emp[cur][tmp.second[cur]])
					g[cur][tmp.second[cur]] = g[tmp.second[cur]][cur] = 1;
				cur = tmp.second[cur];
			}
			cur = v;
			while(tmp2.second[cur] != -1){
				if(emp[cur][tmp2.second[cur]])
					g[cur][tmp2.second[cur]] = g[tmp2.second[cur]][cur] = 1;
				cur = tmp2.second[cur];
			}
			g[u][v] = g[v][u] = L - d1 - d2;
			tmp = dij(s);
			if(tmp.first[t] == L)
				valid();
		}
	}
	invalid();
}


#include <bits/stdc++.h>

using namespace std;

#define all(x) x.begin(), x.end()
#define endl '\n'
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;

/*
 * 3yza path been s and t ykon feh edges fadya
 * hashof el awl lw el shortest path 3moman mafehosh edges fdya w el value bta3to < L then no valid answer (assign empty edges b INF)
 * lw el shortest path == L ha assign el empty edges b INF w 5alas kda
 * now 3shan ageeb my own shortest path ha assign kol el empty edges b one w ageeb shortest path
 * lw tl3 > L then no valid answer
 * lw == L then zy mana
 * lw as3'ar mn L hazawd one of the edges ely kant empty w fel shortest path l3'ayt maywsal L
 * w ba2y el edges ely bara el shortest path w kano empty ha5alehom b INF
 * 1. build graph 3ady gdan
 * 2. arr for values of each edge 3shan ha3'ayaro kaza mara
 * 3. first assign each empty edge b INF (7aga msh hat overflow)
 * 4. run dijkstra lw el result < L return false, lw == L return answer
 * 5. ha assign all empty edges b 1 w a run dijkstra keeping track of the parent of each node 3shan ageeb el empty edges
 * 6. lw > L return false, lw == L return answer
 * 7. lw as3'ar ha5aly all empty edges bara el shortest path b INF w azawd wa7d mn el shortest path L - current
 */

const ll INF = 1e14;
const int N = 1005;
int n, m;
ll L, g[N][N];
bool emp[N][N];
vector<vector<int>>grph(N);
vector<pair<int, int>>edg;
pair<vector<ll>, vector<int>> dij(int s){
	vector<ll>d(N, 1e18);
	vector<bool>vis(N, 0);
	vector<int>par(N, -1);
	d[s] = 0;
	priority_queue<pair<ll, int>>q;
	q.emplace(0, s);
	while(q.size()){
		ll cst = -q.top().first;
		int nd = q.top().second;
		q.pop();
		if(vis[nd])continue;
		vis[nd] = 1;
		for(auto ch: grph[nd]){
			if(vis[ch])continue;
			if(cst + g[nd][ch] < d[ch]){
				d[ch] = cst + g[nd][ch];
				par[ch] = nd;
				q.emplace(-d[ch], ch);
			}
		}
	}

	return {d, par};
}

void invalid(){
	cout << "NO";
	exit(0);
}
void valid(){
	cout << "YES" << endl;
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			if(g[i][j] != -1)
				cout << i << " " << j << " " << g[i][j] << endl;
	exit(0);
}

int main(){
	IO;

	int s, t;
	memset(g, -1, sizeof g);
	cin >> n >> m >> L >> s >> t;

	vector<pair<int, int>>ers;
	for(int i = 0; i < m; i++){
		int u, v, c;
		cin >> u >> v >> c;
		g[u][v] = g[v][u] = c;
		grph[u].emplace_back(v);
		grph[v].emplace_back(u);
		if(c == 0)
			emp[u][v] = emp[v][u] = 1, ers.emplace_back(u, v);
	}
	for(auto x: ers){
		int i = x.first, j = x.second;
		g[i][j] = g[j][i] = INF;
	}

	ll cur = dij(s).first[t];
	if(cur < L)
		invalid();
	if(cur == L)
		valid();

	for(auto x: ers){
		int i = x.first, j = x.second;
		g[i][j] = g[j][i] = 1;
	}

	for(int k = 0; k < ers.size(); k++){
		int u = ers[k].first, v = ers[k].second;
		g[u][v] = g[v][u] = INF;
		pair<vector<ll>, vector<int>> tmp = dij(s);
		pair<vector<ll>, vector<int>> tmp2 = dij(t);
		ll d1 = tmp.first[u], d2 = tmp2.first[v];
		if(d1 + d2 < L){
			for(auto e: ers){
				int i = e.first, j = e.second;
				g[i][j] = g[j][i] = INF;
			}
			int cur = u;
			while(tmp.second[cur] != -1){
				if(emp[cur][tmp.second[cur]])
					g[cur][tmp.second[cur]] = g[tmp.second[cur]][cur] = 1;
				cur = tmp.second[cur];
			}
			cur = v;
			while(tmp2.second[cur] != -1){
				if(emp[cur][tmp2.second[cur]])
					g[cur][tmp2.second[cur]] = g[tmp2.second[cur]][cur] = 1;
				cur = tmp2.second[cur];
			}
			g[u][v] = g[v][u] = L - d1 - d2;
			tmp = dij(s);
			if(tmp.first[t] == L)
				valid();
		}
		d1 = tmp.first[v], d2 = tmp2.first[u];
		if(d1 + d2 < L){
			for(auto e: ers){
				int i = e.first, j = e.second;
				g[i][j] = g[j][i] = INF;
			}
			int cur = u;
			while(tmp.second[cur] != -1){
				if(emp[cur][tmp.second[cur]])
					g[cur][tmp.second[cur]] = g[tmp.second[cur]][cur] = 1;
				cur = tmp.second[cur];
			}
			cur = v;
			while(tmp2.second[cur] != -1){
				if(emp[cur][tmp2.second[cur]])
					g[cur][tmp2.second[cur]] = g[tmp2.second[cur]][cur] = 1;
				cur = tmp2.second[cur];
			}
			g[u][v] = g[v][u] = L - d1 - d2;
			tmp = dij(s);
			if(tmp.first[t] == L)
				valid();
		}
	}
	invalid();
}


#include <bits/stdc++.h>

using namespace std;

#define all(x) x.begin(), x.end()
#define endl '\n'
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;

/*
 * 3yza path been s and t ykon feh edges fadya
 * hashof el awl lw el shortest path 3moman mafehosh edges fdya w el value bta3to < L then no valid answer (assign empty edges b INF)
 * lw el shortest path == L ha assign el empty edges b INF w 5alas kda
 * now 3shan ageeb my own shortest path ha assign kol el empty edges b one w ageeb shortest path
 * lw tl3 > L then no valid answer
 * lw == L then zy mana
 * lw as3'ar mn L hazawd one of the edges ely kant empty w fel shortest path l3'ayt maywsal L
 * w ba2y el edges ely bara el shortest path w kano empty ha5alehom b INF
 * 1. build graph 3ady gdan
 * 2. arr for values of each edge 3shan ha3'ayaro kaza mara
 * 3. first assign each empty edge b INF (7aga msh hat overflow)
 * 4. run dijkstra lw el result < L return false, lw == L return answer
 * 5. ha assign all empty edges b 1 w a run dijkstra keeping track of the parent of each node 3shan ageeb el empty edges
 * 6. lw > L return false, lw == L return answer
 * 7. lw as3'ar ha5aly all empty edges bara el shortest path b INF w azawd wa7d mn el shortest path L - current
 */
const ll INF = 1e14;
const int N = 1005;
int n, m, L, s, t;
ll g[N][N];
bool emp[N][N];
vector<pair<int, int>>edg;
ll dij(){
	vector<bool>vis(N);
	vector<ll>dis(N, 1e18);
	vector<int>par(N, -1);
	priority_queue<pair<ll, int>> q;
	q.emplace(0, s);
	while(q.size()){
		ll cst = -q.top().first;
		int nd = q.top().second;
		q.pop();
		if(vis[nd])continue;
		vis[nd] = 1;
		for(int i = 0; i < n; i++){
			if(g[nd][i] == -1 || vis[i])continue;
			if(cst + g[nd][i] < dis[i]){
				dis[i] = cst + g[nd][i];
				par[i] = nd;
				q.emplace(-dis[i], i);
			}
		}
	}
	edg.clear();
	int cur = t;
	while(par[cur] != -1){
		if(emp[cur][par[cur]])
			edg.emplace_back(cur, par[cur]);
		cur = par[cur];
	}
	return dis[t];
}

void invalid(){
	cout << "NO";
	exit(0);
}
void valid(){
	cout << "YES" << endl;
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			if(g[i][j] != -1)
				cout << i << " " << j << " " << g[i][j] << endl;
	exit(0);
}

int main(){
	IO;

	memset(g, -1, sizeof g);

	cin >> n >> m >> L >> s >> t;
	for(int i = 0; i < m; i++){
		int u, v, c;
		cin >> u >> v >> c;
		if(c == 0)emp[u][v] = emp[v][u] = 1;
		g[u][v] = g[v][u] = c;
	}
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			if(emp[i][j])
				g[i][j] = g[j][i] = INF;

	ll cur = dij();
	if(cur < L)
		invalid();
	if(cur == L)
		valid();
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			if(emp[i][j])
				g[i][j] = g[j][i] = 1;
	cur = dij();

	if(cur > L)
		invalid();
	if(cur == L)
		valid();
	cur = L - cur;
	if(edg.empty())
		invalid();
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			if(emp[i][j])
				g[i][j] = g[j][i] = INF;

	for(auto e: edg)
		g[e.first][e.second] = g[e.second][e.first] = 1;
	g[edg.back().first][edg.back().second] = g[edg.back().second][edg.back().first] = cur + 1;
	valid();
}