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.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;

/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            pass System Test!
*/

public class D {
  private static class Task {
    class Edge implements Comparable<Edge> {
      int to;
      long weight;
      Edge(int to, long weight) {
        this.to = to;
        this.weight = weight;
      }
      @Override
      public int compareTo(Edge o) {
        return Long.signum(this.weight - o.weight);
      }
    }

    final long INF = 1000000000000000000L;
    ArrayList<Edge>[] graph;
    void dijkstra(int start, long[] dist, PriorityQueue<Edge> Q) {
      dist[start] = 0;
      Q.add(new Edge(start, 0));
      while (!Q.isEmpty()) {
        Edge cur = Q.poll();
        int v = cur.to;
        long w = cur.weight;
        for (Edge edge : graph[v]) {
          if (dist[edge.to] <= w + edge.weight) continue;
          dist[edge.to] = w + edge.weight;
          Q.add(new Edge(edge.to, dist[edge.to]));
        }
      }
    }

    void solve(FastScanner in, PrintWriter out) {
      int N = in.nextInt();
      int M = in.nextInt();
      int L = in.nextInt();
      int s = in.nextInt();
      int t = in.nextInt();

      long[][] map = new long[N][N];
      for (int i = 0; i < N; i++) {
        Arrays.fill(map[i], INF);
        map[i][i] = 0;
      }
      long[][] input = new long[M][];
      ArrayList<int[]> erased = new ArrayList<>();
      graph = new ArrayList[N];
      for (int i = 0; i < N; i++) {
        graph[i] = new ArrayList<>();
      }
      for (int i = 0; i < M; i++) {
        int u = in.nextInt();
        int v = in.nextInt();
        int w = in.nextInt();
        input[i] = new long[]{u, v, w};
        if (w == 0) {
          erased.add(new int[]{u, v, i});
        } else {
          map[u][v] = w;
          map[v][u] = w;
          graph[u].add(new Edge(v, w));
          graph[v].add(new Edge(u, w));
        }
      }
      PriorityQueue<Edge> Q = new PriorityQueue<>();
      long[] dist = new long[N];
      Arrays.fill(dist, INF);
      dijkstra(s, dist, Q);

      if (dist[t] < L) {
        out.println("NO");
        return;
      }

      boolean ok = false;
      for (int[] uvi : erased) {
        int x = uvi[0];
        int y = uvi[1];
        int i = uvi[2];
        graph[x].add(new Edge(y, 1));
        graph[y].add(new Edge(x, 1));
        Arrays.fill(dist, INF);
        dijkstra(s, dist, Q);
        if (dist[t] <= L) {
          long high = INF;
          long low = 0;
          while (high - low > 1) {
            long mid = (high + low) / 2;
            graph[x].remove(graph[x].size() - 1);
            graph[y].remove(graph[y].size() - 1);
            graph[x].add(new Edge(y, mid));
            graph[y].add(new Edge(x, mid));
            Arrays.fill(dist, INF);
            dijkstra(s, dist, Q);
            if (dist[t] == L) {
              input[i][2] = mid;
              break;
            }
            if (dist[t] < L) {
              low = mid;
            } else {
              high = mid;
            }
          }
          ok = true;
          break;
        } else input[i][2] = 1;
      }
      if (!ok) {
        out.println("NO");
        return;
      }
      out.println("YES");
      for (long[] uvw : input) {
        long u = uvw[0];
        long v = uvw[1];
        long w = uvw[2];
        if (w == 0) w = INF;
        out.println(u + " " + v + " " + w);
      }

    }
  }

  /**
   * ここから下はテンプレートです。
   */
  public static void main(String[] args) {
    OutputStream outputStream = System.out;
    FastScanner in = new FastScanner();
    PrintWriter out = new PrintWriter(outputStream);
    Task solver = new Task();
    solver.solve(in, out);
    out.close();
  }
  private static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int bufferLength = 0;

    private boolean hasNextByte() {
      if (ptr < bufferLength) {
        return true;
      } else {
        ptr = 0;
        try {
          bufferLength = in.read(buffer);
        } catch (IOException e) {
          e.printStackTrace();
        }
        if (bufferLength <= 0) {
          return false;
        }
      }
      return true;
    }

    private int readByte() {
      if (hasNextByte()) return buffer[ptr++];
      else return -1;
    }

    private static boolean isPrintableChar(int c) {
      return 33 <= c && c <= 126;
    }

    private void skipUnprintable() {
      while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
    }

    boolean hasNext() {
      skipUnprintable();
      return hasNextByte();
    }

    public String next() {
      if (!hasNext()) throw new NoSuchElementException();
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while (isPrintableChar(b)) {
        sb.appendCodePoint(b);
        b = readByte();
      }
      return sb.toString();
    }

    long nextLong() {
      if (!hasNext()) throw new NoSuchElementException();
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
        minus = true;
        b = readByte();
      }
      if (b < '0' || '9' < b) {
        throw new NumberFormatException();
      }
      while (true) {
        if ('0' <= b && b <= '9') {
          n *= 10;
          n += b - '0';
        } else if (b == -1 || !isPrintableChar(b)) {
          return minus ? -n : n;
        } else {
          throw new NumberFormatException();
        }
        b = readByte();
      }
    }

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

    double[] nextDoubleArray(int n) {
      double[] array = new double[n];
      for (int i = 0; i < n; i++) {
        array[i] = nextDouble();
      }
      return array;
    }

    double[][] nextDoubleMap(int n, int m) {
      double[][] map = new double[n][];
      for (int i = 0; i < n; i++) {
        map[i] = nextDoubleArray(m);
      }
      return map;
    }

    public int nextInt() {
      return (int) nextLong();
    }

    public int[] nextIntArray(int n) {
      int[] array = new int[n];
      for (int i = 0; i < n; i++) array[i] = nextInt();
      return array;
    }

    public long[] nextLongArray(int n) {
      long[] array = new long[n];
      for (int i = 0; i < n; i++) array[i] = nextLong();
      return array;
    }

    public String[] nextStringArray(int n) {
      String[] array = new String[n];
      for (int i = 0; i < n; i++) array[i] = next();
      return array;
    }

    public char[][] nextCharMap(int n) {
      char[][] array = new char[n][];
      for (int i = 0; i < n; i++) array[i] = next().toCharArray();
      return array;
    }

    public int[][] nextIntMap(int n, int m) {
      int[][] map = new int[n][];
      for (int i = 0; i < n; i++) {
        map[i] = nextIntArray(m);
      }
      return map;
    }
  }
}