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

import java.io.*;
import java.util.*;
public class div372Dx
{
	BufferedReader in;
	PrintWriter ob;
	StringTokenizer st;
	int n,m,L,u[],v[],w[],source,dest;
	long cost[][];
	long dist1[],dist2[];
	boolean vis1[],vis2[];
	ArrayList<Integer> gr[];
	public static void main(String[] args) throws IOException {
		new div372Dx().run();
	}
	void run() throws IOException {
		//in=new BufferedReader(new FileReader("input.txt"));
		in=new BufferedReader(new InputStreamReader(System.in));
		ob=new PrintWriter(System.out);
		solve();
		ob.flush();
	}
	@SuppressWarnings("unchecked")
	void solve() throws IOException {
		n=ni();
		m=ni();
		L=ni();
		source=ni();
		dest=ni();
		cost=new long[n][n];
		u=new int[m];
		v=new int[m];
		w=new int[m];
		gr=new ArrayList[n];
		for (int i=0; i<n ; i++ ) {
			gr[i]=new ArrayList<Integer>();
		}
		for (int i=0; i<m ; i++ ) {
			u[i]=ni();
			v[i]=ni();
			w[i]=ni();
			gr[u[i]].add(v[i]);
			gr[v[i]].add(u[i]);
			cost[u[i]][v[i]]=(w[i]==0)?-1:w[i];
			cost[v[i]][u[i]]=(w[i]==0)?-1:w[i];
		}
		dijkstra(dest,source);
		/*for (int i=0; i<n ; i++ ) {
			ob.println("dijkstra "+i+" "+dist1[i]);
		}*/
		dijkstraS(source,dest);
		/*for (int i=0; i<n ; i++ ) {
			ob.println("dijkstra2 "+i+" "+dist2[i]);
		}*/
		if(dist2[dest]!=L) {
			ob.println("NO");
		}
		else {
			ob.println("YES");
			for (int i=0; i<m ; i++ ) {
			    if(cost[u[i]][v[i]]==-1)
				ob.println(u[i]+" "+v[i]+" 1000000000");
				else
				ob.println(u[i]+" "+v[i]+" "+cost[u[i]][v[i]]);
			}
		}
	}

	void dijkstraS(int source,int dest) {
		TreeSet<Template> pq=new TreeSet<Template>(new Comparator<Template>(){
			public int compare(Template x, Template y) {
				return Long.compare(x.p,y.p);
			}
		});
		dist2=new long[n];
		Arrays.fill(dist2,Long.MAX_VALUE);
		dist2[source]=0;
		vis2=new boolean[n];
		Template start=new Template();
		start.i=source;
		start.p=0;
		pq.add(start);
		while(!pq.isEmpty()) {
			Template polled=pq.first();
			int ele=polled.i;
			long p=polled.p;
			pq.remove(polled);
			vis2[ele]=true;
			for(int x : gr[ele]) {
				if(!vis2[x]) {
					long weight=(cost[ele][x]==-1)?Math.max(1,L-p-dist1[x]):cost[ele][x];
					if(p+weight<=dist2[x]) {
						cost[ele][x]=weight;
						cost[x][ele]=weight;
						dist2[x]=p+weight;
						Template next=new Template();
						next.i=x;
						next.p=dist2[x];
						pq.add(next);
					}
				}
			}		
		}
	}
	
	void dijkstra(int source,int dest) {
		TreeSet<Template> pq=new TreeSet<Template>(new Comparator<Template>(){
			public int compare(Template x, Template y) {
				return Long.compare(x.p,y.p);
			}
		});
		dist1=new long[n];
		Arrays.fill(dist1,Long.MAX_VALUE);
		dist1[source]=0;
		vis1=new boolean[n];
		Template start=new Template();
		start.i=source;
		start.p=0;
		pq.add(start);
		while(pq.isEmpty()==false) {
			Template polled=pq.first();
			int ele=polled.i;
			long p=polled.p;
			pq.remove(polled);
			vis1[ele]=true;
			for(int x : gr[ele]) {
				if(!vis1[x]) {
					long weight=(cost[ele][x]==-1)?1:cost[ele][x];
					if(p+weight<=dist1[x]) {
						dist1[x]=p+weight;
						Template next=new Template();
						next.i=x;
						next.p=dist1[x];
						pq.add(next);
					}
				}
			}		
		}
	}
	int ni() throws IOException {
		return Integer.parseInt(nextToken());
	}
	String nextToken() throws IOException {
		if(st==null || !st.hasMoreTokens())
			st=new StringTokenizer(in.readLine());
		return st.nextToken();
	}
}
class Template {
	int i;
	long p;
}