7 9 999999999 0 3
0 1 0
1 2 0
2 3 0
0 4 1
4 1 1
1 5 499999999
5 2 499999999
2 6 1
6 3 1
 7 9 320 0 3
0 1 0
1 2 0
2 3 0
0 4 1
4 1 1
1 5 100
5 2 100
2 6 59
6 3 61
 4 5 7 0 3
0 1 0
1 2 3
2 3 0
0 2 5
1 3 5
 8 9 10 1 0
1 2 1
2 4 1
1 3 0
3 4 0
4 5 0
5 6 1
6 0 1
5 7 0
7 0 0
 4 4 14 1 3
1 3 13
2 3 0
2 0 0
1 0 12
 5 6 1000000000 0 4
0 1 1
2 0 2
3 0 3
4 1 0
4 2 0
3 4 0
 4 5 10 1 2
0 1 3
1 2 0
1 3 4
2 3 4
2 0 6
 4 4 2 1 3
1 3 13
2 3 0
2 0 0
1 0 0
 5 5 2 0 2
0 1 1
1 2 1
0 4 0
4 3 0
3 2 0
 5 5 3 0 2
0 1 1
1 2 1
0 4 0
4 3 0
3 2 0
 4 4 8 1 3
1 3 13
2 3 0
2 0 0
1 0 6
 1000 1 1000000000 998 0
0 999 0
 5 5 1 0 2
0 1 1
1 2 1
0 4 0
4 3 0
3 2 0
 100 1 123456 99 0
0 99 123456
 4 4 13 1 3
1 3 13
2 3 0
2 0 0
1 0 12
 7 9 319 0 3
0 1 0
1 2 0
2 3 0
0 4 1
4 1 1
1 5 100
5 2 100
2 6 59
6 3 61
 1000 1 5 999 0
0 999 0

YES
0 1 1
1 2 999999996
2 3 999999997
0 4 1
4 1 1
1 5 499999999
5 2 499999999
2 6 1
6 3 1
 YES
0 1 1
1 2 199
2 3 318
0 4 1
4 1 1
1 5 100
5 2 100
2 6 59
6 3 61
 YES
0 1 3
1 2 3
2 3 2
0 2 5
1 3 5
 YES
1 2 1
2 4 1
1 3 1
3 4 1
4 5 6
5 6 1
6 0 1
5 7 1
7 0 1
 NO YES
0 1 1
2 0 2
3 0 3
4 1 999999999
4 2 999999998
3 4 999999997
 NO NO YES
0 1 1
1 2 1
0 4 1
4 3 1
3 2 1
 NO YES
1 3 13
2 3 1
2 0 1
1 0 6
 NO NO YES
0 99 123456
 YES
1 3 13
2 3 1
2 0 1
1 0 12
 YES
0 1 1
1 2 198
2 3 317
0 4 1
4 1 1
1 5 100
5 2 100
2 6 59
6 3 61
 YES
0 999 5

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <map>
#include <stack>
#include <set>
#include <vector>
#include <queue>
#define eps 10e-7
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define rep0(j,n) for(int j=0;j<n;j++)
#define rep1(j,n) for(int j=1;j<=n;j++)
#define pb push_back
#define set0(n) memset(n,0,sizeof(n))
#define k(n) n->first
#define ll long long

using namespace std;
const int MAXINT = 1010;
struct edge{
	ll u,v,w,tag;
	edge(){}
	edge(ll _u,ll _v,ll _w):u(_u),v(_v),w(_w){
		tag=_w==0?1:0;
		w=_w==0?INF:_w;
	}
	print(){
		printf("%I64d %I64d %I64d\n",u,v,w);
	}
};
struct node{
	int p;
	ll d;
	/*bool operator < (const node &b) const{
		return d>b.d;
	}*/
	node(){}
	node(int _p,ll _d):p(_p),d(_d){}
};
bool operator < (node a,node b) {
	return a.d>b.d;
}
edge sides[20010];
vector<int> G[MAXINT];
int n,m,l,s,t,from[MAXINT]={},vis[MAXINT]={};
ll dis[MAXINT]={};
ll spfa(int,int);
ll dijkstra(int,int);
int work(int,int);
int fix(ll,ll,int,int);
int main() {
	scanf("%d%d%d%d%d",&n,&m,&l,&s,&t);
	int u,v,w,tag=0;
	ll a;
	rep0(i,m){
		scanf("%d%d%d",&u,&v,&w);
		sides[tag]=edge(u,v,w);
		G[u].pb(tag++);
		sides[tag]=edge(v,u,w);
		G[v].pb(tag++);
	}
	if(dijkstra(s,t)<l){
		printf("NO\n");
		return 0;
	}
	rep0(i,m*2){
		if(sides[i].tag) sides[i].w=1;
	}
	if(dijkstra(s,t)>l){
		printf("NO\n");
		return 0;
	}
	rep0(i,m*2){
		if(sides[i].tag) sides[i].w=INF;
	}
	spfa(s,t);
	work(s,t);
	printf("YES\n");
	rep0(i,m){
		sides[i*2].print();
	}
    return 0;
}
ll spfa(int u,int v){
	memset(dis,0x3f3f,sizeof(dis));
	memset(vis,0,sizeof(vis));
	dis[u]=0;
	queue<int> q;
	int p;
	q.push(u);
	while(!q.empty()){
		p=q.front();q.pop();
		rep0(i,G[p].size()){
			edge &eg=sides[G[p][i]];
			if(dis[eg.u]+eg.w<dis[eg.v]){
				dis[eg.v]=dis[eg.u]+eg.w;
				from[eg.v]=G[p][i];
				if(!vis[eg.v]){
					vis[eg.v]=1;
					q.push(eg.v);
				}
			}
		}
		vis[p]=0;
	}
	return dis[v];
}
int fix(ll len,ll lans,int u,int v){
	int p=v;
	while(p!=u){
		edge &eg=sides[from[p]];
		if(eg.tag){
			eg.w+=lans-len;
			sides[from[p]^1].w+=lans-len;
			if(eg.w<=0) return 0;
			return 1;
		}
		p=eg.u;
	}
	return 0;
}
ll dijkstra(int u,int v){
	memset(dis,0x3f3f,sizeof(dis));
	memset(vis,0,sizeof(vis));
	dis[u]=0;
	int p;
	priority_queue<node> q;
	q.push(node(u,0));
	rep0(i,n){
		while(!q.empty()&&vis[p=q.top().p]) q.pop();
		if(vis[p]) break;
		vis[p]=1;
		rep0(i,G[p].size()){
			edge &eg=sides[G[p][i]];
			if(dis[eg.u]+eg.w<dis[eg.v]){
				dis[eg.v]=dis[eg.u]+eg.w;
				//from[eg.v]=G[p][i];
				q.push(node(eg.v,dis[eg.v]));
			}
		}
	}
	return dis[v];
}
int work(int u,int v){
	int p=v;
	ll a;
	while(p!=u){
		edge &eg=sides[from[p]];
		if(eg.tag){
			eg.w=1;
			a=dijkstra(u,v);
			if(a<l){
				eg.w+=l-a;
				return 0;
			}
		}
		p=eg.u;
	}
	return 0;
}
