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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class A {

	static final long INF = (long)1e18;

	static long[] dijkstra(int S, int N, ArrayList<Edge>[] adjList)
	{
		long[] D = new long[N];
		Arrays.fill(D, INF);
		PriorityQueue<Edge> pq = new PriorityQueue<>();
		D[S] = 0;
		pq.add(new Edge(S, 0));
		while(!pq.isEmpty())
		{
			Edge cur = pq.remove();
			if(cur.cost > D[cur.node])
				continue;
			for(Edge nxt: adjList[cur.node])
			{
				long totalCost = cur.cost + Math.max(nxt.cost, 1);
				if(totalCost < D[nxt.node])
					pq.add(new Edge(nxt.node, D[nxt.node] = totalCost));
			}
		}
		return D;
	}

	public static void main(String[] args) throws IOException 
	{
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int N = sc.nextInt(), M = sc.nextInt(), L = sc.nextInt(), S = sc.nextInt(), T = sc.nextInt();
		ArrayList<Edge>[] adjList = new ArrayList[N];
		for(int i = 0; i < N; ++i)
			adjList[i] = new ArrayList<>(1);
		long[][] adjMat = new long[N][N];
		for(long[] x: adjMat)
			Arrays.fill(x, -1);
		while(M-->0)
		{
			int u = sc.nextInt(), v = sc.nextInt(), w = sc.nextInt();
			adjList[u].add(new Edge(v, w));
			adjList[v].add(new Edge(u, w));
			adjMat[u][v] = adjMat[v][u] = w;
		}
		long[] dist = dijkstra(S, N, adjList);
		if(dist[T] == -1 || dist[T] > L)
			out.println("NO");
		else
		{
			PriorityQueue<Edge> pq = new PriorityQueue<>(new Comp());
			if(dist[T] < L)
			{
				pq.add(new Edge(T, L));
				dist[T] = L;
			}
			boolean good = true;
			while(!pq.isEmpty())
			{
				Edge cur = pq.remove();
				if(cur.node == S)
					good = false;
				if(cur.cost != dist[cur.node])
					continue;
				for(Edge nxt: adjList[cur.node])
					if(dist[nxt.node] + Math.max(nxt.cost, 1) < cur.cost)
						if(nxt.cost == 0)
							adjMat[cur.node][nxt.node] = adjMat[nxt.node][cur.node] = cur.cost - dist[nxt.node];
						else
							pq.add(new Edge(nxt.node, dist[nxt.node] = cur.cost - nxt.cost));
			}
			if(!good)
				out.println("NO");
			else
			{
				out.println("YES");
				for(int i = 0; i < N; ++i)
					for(int j = i + 1; j < N; ++j)
						if(adjMat[i][j] != -1)
							out.printf("%d %d %d\n", i, j, Math.max(adjMat[i][j], 1));
			}
		}
		out.flush();
		out.close();
	}

	static class Edge implements Comparable<Edge>
	{
		int node;
		long cost;

		Edge(int a, long b) { node = a; cost = b; }

		public int compareTo(Edge e)
		{
			if(cost != e.cost)
				return cost > e.cost ? 1 : -1;
				return node - e.node;
		}
	}
	
	static class Comp implements Comparator<Edge>
	{
		public int compare(Edge e1, Edge e2)
		{
			if(e1.cost != e2.cost)
				return e1.cost > e2.cost ? -1 : 1;
			return e1.node - e2.node;
		}
	}

	static class Scanner 
	{
		StringTokenizer st;	
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException 
		{
			while (st == null || !st.hasMoreTokens()) 
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}

		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}

		public double nextDouble() throws IOException { return Double.parseDouble(next()); }
	}
}