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.*;
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,s,t;
    static long L;
    static long inf = (long)1e18;
    static List<node> [] g;
    static List<pair> e,path;
    
    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 = parseLong(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<>();
       path = new ArrayList<>();
       
       while(m-- > 0) {
           tk = new StringTokenizer(in.readLine());
           int a = parseInt(tk.nextToken()),b = parseInt(tk.nextToken());
           long c = parseLong(tk.nextToken());
           
           e.add(new pair(a,b,c));
           
           g[a].add(new node(b,c));
           g[b].add(new node(a,c));
       }
       
       long tot = dijkstra(s,t);
       
       if(tot < L) {
           System.out.println("NO");
           return;
       }
       
       tot = dijkstra2(s,t);
       
       if(tot > L || path.size()>L-tot) {
           System.out.println("NO");
           return;
       }
       
       tot = L-tot;
       
       long [][] v = new long[n][n];
       for(int i=0; i<path.size()-1; i++) {
           pair pp = path.get(i);
           v[pp.a][pp.b] = v[pp.b][pp.a] = 1;
           tot--;
       }
       if(!path.isEmpty()) {
           pair pp = path.get(path.size()-1);
           v[pp.a][pp.b] = v[pp.b][pp.a] = tot;
       }
       out.append("YES\n");
       for(pair p : e) {
           out.append(p.a).append(" ").append(p.b);
           if(p.c==0) {
               if(v[p.a][p.b]==0) out.append(" ").append(inf).append("\n");
               else out.append(" ").append(v[p.a][p.b]).append("\n");
           } else {
               out.append(" ").append(p.c).append("\n");
           }
       }
       
        System.out.print(out);
    }
    
    static long dijkstra(int s,int t) {
        Queue<node> q = new PriorityQueue<>();
        long [] d = new long[n];
        Arrays.fill(d, inf);
        d[s] = 0;
        q.add(new node(s,0));
        
        while(!q.isEmpty()) {
            node u = q.remove();
            
            if(u.u == t)
                return u.c;
            
            for(node v : g[u.u]) {
                if(d[v.u] > d[u.u]+v.c && v.c!=0) {
                    d[v.u] = d[u.u]+v.c;
                    q.add(new node(v.u,d[v.u]));
                }
            }
        }
        
        return inf;
    }
    
    static long dijkstra2(int s,int t) {
        Queue<node> q = new PriorityQueue<>();
        long [] d = new long[n];
        Arrays.fill(d, inf);
        d[s] = 0;
        q.add(new node(s,0));
        
        while(!q.isEmpty()) {
            node u = q.remove();
            
            if(u.u == t)
                return u.c;
            
            for(node v : g[u.u]) {
                if(d[v.u] > d[u.u]+v.c && v.c!=0) {
                    d[v.u] = d[u.u]+v.c;
                    q.add(new node(v.u,d[v.u]));
                } else if(d[v.u] > d[u.u]+v.c && v.c==0) {
                    d[v.u] = d[u.u];
                    path.add(new pair(u.u,v.u,0));
                    q.add(new node(v.u,d[v.u]));
                }
            }
        }
        
        return inf;
    }
}

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

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