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


// ~/BAU/ACM-ICPC/Teams/A++/BlackBurn95
// ~/sudo apt-get Accpeted

import java.io.*;
import java.util.*;
import java.math.*;
import static java.lang.Math.*;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Double.parseDouble;
import static java.lang.String.*;

public class Main {
    
    static int n,m,L,s,t;
    static long inf = (long)1e18;
    static List<node> [] g;
    static long [][] cost;
    static List<edge> e;
    
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder out = new StringBuilder();
        StringTokenizer tk;
        
        tk = new StringTokenizer(in.readLine());
        n = parseInt(tk.nextToken());
        m = parseInt(tk.nextToken());
        L = parseInt(tk.nextToken());
        s = parseInt(tk.nextToken());
        t = parseInt(tk.nextToken());
        
        g = new List[n];
        for(int i=0; i<n; i++) g[i] = new ArrayList<>();
        e = new ArrayList<>();
        
        int x = 1;
        while(m-- > 0) {
            tk = new StringTokenizer(in.readLine());
            int a = parseInt(tk.nextToken()),b = parseInt(tk.nextToken()),c = parseInt(tk.nextToken());
            
            e.add(new edge(a,b,c));
            g[a].add(new node(b,c,(c==0 ? x : -1)));
            g[b].add(new node(a,c,(c==0 ? x++ : -1)));
        }
        
        long dist = dijkstra(s,t,-1,0);
        
        if(dist < L) {
             System.out.println("NO");
             return;
        }
        
        int l=1,r=e.size(),p=-1;
        
        while(l <= r) {
            m = (l+r)/2;
            
            if(dijkstra(s,t,m,1) <= L) {
                p = m;
                r = m-1;
            } else l = m+1;
        }
        
        if(p==-1) {
            System.out.println("NO");
            return;
        }
        
        l=1;
        r=(int)L;
        x=-1;
        
        while(l <= r) {
            m = (l+r)/2;
            
            long tmp = dijkstra(s,t,p,m);
            if(tmp == L) {
                x = m;
                break;
            } else if(tmp > L) r = m-1;
            else l = m+1;
        }
        
        if(x==-1) {
            System.out.println("NO");
            return;
        }
        
        out.append("YES\n");
        
        int i = 1;
        for(edge ee : e) {
            out.append(ee.a).append(" ").append(ee.b).append(" ");
            if(ee.c==0) {
                if(i<p) out.append("1\n");
                else if(i==p) out.append(x).append("\n");
                else out.append(inf).append("\n");
            } else out.append(ee.c).append("\n");
        }
        
        System.out.print(out);
    }
    
    static long dijkstra(int s,int t,int p,long val) {
        Queue<node> q = new PriorityQueue<>();
        long [] d = new long[n];
        Arrays.fill(d, inf);
        d[s] = 0;
        q.add(new node(s,0,0));
        
        while(!q.isEmpty()) {
            node u = q.remove();
            
            if(u.u==t)
                return u.c;
            
            for(node v : g[u.u]) {
                if(p==-1 && v.c==0)  continue;
                                
                long w = v.c;
                if(w==0) {
                    if(v.x < p) w = 1;
                    else if(v.x == p) w = val;
                    else w = inf;
                }
                
                if(d[v.u] > d[u.u]+w) {
                    d[v.u] = d[u.u]+w;
                    q.add(new node(v.u,d[v.u],0));
                }
            }
        }
        
        return inf;
    }
}

class node implements Comparable<node> {
    int u,x;
    long c;
    
    public node(int u,long c,int x) {
        this.u = u;
        this.c = c;
        this.x = x;
    }
    
    @Override
    public int compareTo(node n) {
        if(c != n.c)
            return c < n.c ? -1 : 1;
        return u - n.u;
    }
    
    @Override
    public String toString() {
        return " ("+u+" , "+c+") ";
    }
}

class edge {
    int a,b,c;
    
    public edge(int a,int b,int c) {
        this.a = a;
        this.b = b;
        this.c = c;
    }
}