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

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>

#define FOR(x, a, b) for (int x = a; x <= b; ++x)
#define FOD(x, a, b) for (int x = a; x >= b; --x)
#define REP(x, a, b) for (int x = a; x < b; ++x)
#define ll long long
#define fi first
#define se second
#define DEBUG(X) { cout << #X << " = " << X << endl; }
#define PR(A, n) { cout << #A << " = "; FOR(_, 1, n) cout << A[_] << " "; cout << endl; }
#define PR0(A, n)  { cout << #A << " = "; REP(_, 0, n) cout << A[_] << " "; cout << endl; }

using namespace std;

void Read(int &n)
{
    int sign = 1; n = 0; char c;
    do
    {
        c = getchar();
    } while (!isdigit(c) && c != '-');
    if (c == '-')
    {
        c = getchar();
        sign = -1;
    }
    do
    {
        n = n * 10 + c - 48;
        c = getchar();
    } while (isdigit(c));
    n *= sign;
}

void Read(ll &n)
{
    int sign = 1; n = 0; char c;
    do
    {
        c = getchar();
    } while (!isdigit(c) && c != '-');
    if (c == '-')
    {
        c = getchar();
        sign = -1;
    }
    do
    {
        n = n * 10ll + c - 48;
        c = getchar();
    } while (isdigit(c));
    n *= sign;
}

void Write(int n)
{
    if (n == 0) putchar('0'); else
        if (n < 0) putchar('-'), n = -n;
    char C[30];
    int d = 0;
    while (n)
    {
        C[++d] = (n % 10) + 48;
        n /= 10;
    }
    FOD(i, d, 1) putchar(C[i]);
}

void Write(ll n)
{
    if (n == 0) putchar('0'); else
        if (n < 0) putchar('-'), n = -n;
    char C[30];
    int d = 0;
    while (n)
    {
        C[++d] = (n % 10ll) + 48;
        n /= 10ll;
    }
    FOD(i, d, 1) putchar(C[i]);
}

const int maxn = 1005;
const int maxm = 5e6 + 5;
const ll INFL = 1e18;

typedef pair <int, int> II;
typedef pair <ll, int> LLI;

struct Edge
{
    int u, v, w;
    Edge () {}
    Edge (int u, int v, int w) : u(u), v(v), w(w) {}
} E[maxm];

vector <II> adj[maxn];
int n, m, L, s, t;
int T[maxn];
bool Free[maxm];
ll d[maxn], W[maxm];

ll Pre_Dijkstra()
{
    set <LLI> S;
    FOR(i, 0, n) d[i] = INFL;
    d[s] = 0;
    S.clear();
    S.insert(LLI(0, s));
    while (S.size())
    {
        LLI temp = *S.begin();
        S.erase(S.begin());
        int u = temp.se;
        REP(k, 0, adj[u].size())
        {
            int v = adj[u][k].fi;
            int w = adj[u][k].se;
            if (w == 0) continue;
            if (d[v] > d[u] + (ll)w)
            {
                S.erase(LLI(d[v], v));
                d[v] = d[u] + (ll)w;
                S.insert(LLI(d[v], v));
            }
        }
    }
    return d[t];
}

ll Dijkstra()
{
    set <LLI> S;
    S.clear();
    FOR(i, 0, n) d[i] = INFL;
    d[s] = 0; S.insert(LLI(d[s], s));
    T[s] = 0;
    while (S.size())
    {
        LLI temp = *S.begin();
        S.erase(S.begin());
        int u = temp.se;
        REP(k, 0, adj[u].size())
        {
            int v = adj[u][k].fi;
            int w = adj[u][k].se;
            if (w == 0) w = 1;
            if (d[v] > d[u] + (ll)w)
            {
                S.erase(LLI(d[v], v));
                T[v] = u;
                d[v] = d[u] + (ll)w;
                S.insert(LLI(d[v], v));
            }
        }
    }
    return d[t];

}

int Pow[10];

int Count(int v)
{
    int d = 0;
    while (v) d++, v /= 10;
    return d;
}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif // ONLINE_JUDGE
    Read(n); Read(m); Read(L); Read(s); Read(t);
    //DEBUG(Count(123));
    Pow[0] = 1;
    FOR(i, 1, 9) Pow[i] = Pow[i - 1] * 10;
    s++; t++;
    FOR(i, 1, m)
    {
        int u, v, w;
        Read(u); Read(v); Read(w);
        u++; v++;
        E[i] = Edge(u, v, w);
        if (w == 0)
        {
            Free[u * Pow[Count(v)] + v] = 1;
            Free[v * Pow[Count(u)] + u] = 1;
        }
        adj[u].push_back(II(v, w));
        adj[v].push_back(II(u, w));
    }
    ll SPath1 = Pre_Dijkstra();
   // DEBUG(SPath1);
    if (SPath1 < L) puts("NO"); else
    {
        ll SPath2 = Dijkstra();
       // DEBUG(SPath2);
        ll res = L - SPath2;
        vector <II> L;
        int v = t;
        int EAssign = 0;
        while (T[v] != 0)
        {
            if (Free[T[v] * Pow[Count(v)] + v]) L.push_back(II(T[v], v));
            v = T[v];
        }
        if (res < 0)
        {
            puts("NO");
            return 0;
        }
        if (L.empty())
        {
            if (res == 0)
            {
                puts("YES");
                FOR(i, 1, m)
                {
                    if (E[i].w == 0)
                    {
                        Write(E[i].u - 1); putchar(' '); Write(E[i].v - 1); putchar(' '); Write(100000000000000000);
                        putchar('\n');
                    } else
                    {
                        Write(E[i].u - 1); putchar(' '); Write(E[i].v - 1); putchar(' '); Write(E[i].w);
                        putchar('\n');
                    }
                }
            } else puts("NO");
        } else
        {
            puts("YES");
            REP(i, 0, L.size()) W[L[i].fi * Pow[Count(L[i].se)] + L[i].se] = 1, W[L[i].se * Pow[Count(L[i].fi)] + L[i].fi] = 1;
            W[L[0].fi * Pow[Count(L[0].se)] + L[0].se] = W[L[0].se * Pow[Count(L[0].fi)] + L[0].fi] = res + 1;
           // FOR(i, 1, m) printf("%d %d %d\n", E[i].u, E[i].v, E[i].w);
            FOR(i, 1, m) if (E[i].w == 0)
            {
                int u = E[i].u, v = E[i].v;
                if (W[u * Pow[Count(v)] + v] == 0)
                {
                    Write(E[i].u - 1); putchar(' '); Write(E[i].v - 1); putchar(' '); Write(100000000000000000);
                    putchar('\n');
                } else
                {
                    Write(E[i].u - 1); putchar(' '); Write(E[i].v - 1); putchar(' '); Write(W[u * Pow[Count(v)] + v]);
                    putchar('\n');
                }
            } else
            {
                Write(E[i].u - 1); putchar(' '); Write(E[i].v - 1); putchar(' '); Write(E[i].w);
                putchar('\n');
            }
        }

    }
    return 0;
}
