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.*;
import java.math.*;

public class Solve3 {
  
  static class Edge{
    int u; int v; long w;
    Edge(int u, int v, long w) {
	  this.u = u; this.v = v; this.w = w;
	}
  }
  static class Node implements Comparable<Node>{
    int nr; long d;
	Node(int nr, long d){
	  this.nr = nr;
	  this.d = d;
	}
	public int compareTo(Node node) {
	  if(node.d > d) return -1;
	  if(node.d < d) return 1;
	  return 0;
	}
  }
  static long INF = 10000000000L;
  static long dij(Edge[] edges, int s, int t, int n) {
    long res = INF;
    LinkedList<Edge> [] es = new LinkedList[n];
	for(int i = 0; i < n; i++) es[i] = new LinkedList<>();
	for(Edge e : edges) {
	  es[e.u].add(e);
	  es[e.v].add(e);
	}
	PriorityQueue<Node> q = new PriorityQueue<Node>();
	boolean[] visited = new boolean[n];
	q.offer(new Node(s, 0));
	while(!q.isEmpty()) {
	  Node node = q.poll();
	  visited[node.nr] = true;
	  if(node.nr == t) {
	    return node.d;
	  }
	  for(Edge e : es[node.nr]) {
	    if(e.v==node.nr) {
		  if(!visited[e.u])
		    q.offer(new Node(e.u, node.d + e.w));
		} else {
		  if(!visited[e.v])
		    q.offer(new Node(e.v, node.d + e.w));
		}
	  }
	  
	}
    return res;	
  }
  
  public static void main(String[] args) {
	MyScanner scanner = new MyScanner();
	PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
    int n = scanner.nextInt();
	int m = scanner.nextInt();
	long L = scanner.nextInt();
	int s = scanner.nextInt();
	int t = scanner.nextInt();
	Edge[] edges = new Edge[m];
	Set<Edge> zeros = new HashSet<Edge>();
    for(int i = 0; i < m; i++) {
      int u = scanner.nextInt();
	  int v = scanner.nextInt();
	  long w = scanner.nextInt();
	  edges[i] = new Edge(u,v,w);
	  if(w==0L) zeros.add(edges[i]);
    }
	for(Edge e : zeros) {
      e.w = 1L;
    }	
    long min = dij(edges, s, t, n);
    for(Edge e : zeros) {
      e.w = INF;
    }	
	long max = dij(edges, s, t, n);
	//System.out.println(min + " " + max);
	if(min <= L && L <= max) {
	  
	  for(Edge e : zeros) {
	    long mi = 1; long ma = INF;
		long dist = INF;
		while(mi < ma) {
		  long mid = (mi+ma)/2;
		  e.w = mid;
		  dist = dij(edges, s, t, n);
		  //System.out.println(dist);
		  if(dist == L) {
		    break;
		  } else if(dist < L) {
		    mi = mid+1;
		  } else {
		    ma = mid;
		  }
		}
		if(dist == L) {
		  out.println("YES");
		  for(Edge e2 : edges) {
		    out.println(e2.u + " " + e2.v + " " + e2.w);
		  }
		  out.close();
		  return;
		}
	  }
	}
	out.println("NO");
	out.close();
  }
//

  public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;
 
      public MyScanner() {
         br = new BufferedReader(new InputStreamReader(System.in));
      }
 
      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }
 
      int nextInt() {
          return Integer.parseInt(next());
      }
 
      long nextLong() {
          return Long.parseLong(next());
      }
 
      double nextDouble() {
          return Double.parseDouble(next());
      }
 
      String nextLine(){
          String str = "";
	  try {
	     str = br.readLine();
	  } catch (IOException e) {
	     e.printStackTrace();
	  }
	  return str;
      }

   }
}