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<cstdio>
#include<queue>
#include<cstring>
#include<cstdlib>
using namespace std;
const int N=1000,M=10000;
typedef long long ll;
const ll inf=1e15;
struct edge{int to,rev; ll len; bool b;};
vector<edge> G[N+1];
ll dis[N+1]; int pre[N+1][2];
bool counted[N+1][N+1];
int cnt,s,t;
void error(){
	printf("NO"); exit(0);
}
struct oedge{int st,en,stpos,enpos;}a[M+1];
void spfa(){
	bool vis[N+1]; memset(vis,0,sizeof vis);
	memset(pre,-1,sizeof pre);
	memset(dis,0x3f,sizeof dis); dis[s]=0; queue<int> Q;
	for(Q.push(s);!Q.empty();Q.pop()){
		int x=Q.front(); vis[x]=0;
		for(int i=0;i<G[x].size();++i){
			edge e=G[x][i];
			if(dis[x]+e.len<dis[e.to]){
				dis[e.to]=dis[x]+e.len; pre[e.to][0]=x; pre[e.to][1]=i;
				if(!vis[e.to]){
					vis[e.to]=1; Q.push(e.to);
				}
			}
		}
	}
}
int main(){
	int n,m; ll l; scanf("%d%d%lld%d%d",&n,&m,&l,&s,&t); ++s; ++t;
	for(int i=1;i<=m;++i){
		int u,v; ll w; scanf("%d%d%lld",&u,&v,&w); ++u; ++v;
		G[u].push_back({v,G[v].size(),w,w==0});
		G[v].push_back({u,G[u].size()-1,w,w==0});
		if(!w){
			a[++cnt].st=u; a[cnt].en=v;
			a[cnt].stpos=G[u].size()-1; a[cnt].enpos=G[v].size()-1;
		}
	}
	for(int i=1;i<=cnt;++i){
		G[a[i].st][a[i].stpos].len=G[a[i].en][a[i].enpos].len=inf;
	}
	spfa();
	if(dis[t]<l) error();
	for(int i=1;i<=cnt;++i)
		G[a[i].st][a[i].stpos].len=G[a[i].en][a[i].enpos].len=1;
	for(;;){
		spfa();
		if(dis[t]==l){
			printf("YES\n");
			for(int i=1;i<=n;++i) for(int j=0;j<G[i].size();++j){
				edge e=G[i][j];
				if(!counted[i][e.to]){
					printf("%d %d %lld\n",i-1,e.to-1,e.len);
					counted[i][e.to]=counted[e.to][i]=1;
				}
			}
			return 0;
		}
		int v=l-dis[t]; bool b=1;
		for(int i=t;pre[i][0]!=-1;i=pre[i][0])
			if(G[pre[i][0]][pre[i][1]].b){
				G[pre[i][0]][pre[i][1]].len+=v;
				G[i][G[pre[i][0]][pre[i][1]].rev].len+=v;
				b=0; break;
			}
		if(b) error();
	}
	return 0;
}