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.awt.Point;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;


public class D {

	static StringTokenizer st;
	static BufferedReader br;
	static PrintWriter pw;
	static int[][]a;
	static int[][]b;
	static long[]d;
	static int n;
	static long[][]D;
	static int[]q;
	static int[][]ages;
	static int[]size, p;
	static int qsize;
	
	public static void main(String[] args) throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		n = nextInt();
		int m = nextInt();
		int L = nextInt();
		int s = nextInt();
		int t = nextInt();
		s++;
		t++;
		a = new int[n+1][n+1];
		b = new int[n+1][n+1];
		q = new int[8*n+1];
		int[]v1 = new int[m+1], v2 = new int[m+1], w = new int[m+1];
		size = new int[n+1];
		p = new int[n+1];
		for (int i = 1; i <= m; i++) {
			v1[i] = nextInt();
			v2[i] = nextInt();
			v1[i]++;
			v2[i]++;
			size[v1[i]]++;
			size[v2[i]]++;
			w[i] = nextInt();
			if (w[i]==0)
				w[i] = -1;
			b[v1[i]][v2[i]] = b[v2[i]][v1[i]] = w[i];
		}
		ages = new int[n+1][];
		for (int i = 1; i <= n; i++) {
			ages[i] = new int[size[i]+1];
		}
		for (int i = 1; i <= n; i++) {
			size[i] = 0;
		}
		for (int i = 1; i <= m; i++) {
			ages[v1[i]][size[v1[i]]] = v2[i];
			ages[v2[i]][size[v2[i]]] = v1[i];
			
			size[v1[i]]++;
			size[v2[i]]++;
		}
		d = new long[n+1];
		
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				a[i][j] = b[i][j];
				if (b[i][j]==-1)
					a[i][j] = 0;
			}
		}
		long d1 = Dikstra(s, t);
		
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				a[i][j] = b[i][j];
				if (b[i][j]==-1)
					a[i][j] = 1;
			}
		}
		long d2 = Dikstra(s, t);
		
		if (d1 < L || d2 > L) {
			System.out.println("NO");
			return;
		}
		while (true) {
			d1 = Dikstra(s, t);
			if (d1==L)
				break;
			int v = t;
			while (v != s) {
				if (b[p[v]][v]==-1) {
					a[p[v]][v] = a[v][p[v]] = (int)(L-d[t]+a[p[v]][v]);
					if (a[p[v]][v] <= 0) {
						while (true) {
							
						}
					}
					break;
				}
				v = p[v];
			}
		}
		pw.println("YES");
		for (int i = 1; i <= n; i++) {
			for (int j = i+1; j <= n; j++) {
				if (a[i][j]==0)
					continue;
				pw.println((i-1)+" "+(j-1)+" "+a[i][j]);
			}
		}
		pw.close();
	}
	private static long Dikstra(int s, int t) {
		long INF = (long) 1e18;
		Arrays.fill(d, INF);
		d[s] = 0;
		q[1] = s;
		qsize = 1;
		boolean[]used = new boolean[n+1];
		Arrays.fill(p, 0);
		while (qsize >  0) {
			int v = pop();
			if (used[v])
				continue;
			used[v] = true;
			for (int i = 0; i < size[v]; i++) {
				int to = ages[v][i];
				if (a[v][to] != 0 && d[v] + a[v][to] < d[to]) {
					d[to] = d[v] + a[v][to];
					p[to] = v;
					add(to);
				}
			}
		}
		return d[t];
	}

	private static void add(int x) {
		q[++qsize] = x;
		int v = qsize;
		while (v > 1) {
			if (d[q[v]] < d[q[v >> 1]]) {
				int t = q[v];
				q[v] = q[v >> 1];
				q[v >> 1] = t;
				v >>= 1;
			}
			else
				break;
		}
	}
	
	private static int pop() {
		int res = q[1];
		q[1] = q[qsize];
		qsize--;
		int v = 1;
		while (2*v <= qsize) {
			int min_id = v;
			if (d[q[2*v]] < d[q[min_id]])
				min_id = 2*v;
			if (2*v+1 <= qsize && d[q[2*v+1]] < d[q[min_id]])
				min_id = 2*v+1;
			if (min_id==v)
				break;
			int t = q[v];
			q[v] = q[min_id];
			q[min_id] = t;
			v = min_id;
		}
		return res;
	}
	private static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
	private static long nextLong() throws IOException {
		return Long.parseLong(next());
	}
	private static double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}
	private static String next() throws IOException {
		while (st==null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}
}