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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.AbstractCollection;
import java.util.Comparator;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public static final long oo = Long.MAX_VALUE >> 4;
        int n;
        int m;
        List<Integer>[] g;
        int L;
        int[] prev;
        int s;
        int t;
        long[] dist;
        HashMap<Long, Long> pairs = new HashMap<>();

        public void solve(int testNumber, FastReader in, PrintWriter out) {
            Debug debug = new Debug();
            n = in.nextInt();
            m = in.nextInt();
            L = in.nextInt();
            s = in.nextInt();
            t = in.nextInt();

            g = new List[n];
            prev = new int[n];
            dist = new long[n];

            for (int i = 0; i < n; ++i) g[i] = new ArrayList<>();

            for (int i = 0; i < m; ++i) {
                int u = in.nextInt();
                int v = in.nextInt();
                int w = in.nextInt();
                g[u].add(v);
                g[v].add(u);

                long key = Math.min(u, v);
                key <<= 32L;
                key |= Math.max(u, v);
                pairs.put(key, (long) w);
            }
            propDij();
//        debug.tr(dist);
            if (dist[t] > L) {
                out.println("NO");
            } else {
                long rem = L;
                int cur = t;
                while (prev[cur] != -1) {
                    int pre = prev[cur];

                    int u = Math.min(cur, pre);
                    int v = Math.max(cur, pre);
                    long key = u;
                    key <<= 32L;
                    key |= v;
                    Long value = pairs.get(key);
                    if (value == null) throw new RuntimeException();
                    if (value != 0) {
                        rem -= value;
                    }
                    cur = pre;
                }
                cur = t;
                while (prev[cur] != -1) {
                    int pre = prev[cur];

                    int u = Math.min(cur, pre);
                    int v = Math.max(cur, pre);
                    long key = u;
                    key <<= 32L;
                    key |= v;
                    Long value = pairs.get(key);
                    if (value == null) throw new RuntimeException();
                    if (value == 0) {
                        value = rem;
                        pairs.put(key, value);
                        break;
                    }
                    cur = pre;
                }
                propDij();
                if (dist[t] != L) {
                    out.println("NO");
                    return;
                }
                out.println("YES");
                for (Long key : pairs.keySet()) {
                    long[] uv = get(key);
                    out.println(uv[0] + " " + uv[1] + " " + pairs.get(key));
                }
            }
        }

        private void propDij() {
            PriorityQueue<Integer> priorityQueue = new PriorityQueue<>(new Comparator<Integer>() {

                public int compare(Integer o1, Integer o2) {
                    return Long.compare(dist[o1], dist[o2]);
                }
            });
            ArrayUtils.fill(prev, -1);
            ArrayUtils.fill(dist, oo);

            dist[s] = 0;
            priorityQueue.add(s);
            while (!priorityQueue.isEmpty()) {
                Integer cur = priorityQueue.poll();
                for (Integer next : g[cur]) {
                    long w = getWeight(cur, next);
                    if (dist[next] > dist[cur] + w) {
                        dist[next] = dist[cur] + w;
                        prev[next] = cur;
                        priorityQueue.remove(next);
                        priorityQueue.add(next);
                    }
                }
            }
        }

        private long[] get(Long key) {
            long u = key >>> 32L;
            long v = key - (u << 32L);
            return new long[]{u, v};
        }

        private long getWeight(int u, int v) {
            long key = Math.min(u, v);
            key <<= 32L;
            key |= Math.max(u, v);
            return pairs.get(key);
        }

    }

    static class Debug {
        PrintWriter out;
        boolean oj;
        boolean system;
        long timeBegin;
        Runtime runtime;

        public Debug(PrintWriter out) {
            oj = System.getProperty("ONLINE_JUDGE") != null;
            this.out = out;
            this.timeBegin = System.currentTimeMillis();
            this.runtime = Runtime.getRuntime();
        }

        public Debug() {
            system = true;
            oj = System.getProperty("ONLINE_JUDGE") != null;
            OutputStream outputStream = System.out;
            this.out = new PrintWriter(outputStream);
            this.timeBegin = System.currentTimeMillis();
            this.runtime = Runtime.getRuntime();
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int pnumChars;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        private int pread() {
            if (pnumChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= pnumChars) {
                curChar = 0;
                try {
                    pnumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (pnumChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = pread();
            while (isSpaceChar(c))
                c = pread();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = pread();
            }
            int res = 0;
            do {
                if (c == ',') {
                    c = pread();
                }
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = pread();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }

    static class ArrayUtils {
        public static void fill(long[] array, long value) {
            Arrays.fill(array, value);
        }

        public static void fill(int[] array, int value) {
            Arrays.fill(array, value);
        }

    }
}

