#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
const LL N = 100050;

LL dt[N][3], pre[N];
LL n, m, L, s, t, head[N*2], cnt, dis[N*2];
struct edge{LL next,to,from; LL w;} e[N*6];
bool inq[N*2];
bool ok[1005][1005];

struct node
{
    LL dis;
	LL id;
    node(){}
    node(LL _,LL __){dis = _; id = __;}
    friend bool operator < (node a,node b)
    {
        return a.dis > b.dis;
    }
};

void link(LL u,LL v,LL w)
{
    ++ cnt;
    e[cnt].next = head[u];
    e[cnt].to = v;
    e[cnt].w = w;
    e[cnt].from = u;
    head[u] = cnt;
    ++ cnt;
    e[cnt].next = head[v];
    e[cnt].to = u;
    e[cnt].w = w;
    e[cnt].from = v;
    head[v] = cnt;
}

LL dij(LL u,LL v)
{
    priority_queue<node> q;
    node ahead, next;
    LL i;

    q.push(node(0,u));
    for(i = 0; i < n; ++ i) dis[i] = 1LL<<61;
    dis[u] = 0; inq[u] = true;
    while(!q.empty())
    {
        ahead = q.top(); q.pop();
        inq[ahead.id] = false;
        for(i = head[ahead.id]; i ; i = e[i].next)
        {
            next.id = e[i].to;
            if(dis[next.id] > dis[ahead.id] + e[i].w)
            {
                dis[next.id] = dis[ahead.id] + e[i].w;
                next.dis = dis[next.id];
                pre[next.id] = i;
                if(!inq[next.id]) q.push(next), inq[next.id] = true;
            }
        }
    }
    return dis[v];
}

int main()
{
    LL i, x, y, z, Qans;
    scanf("%I64d%I64d%I64d%I64d%I64d",&n,&m,&L,&s,&t);
    for(i = 1; i <= m; ++ i)
    {
        scanf("%I64d%I64d%I64d",&x,&y,&z);
        dt[i][0] = x; dt[i][1] = y; dt[i][2] = z;
        if(!z) ok[x][y] = ok[y][x] = true;
		if(z) link(x,y,z);
    }
    Qans = dij(s,t);
    if(Qans < L) {puts("NO"); return 0;}
    if(Qans == L)
    {
    	puts("YES");
    	for(i = 1; i <= m; ++ i)
    		if(dt[i][2] == 0) printf("%I64d %I64d 10000000000000000\n",dt[i][0],dt[i][1]);
    		else printf("%I64d %I64d %I64d\n",dt[i][0],dt[i][1],dt[i][2]);
    	return 0;
	}
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0) link(dt[i][0],dt[i][1],1);
	Qans = dij(s,t);
	if(Qans > L) {puts("NO"); return 0;}
	i = pre[t];
	while(e[i].w != 1 || !ok[e[i].from][e[i].to]) i = pre[e[i].from];
	x = i; y = 1;
	while(e[i].from != s) {i = pre[e[i].from]; y += (e[i].w == 1 && ok[e[i].from][e[i].to]);}
	y += (e[i].w == 1 && ok[e[i].from][e[i].to]);
	puts("YES");
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0 && ((dt[i][0] == e[x].from && dt[i][1] == e[x].to) || (dt[i][0] == e[x].to && dt[i][1] == e[x].from)))
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], L - Qans + 1);
		else
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], dt[i][2] == 0?1:dt[i][2]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
const LL N = 100050;

LL dt[N][3], pre[N];
LL n, m, L, s, t, head[N*2], cnt, dis[N*2];
struct edge{LL next,to,from; LL w;} e[N*6];
bool inq[N*2];
bool ok[1005][1005];

struct node
{
    LL dis;
	LL id;
    node(){}
    node(LL _,LL __){dis = _; id = __;}
    friend bool operator < (node a,node b)
    {
        return a.dis > b.dis;
    }
};

void link(LL u,LL v,LL w)
{
    ++ cnt;
    e[cnt].next = head[u];
    e[cnt].to = v;
    e[cnt].w = w;
    e[cnt].from = u;
    head[u] = cnt;
    ++ cnt;
    e[cnt].next = head[v];
    e[cnt].to = u;
    e[cnt].w = w;
    e[cnt].from = v;
    head[v] = cnt;
}

LL dij(LL u,LL v)
{
    priority_queue<node> q;
    node ahead, next;
    LL i;

    q.push(node(0,u));
    for(i = 0; i < n; ++ i) dis[i] = 1e15;
    dis[u] = 0; inq[u] = true;
    while(!q.empty())
    {
        ahead = q.top(); q.pop();
        inq[ahead.id] = false;
        for(i = head[ahead.id]; i ; i = e[i].next)
        {
            next.id = e[i].to;
            if(dis[next.id] > dis[ahead.id] + e[i].w)
            {
                dis[next.id] = dis[ahead.id] + e[i].w;
                next.dis = dis[next.id];
                pre[next.id] = i;
                if(!inq[next.id]) q.push(next), inq[next.id] = true;
            }
        }
    }
    return dis[v];
}

int main()
{
    LL i, x, y, z, Qans;
    scanf("%I64d%I64d%I64d%I64d%I64d",&n,&m,&L,&s,&t);
    for(i = 1; i <= m; ++ i)
    {
        scanf("%I64d%I64d%I64d",&x,&y,&z);
        dt[i][0] = x; dt[i][1] = y; dt[i][2] = z;
        if(!z) ok[x][y] = ok[y][x] = true;
		if(z) link(x,y,z);
    }
    Qans = dij(s,t);
    if(Qans < L) {puts("NO"); return 0;}
    if(Qans == L)
    {
    	puts("YES");
    	for(i = 1; i <= m; ++ i)
    		if(dt[i][2] == 0) printf("%I64d %I64d 10000000000000000\n",dt[i][0],dt[i][1]);
    		else printf("%I64d %I64d %I64d\n",dt[i][0],dt[i][1],dt[i][2]);
    	return 0;
	}
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0) link(dt[i][0],dt[i][1],1);
	Qans = dij(s,t);
	if(Qans > L) {puts("NO"); return 0;}
	i = pre[t];
	while(e[i].w != 1 || !ok[e[i].from][e[i].to]) i = pre[e[i].from];
	x = i; y = 0;
	while(e[i].from != s) {y += (e[i].w == 1 && ok[e[i].from][e[i].to]); i = pre[e[i].from]; }
	y += (e[i].w == 1 && ok[e[i].from][e[i].to]);
	puts("YES");
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0 && ((dt[i][0] == e[x].from && dt[i][1] == e[x].to) || (dt[i][0] == e[x].to && dt[i][1] == e[x].from)))
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], L - Qans + 1);
		else
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], dt[i][2] == 0?1:dt[i][2]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
const LL N = 100050;

LL dt[N][3], pre[N];
LL n, m, L, s, t, head[N*2], cnt, dis[N*2];
struct edge{LL next,to,from; LL w;} e[N*6];
bool inq[N*2];
bool ok[1005][1005];

struct node
{
    LL dis;
	LL id;
    node(){}
    node(LL _,LL __){dis = _; id = __;}
    friend bool operator < (node a,node b)
    {
        return a.dis > b.dis;
    }
};

void link(LL u,LL v,LL w)
{
    ++ cnt;
    e[cnt].next = head[u];
    e[cnt].to = v;
    e[cnt].w = w;
    e[cnt].from = u;
    head[u] = cnt;
    ++ cnt;
    e[cnt].next = head[v];
    e[cnt].to = u;
    e[cnt].w = w;
    e[cnt].from = v;
    head[v] = cnt;
}

LL dij(LL u,LL v)
{
    priority_queue<node> q;
    node ahead, next;
    LL i;

    q.push(node(0,u));
    for(i = 0; i < n; ++ i) dis[i] = 1000000000000000000LL;
    dis[u] = 0; inq[u] = true;
    while(!q.empty())
    {
        ahead = q.top(); q.pop();
        inq[ahead.id] = false;
        for(i = head[ahead.id]; i ; i = e[i].next)
        {
            next.id = e[i].to;
            if(dis[next.id] > dis[ahead.id] + e[i].w)
            {
                dis[next.id] = dis[ahead.id] + e[i].w;
                next.dis = dis[next.id];
                pre[next.id] = i;
                if(!inq[next.id]) q.push(next), inq[next.id] = true;
            }
        }
    }
    return dis[v];
}

int main()
{
    LL i, x, y, z, Qans;
    scanf("%I64d%I64d%I64d%I64d%I64d",&n,&m,&L,&s,&t);
    for(i = 1; i <= m; ++ i)
    {
        scanf("%I64d%I64d%I64d",&x,&y,&z);
        dt[i][0] = x; dt[i][1] = y; dt[i][2] = z;
        if(!z) ok[x][y] = ok[y][x] = true;
		if(z) link(x,y,z);
    }
    Qans = dij(s,t);
    if(Qans < L) {puts("NO"); return 0;}
    if(Qans == L)
    {
    	puts("YES");
    	for(i = 1; i <= m; ++ i)
    		if(dt[i][2] == 0) printf("%I64d %I64d 10000000000000000\n",dt[i][0],dt[i][1]);
    		else printf("%I64d %I64d %I64d\n",dt[i][0],dt[i][1],dt[i][2]);
    	return 0;
	}
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0) link(dt[i][0],dt[i][1],1);
	Qans = dij(s,t);
	if(Qans > L) {puts("NO"); return 0;}
	i = pre[t];
	while(e[i].w != 1 || !ok[e[i].from][e[i].to]) i = pre[e[i].from];
	x = i; y = 0;
	while(e[i].from != s) {y += (e[i].w == 1 && ok[e[i].from][e[i].to]); if((e[i].w == 1 && ok[e[i].from][e[i].to])) x = i; i = pre[e[i].from]; }
	y += (e[i].w == 1 && ok[e[i].from][e[i].to]);
	puts("YES");
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0 && ((dt[i][0] == e[x].from && dt[i][1] == e[x].to) || (dt[i][0] == e[x].to && dt[i][1] == e[x].from)))
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], L - Qans + 1);
		else
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], dt[i][2] == 0?1:dt[i][2]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
const LL N = 100050;
const LL inf = 1000000000000000000LL;

LL dt[N][3], pre[N];
LL n, m, L, s, t, head[N*2], cnt, dis[N*2];
struct edge{LL next,to,w;} e[N*6];
bool inq[N*2];

struct node
{
    LL dis;
	LL id;
    node(){}
    node(LL _,LL __){dis = _; id = __;}
    friend bool operator < (node a,node b)
    {
        return a.dis > b.dis;
    }
};

void link(LL u,LL v,LL w)
{
    ++ cnt;
    e[cnt].next = head[u];
    e[cnt].to = v;
    e[cnt].w = w;
    head[u] = cnt;
    ++ cnt;
    e[cnt].next = head[v];
    e[cnt].to = u;
    e[cnt].w = w;
    head[v] = cnt;
}

LL dij(LL u,LL v)
{
    priority_queue<node> q;
    node ahead, next;
    LL i;

    q.push(node(0,u));
    for(i = 0; i < n; ++ i) dis[i] = inf;
    dis[u] = 0; inq[u] = true;
    while(!q.empty())
    {
        ahead = q.top(); q.pop();
        inq[ahead.id] = false;
        for(i = head[ahead.id]; i ; i = e[i].next)
        {
            next.id = e[i].to;
            if(dis[next.id] > dis[ahead.id] + e[i].w)
            {
                dis[next.id] = dis[ahead.id] + e[i].w;
                next.dis = dis[next.id];
                if(!inq[next.id]) {q.push(next), inq[next.id] = true;}
            }
        }
    }
    return dis[v];
}

int main()
{
    LL i, x, y, z, Qans;
    scanf("%I64d%I64d%I64d%I64d%I64d",&n,&m,&L,&s,&t);
    for(i = 1; i <= m; ++ i)
    {
        scanf("%I64d%I64d%I64d",&x,&y,&z);
        dt[i][0] = x; dt[i][1] = y; dt[i][2] = z;
		if(z) link(x,y,z);
    }
    Qans = dij(s,t);
    if(Qans < L) {puts("NO"); return 0;}
    if(Qans == L)
    {
    	puts("YES");
    	for(i = 1; i <= m; ++ i)
    		if(dt[i][2] == 0) printf("%I64d %I64d 10000000000000000\n",dt[i][0],dt[i][1]);
    		else printf("%I64d %I64d %I64d\n",dt[i][0],dt[i][1],dt[i][2]);
    	return 0;
	}
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0) link(dt[i][0],dt[i][1],1);
	Qans = dij(s,t);
	if(Qans > L) {puts("NO"); return 0;}
	cnt = 0;
	memset(head,0,sizeof(head));
	for(i = 1; i <= m; ++ i) if(dt[i][2]) link(dt[i][0],dt[i][1],dt[i][2]);
	x = -1;
	for(i = 1; i <= m; ++ i)
		if(!dt[i][2])
		{
			link(dt[i][0],dt[i][1],1);
			dt[i][2] = 1;
			Qans = dij(s,t);
			if(Qans <= L) {x = i; dt[i][2] = L - Qans + 1; break;}
		}
	if(x == -1){puts("NO"); return 0;}
	puts("YES");
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0)
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], inf);
		else
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], dt[i][2] == 0?1:dt[i][2]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
const LL N = 100050;
const LL inf = 1000000000000000000LL;

LL dt[N][3], pre[N];
LL n, m, L, s, t, head[N*2], cnt, dis[N*2];
struct edge{LL next,to,w;} e[N*6];
bool inq[N*2];

struct node
{
    LL dis;
	LL id;
    node(){}
    node(LL _,LL __){dis = _; id = __;}
    friend bool operator < (node a,node b)
    {
        return a.dis > b.dis;
    }
};

void link(LL u,LL v,LL w)
{
    ++ cnt;
    e[cnt].next = head[u];
    e[cnt].to = v;
    e[cnt].w = w;
    head[u] = cnt;
    ++ cnt;
    e[cnt].next = head[v];
    e[cnt].to = u;
    e[cnt].w = w;
    head[v] = cnt;
}

LL dij(LL u,LL v)
{
    priority_queue<node> q;
    node ahead, next;
    LL i;

    q.push(node(0,u));
    for(i = 0; i < n; ++ i) dis[i] = inf;
    dis[u] = 0; inq[u] = true;
    while(!q.empty())
    {
        ahead = q.top(); q.pop();
        inq[ahead.id] = false;
        for(i = head[ahead.id]; i ; i = e[i].next)
        {
            next.id = e[i].to;
            if(dis[next.id] > dis[ahead.id] + e[i].w)
            {
                dis[next.id] = dis[ahead.id] + e[i].w;
                next.dis = dis[next.id];
                if(!inq[next.id]) {q.push(next), inq[next.id] = true;}
            }
        }
    }
    return dis[v];
}

int main()
{
    LL i, x, y, z, Qans;
    scanf("%I64d%I64d%I64d%I64d%I64d",&n,&m,&L,&s,&t);
    for(i = 1; i <= m; ++ i)
    {
        scanf("%I64d%I64d%I64d",&x,&y,&z);
        dt[i][0] = x; dt[i][1] = y; dt[i][2] = z;
		if(z) link(x,y,z);
    }
    Qans = dij(s,t);
    if(Qans < L) {puts("NO"); return 0;}
    if(Qans == L)
    {
    	puts("YES");
    	for(i = 1; i <= m; ++ i)
    		if(dt[i][2] == 0) printf("%I64d %I64d 10000000000000000\n",dt[i][0],dt[i][1]);
    		else printf("%I64d %I64d %I64d\n",dt[i][0],dt[i][1],dt[i][2]);
    	return 0;
	}
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0) link(dt[i][0],dt[i][1],1);
	Qans = dij(s,t);
	if(Qans > L) {puts("NO"); return 0;}
	cnt = 0;
	memset(head,0,sizeof(head));
	for(i = 1; i <= m; ++ i) if(dt[i][2]) link(dt[i][0],dt[i][1],dt[i][2]);
	x = -1;
	for(i = 1; i <= m; ++ i)
		if(!dt[i][2])
		{
			link(dt[i][0],dt[i][1],1);
			dt[i][2] = 1;
			Qans = dij(s,t);
			if(Qans <= L) {x = i; break;}
		}
	if(x == -1){puts("NO"); return 0;}
	puts("YES");
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0)
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], i == x ? L - Qans + 1 : inf);
		else
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], dt[i][2] == 0?1:dt[i][2]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
const LL N = 100050;

LL dt[N][3], pre[N];
LL n, m, L, s, t, head[N*2], cnt, dis[N*2];
struct edge{LL next,to,from; LL w;} e[N*6];
bool inq[N*2];
bool ok[1005][1005];

struct node
{
    LL dis;
	LL id;
    node(){}
    node(LL _,LL __){dis = _; id = __;}
    friend bool operator < (node a,node b)
    {
        return a.dis > b.dis;
    }
};

void link(LL u,LL v,LL w)
{
    ++ cnt;
    e[cnt].next = head[u];
    e[cnt].to = v;
    e[cnt].w = w;
    e[cnt].from = u;
    head[u] = cnt;
    ++ cnt;
    e[cnt].next = head[v];
    e[cnt].to = u;
    e[cnt].w = w;
    e[cnt].from = v;
    head[v] = cnt;
}

LL dij(LL u,LL v)
{
    priority_queue<node> q;
    node ahead, next;
    LL i;

    q.push(node(0,u));
    for(i = 0; i < n; ++ i) dis[i] = 1e15;
    dis[u] = 0; inq[u] = true;
    while(!q.empty())
    {
        ahead = q.top(); q.pop();
        inq[ahead.id] = false;
        for(i = head[ahead.id]; i ; i = e[i].next)
        {
            next.id = e[i].to;
            if(dis[next.id] > dis[ahead.id] + e[i].w)
            {
                dis[next.id] = dis[ahead.id] + e[i].w;
                next.dis = dis[next.id];
                pre[next.id] = i;
                if(!inq[next.id]) q.push(next), inq[next.id] = true;
            }
        }
    }
    return dis[v];
}

int main()
{
    LL i, x, y, z, Qans;
    scanf("%I64d%I64d%I64d%I64d%I64d",&n,&m,&L,&s,&t);
    for(i = 1; i <= m; ++ i)
    {
        scanf("%I64d%I64d%I64d",&x,&y,&z);
        dt[i][0] = x; dt[i][1] = y; dt[i][2] = z;
        if(!z) ok[x][y] = ok[y][x] = true;
		if(z) link(x,y,z);
    }
    Qans = dij(s,t);
    if(Qans < L) {puts("NO"); return 0;}
    if(Qans == L)
    {
    	puts("YES");
    	for(i = 1; i <= m; ++ i)
    		if(dt[i][2] == 0) printf("%I64d %I64d 10000000000000000\n",dt[i][0],dt[i][1]);
    		else printf("%I64d %I64d %I64d\n",dt[i][0],dt[i][1],dt[i][2]);
    	return 0;
	}
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0) link(dt[i][0],dt[i][1],1);
	Qans = dij(s,t);
	if(Qans > L) {puts("NO"); return 0;}
	i = pre[t];
	while(e[i].w != 1 || !ok[e[i].from][e[i].to]) i = pre[e[i].from];
	x = i; y = 0;
	assert(x != 0);
	while(e[i].from != s) {y += (e[i].w == 1 && ok[e[i].from][e[i].to]); i = pre[e[i].from]; }
	y += (e[i].w == 1 && ok[e[i].from][e[i].to]);
	puts("YES");
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0 && ((dt[i][0] == e[x].from && dt[i][1] == e[x].to) || (dt[i][0] == e[x].to && dt[i][1] == e[x].from)))
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], L - Qans + 1);
		else
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], dt[i][2] == 0?1:dt[i][2]);
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int N = 1001;
const int M = 10001;
const ll INF = ll(1e18);

vector<ii> adj[N];
vector<int> adj2[N];
int L[M]; int R[M];
ll d1[N];
ll d2[N];
int par[N];
ll dist[N][N];

int n, m, l, s, e;

void dijkstra()
{
	d1[s] = 0;
	priority_queue<ii, vector<ii>, greater<ii> > pq;
	pq.push(ii(0, s));
	int cnt = 0;
	while(!pq.empty())
	{
		cnt++;
		int u = pq.top().se; ll d = pq.top().fi; pq.pop();
		for(int i = 0; i < adj[u].size(); i++)
		{
			int v = adj[u][i].fi; ll w = adj[u][i].se;
			if(d + w < d1[v])
			{
				d1[v] = d + w;
				pq.push(ii(d1[v], v));
			}
		}
	}
}

bool dijkstra2()
{
	d2[s] = 0;
	priority_queue<ii, vector<ii>, greater<ii> > pq;
	pq.push(ii(0, s));
	while(!pq.empty())
	{
		int u = pq.top().se; ll d = pq.top().fi; pq.pop();
		for(int i = 0; i < adj2[u].size(); i++)
		{
			int v = adj2[u][i]; ll w = dist[u][v];
			if(d + abs(w) < d2[v])
			{
				d2[v] = d + abs(w);
				par[v] = u;
				pq.push(ii(d2[v], v));
			}
		}
	}
	if(d2[e] > l) return false;
	int cur = e;
	while(cur != s)
	{
		int p = par[cur];
		if(dist[p][cur] < 0)
		{
			dist[p][cur] = -2; dist[cur][p] = -2;
		}
		cur = par[cur];
	}
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			if(dist[i][j] == -1)
			{
				dist[i][j] = INF;
			}
		}
	}
	cur = e;
	while(cur != s)
	{
		int p = par[cur];
		if(dist[p][cur] < 0)
		{
			dist[p][cur] = -1; dist[cur][p] = -1;
		}
		cur = par[cur];
	}
	return true;
}

void print()
{
	cout << "YES\n";
	for(int i = 0; i < m; i++)
	{
		int u = L[i]; int v = R[i];
		ll d = dist[u][v];
		if(d < 0) d = -d;
		cout << u << ' ' << v << ' ' << d << '\n';
	}
}

bool relax()
{
	for(int i = 0; i < n; i++) d2[i] = INF;
	memset(par, -1, sizeof(par)); //shouldn't be neccesary
	d2[s] = 0;
	priority_queue<ii, vector<ii>, greater<ii> > pq;
	pq.push(ii(0, s));
	while(!pq.empty())
	{
		int u = pq.top().se; ll d = pq.top().fi; pq.pop();
		for(int i = 0; i < adj2[u].size(); i++)
		{
			int v = adj2[u][i]; ll w = dist[u][v];
			if(d + abs(w) < d2[v])
			{
				d2[v] = d + abs(w);
				par[v] = u;
				pq.push(ii(d2[v], v));
			}
		}
	}
	//cerr << d2[e] << '\n';
	if(d2[e] == l) return true;
	int cur = e; bool meet = false;
	while(cur != s)
	{
		int p = par[cur];
		if(!meet && dist[p][cur] < 0)
		{
			ll d = abs(dist[p][cur]);
			dist[p][cur] = d + l - d2[e];
			dist[cur][p] = d + l - d2[e];
			//cerr << d << endl;
			meet = true;
		}
		if(meet) break;
		cur = par[cur];
	}
	return false;
}

int dist1[N][N];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m >> l >> s >> e;
	memset(dist1, -1, sizeof(dist1));
	for(int i = 0; i < m; i++)
	{
		int u, v, w; cin >> u >> v >> w;
		if(w > 0)
		{
			adj[u].pb(ii(v, w)); adj[v].pb(ii(u, w));
			adj2[u].pb(v); adj2[v].pb(u);
			dist1[u][v] = w; dist1[v][u] = w;
			dist[u][v] = w; dist[v][u] = w;
		}
		else
		{
			adj2[u].pb(v); adj2[v].pb(u);
			dist[u][v] = -1; dist[v][u] = -1;
		}
		L[i] = u; R[i] = v;
	}
	for(int i = 0; i < n; i++)
	{
		d1[i] = INF; d2[i] = INF;
	}
	dijkstra(); //cerr << d1[e] << '\n';
	if(d1[e] < l)
	{
		cout << "NO\n";
		return 0;
	}
	if(d1[e] == l)
	{
		cout << "YES\n";
		for(int i = 0; i < m; i++)
		{
			int u = L[i]; int v = R[i];
			ll d = dist1[u][v];
			if(d <= 0) d = INF;
			cout << u << ' ' << v << ' ' << d << '\n';
		}
		return 0;
	}
	bool tmp = dijkstra2();
	if(!tmp)
	{
		cout << "NO\n";
		return 0;
	}
	//cerr << d2[e] << '\n';
	int cnt = 0;
	while(!relax())
	{
		relax(); cnt++;
	}
	print();
}


#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 dist[maxn][maxn];

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;
            if (dist[u][v] == -1) continue;
            int w = abs(dist[u][v]);
            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 = abs(dist[u][v]);
            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));
            }
        }
    }
    int v = t;
    while (T[v] != 0)
    {
        if (dist[T[v]][v] < 0)
        {
            dist[T[v]][v] = -2;
            dist[v][T[v]] = -2;
        }
        v = T[v];
    }
    FOR(i, 1, n)
     FOR(j, 1, n) if (dist[i][j] == -1) dist[i][j] = INFL;
    FOR(i, 1, n)
     FOR(j, 1, n) if (dist[i][j] == -2) dist[i][j] = -1;
    return d[t];

}

int Pow[10];

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

bool Relax()
{
    set <LLI> S;
    S.clear();
    FOR(i, 1, n) d[i] = INFL;
    d[s] = 0;
    T[s] = 0;
    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;
            ll w = abs(dist[u][v]);
            if (d[v] > d[u] + w)
            {
                S.erase(LLI(d[v], v));
                d[v] = d[u] + w;
                T[v] = u;
                S.insert(LLI(d[v], v));
            }
        }
    }
    if (d[t] == L) return 1;
    int v = t;
    bool meet = 0;
    while (T[v] != 0)
    {
        int u = T[v];
        if (!meet && dist[u][v] < 0)
        {
            dist[u][v] = abs(dist[u][v]) + L - d[t];
            dist[v][u] = abs(dist[v][u]) + L - d[t];
            meet = 1;
        }
        if (meet) break;
        v = T[v];
    }
    return 0;
}

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);
        dist[u][v] = w;
        dist[v][u] = w;
        if (w == 0)
        {
            Free[u * Pow[Count(v)] + v] = 1;
            Free[v * Pow[Count(u)] + u] = 1;
            dist[u][v] = -1;
            dist[v][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");
        return 0;
    }
    if (SPath1 == L)
    {
        puts("YES");
        FOR(i, 1, m)
        {
            if (E[i].w == 0) E[i].w = INFL;
            Write(E[i].u - 1); putchar(' '); Write(E[i].v - 1); putchar(' '); Write(E[i].w);
            putchar('\n');
        }
        return 0;
    }
    ll SPath2 = Dijkstra();
  //  DEBUG(SPath2);
    if (SPath2 > L)
    {
        puts("NO");
        return 0;
    }
    bool k = Relax();
    while (!k) k = Relax();
    FOR(i, 1, m)
    {
        Write(E[i].u - 1); putchar(' '); Write(E[i].v - 1); putchar(' '); Write(abs(dist[E[i].u][E[i].v]));
        putchar('\n');
    }
    return 0;
}


#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 = 1e4 + 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[maxn];

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 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);
    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 * 10 + v] = 1;
            Free[v * 10 + v] = 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] * 10 + 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 * 10 + L[i].se] = 1, W[L[i].se * 10 + L[i].fi] = 1;
            W[L[0].fi * 10 + L[0].se] = W[L[0].se * 10 + 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 * 10 + v] == 0 && W[v * 10 + u] == 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 * 10 + v]);
                    putchar('\n');
                }
            } else
            {
                Write(E[i].u - 1); putchar(' '); Write(E[i].v - 1); putchar(' '); Write(E[i].w);
                putchar('\n');
            }
        }

    }
}


#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 = 1e5 + 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 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);
    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 * 10 + v] = 1;
            Free[v * 10 + 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] * 10 + 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 * 10 + L[i].se] = 1, W[L[i].se * 10 + L[i].fi] = 1;
            W[L[0].fi * 10 + L[0].se] = W[L[0].se * 10 + 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 * 10 + v] == 0 && W[v * 10 + u] == 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 * 10 + v]);
                    putchar('\n');
                }
            } else
            {
                Write(E[i].u - 1); putchar(' '); Write(E[i].v - 1); putchar(' '); Write(E[i].w);
                putchar('\n');
            }
        }

    }
}


#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 = 1e5 + 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;
}


#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 = 1e4 + 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[maxn];

ll Pre_Dijkstra()
{
    set <LLI> S;
    FOR(i, 1, 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, 1, n) d[i] = INFL;
    d[s] = 0; S.insert(LLI(d[s], s));
    T[s] = -1;
    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 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);
    FOR(i, 1, m)
    {
        int u, v, w;
        Read(u); Read(v); Read(w);
        E[i] = Edge(u, v, w);
        if (w == 0)
        {
            Free[(u + 1) * 10 + (v + 1)] = 1;
            Free[(v + 1) * 10 + (u + 1)] = 1;
        }
        adj[u].push_back(II(v, w));
        adj[v].push_back(II(u, w));
    }
    ll SPath1 = Pre_Dijkstra();
    if (SPath1 < L) puts("NO"); else
    {
        ll SPath2 = Dijkstra();
        ll res = L - SPath2;
        int v = t;
        int EAssign = 0;
        vector <II> L;
        while (T[v] != -1)
        {
            if (Free[(T[v] + 1) * 10 + v + 1]) L.push_back(II(T[v] + 1, v + 1));
            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); putchar(' '); Write(E[i].v); putchar(' '); Write(100000000000000000);
                        putchar('\n');
                    } else
                    {
                        Write(E[i].u); putchar(' '); Write(E[i].v); putchar(' '); Write(E[i].w);
                        putchar('\n');
                    }
                }
            } else puts("NO");
        } else
        {
            puts("YES");
            REP(i, 0, L.size()) W[L[i].fi * 10 + L[i].se] = 1, W[L[i].se * 10 + L[i].fi] = 1;
            W[L[0].fi * 10 + L[0].se] = W[L[0].se * 10 + 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 + 1, v = E[i].v + 1;
                if (W[u * 10 + v] == 0 && W[v * 10 + u] == 0)
                {
                    Write(E[i].u); putchar(' '); Write(E[i].v); putchar(' '); Write(100000000000000000);
                    putchar('\n');
                } else
                {
                    Write(E[i].u); putchar(' '); Write(E[i].v); putchar(' '); Write(W[u * 10 + v]);
                    putchar('\n');
                }
            } else
            {
                Write(E[i].u); putchar(' '); Write(E[i].v); putchar(' '); Write(E[i].w);
                putchar('\n');
            }
        }

    }
}


#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() - 1) 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;
            int i = L.size() - 1;
            W[L[i].fi * Pow[Count(L[i].se)] + L[i].se] = W[L[i].se * Pow[Count(L[i].fi)] + L[i].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;
}


#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;
}


#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 = 1e4 + 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[maxn];

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] = -1;
    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 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);
    FOR(i, 1, m)
    {
        int u, v, w;
        Read(u); Read(v); Read(w);
        E[i] = Edge(u, v, w);
        if (w == 0)
        {
            Free[(u + 1) * 10 + (v + 1)] = 1;
            Free[(v + 1) * 10 + (u + 1)] = 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();
        ll res = L - SPath2;
        int v = t;
        int EAssign = 0;
        vector <II> L;
        while (T[v] != -1)
        {
            if (Free[(T[v] + 1) * 10 + v + 1]) L.push_back(II(T[v] + 1, v + 1));
            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); putchar(' '); Write(E[i].v); putchar(' '); Write(100000000000000000);
                        putchar('\n');
                    } else
                    {
                        Write(E[i].u); putchar(' '); Write(E[i].v); putchar(' '); Write(E[i].w);
                        putchar('\n');
                    }
                }
            } else puts("NO");
        } else
        {
            puts("YES");
            REP(i, 0, L.size()) W[L[i].fi * 10 + L[i].se] = 1, W[L[i].se * 10 + L[i].fi] = 1;
            W[L[0].fi * 10 + L[0].se] = W[L[0].se * 10 + 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 + 1, v = E[i].v + 1;
                if (W[u * 10 + v] == 0 && W[v * 10 + u] == 0)
                {
                    Write(E[i].u); putchar(' '); Write(E[i].v); putchar(' '); Write(100000000000000000);
                    putchar('\n');
                } else
                {
                    Write(E[i].u); putchar(' '); Write(E[i].v); putchar(' '); Write(W[u * 10 + v]);
                    putchar('\n');
                }
            } else
            {
                Write(E[i].u); putchar(' '); Write(E[i].v); putchar(' '); Write(E[i].w);
                putchar('\n');
            }
        }

    }
}


#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 dist[maxn][maxn];

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;
            if (dist[u][v] == -1) continue;
            int w = abs(dist[u][v]);
            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 = abs(dist[u][v]);
            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));
            }
        }
    }
    int v = t;
    while (T[v] != 0)
    {
        if (dist[T[v]][v] < 0)
        {
            dist[T[v]][v] = -2;
            dist[v][T[v]] = -2;
        }
        v = T[v];
    }
    FOR(i, 1, n)
     FOR(j, 1, n) if (dist[i][j] == -1) dist[i][j] = INFL;
    FOR(i, 1, n)
     FOR(j, 1, n) if (dist[i][j] == -2) dist[i][j] = -1;
    return d[t];

}

int Pow[10];

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

bool Relax()
{
    set <LLI> S;
    S.clear();
    FOR(i, 1, n) d[i] = INFL;
    d[s] = 0;
    T[s] = 0;
    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;
            ll w = abs(dist[u][v]);
            if (d[v] > d[u] + w)
            {
                S.erase(LLI(d[v], v));
                d[v] = d[u] + w;
                T[v] = u;
                S.insert(LLI(d[v], v));
            }
        }
    }
    if (d[t] == L) return 1;
    int v = t;
    bool meet = 0;
    while (T[v] != 0)
    {
        int u = T[v];
        if (!meet && dist[u][v] < 0)
        {
            dist[u][v] = abs(dist[u][v]) + L - d[t];
            dist[v][u] = abs(dist[v][u]) + L - d[t];
            meet = 1;
        }
        if (meet) break;
        v = T[v];
    }
    return 0;
}

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);
        dist[u][v] = w;
        dist[v][u] = w;
        if (w == 0)
        {
            Free[u * Pow[Count(v)] + v] = 1;
            Free[v * Pow[Count(u)] + u] = 1;
            dist[u][v] = -1;
            dist[v][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");
        return 0;
    }
    if (SPath1 == L)
    {
        puts("YES");
        FOR(i, 1, m)
        {
            if (E[i].w == 0) E[i].w = INFL;
            Write(E[i].u - 1); putchar(' '); Write(E[i].v - 1); putchar(' '); Write(E[i].w);
            putchar('\n');
        }
        return 0;
    }
    ll SPath2 = Dijkstra();
  //  DEBUG(SPath2);
    if (SPath2 > L)
    {
        puts("NO");
        return 0;
    }
    puts("YES");
    bool k = Relax();
    while (!k) k = Relax();
    FOR(i, 1, m)
    {
        Write(E[i].u - 1); putchar(' '); Write(E[i].v - 1); putchar(' '); Write(abs(dist[E[i].u][E[i].v]));
        putchar('\n');
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
	int t;
	cin >> t;

	for (int test = 1; test <= t; test++) {
		int n, k;
		cin >> n >> k;
		string s;
		cin >> s;

		int res = 0;

		for (int i = 0; i < n;) {
			int j = i + 1;

			for (; j < n && s[j] != '1'; j++);

			int left = s[i] == '1' ? k : 0;
			int right = j < n && s[j] == '1' ? k : 0;
			int len = j - i;

			if (left == k) {
				len--;
			}

			len -= left + right;

			if (len > 0) {
				res += (len + k) / (k + 1);
			}

			i = j;
		}

		cout << res << endl;
	}

	return 0;
}


#include<iostream>
#include<bits/stdc++.h>

using namespace std;

int main(){
    int T;
    cin>>T;
    while(T--){
        int n,k;
        int count = 0;
        string S;
        cin>>n>>k;
        cin>>S;
        int startAt = -1;
        //cout<<"::"<<startAt % 2<<endl;
        for(int i = 0; i < n; i++){

            if(S[i] == '1'){
                count++;
                if(startAt == -1){
                    startAt = i;
                }
            }
        }

        if(n == k && count == 0){
            cout<<1<<endl;
            continue;
        }else if(n == k && count == 1){
            cout<<0<<endl;
            continue;
        }
        if(n%2 == 1 && startAt % 2 == 1){
            n = n - 1;
        }

        cout<<ceil(float(n) / (k + 1)) - count<<endl;
    }
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int T;
    cin >> T;
    while (T--)
    {
        int n, k;
        int count = 0;
        string S;
        cin >> n >> k;
        cin >> S;
        int gap = k + 1;
        int startAt = -1;
        //cout<<"::"<<startAt % 2<<endl;
        for (int i = 0; i < n; i++)
        {

            if (S[i] == '1')
            {
                count++;
                if (startAt == -1)
                {
                    startAt = i;
                }
            }
        }
        if (startAt == -1)
        {
            startAt = 0;
        } // 1 /2
        int possible = n/gap + ((n % gap) > (startAt % gap));
       // int possible = (((n - (startAt % gap)) - (n%gap))/ gap) + ((n % gap) > (startAt % gap));
        cout << (possible - count) << endl;
    }
}


#include<iostream>
#include<bits/stdc++.h>

using namespace std;

int main(){
    int T;
    cin>>T;
    while(T--){
        int n,k;
        int count = 0;
        string S;
        cin>>n>>k;
        cin>>S;
        int startAt = -1;
        //cout<<"::"<<startAt % 2<<endl;
        for(int i = 0; i < n; i++){

            if(S[i] == '1'){
                count++;
                if(startAt == -1){
                    startAt = i;
                }
            }
        }

        if(n == k){
            cout<<!count<<endl;
            continue;
        }
        if(startAt != -1){
            n = n - (startAt % k);

        }

        // cout<<n<<" "<<k+1<<" "<<count<<endl;

        cout<<(ceil(double(n) / (k + 1)) - count)<<endl;
    }

}


#include<iostream>
#include<bits/stdc++.h>

using namespace std;

int main(){
    int T;
    cin>>T;
    while(T--){
        int n,k;
        int count = 0;
        string S;
        cin>>n>>k;
        cin>>S;
        int startAt = -1;
        //cout<<"::"<<startAt % 2<<endl;
        for(int i = 0; i < n; i++){

            if(S[i] == '1'){
                count++;
                if(startAt == -1){
                    startAt = i;
                }
            }
        }

        if(n == k && count == 0){
            cout<<1<<endl;
            continue;
        }
        if(n%2 == 1 && startAt % 2 == 1){
            n = n - 1;
        }

        cout<<ceil(float(n) / (k + 1)) - count<<endl;
    }
}


#include<iostream>
#include<bits/stdc++.h>

using namespace std;

int main(){
    int T;
    cin>>T;
    while(T--){
        float n,k;
        int count = 0;
        string S;
        cin>>n>>k;
        cin>>S;
        for(int i = 0; i < n; i++){
            if(S[i] == '1'){
                count++;
            }
        }
        cout<<ceil(n / (k + 1)) - count<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sct(tc) scanf("%lld",&tc)
#define scl(n) scanf("%lld",&n)
#define scll(n,m) scanf("%lld%lld",&n,&m)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
int main()
{
	ll tc,n,cnt,k,i,j,c;
	sct(tc);
	while(tc--)
	{
	scanf("%lld %lld",&n,&k);
	cnt=0;
	string s;
	cin >>s;
	/*if(s[0]=='0')
	{
		cnt++;
	}*/
	for(i=0;i<n;)
	{

	   if(s[i]=='0')
	   {
	   	c=0;
	   	ll cnt2=0;
	   	for(j=i+1;j>=(i+k);j--)
	   		{
	   			c++;
	   			if(s[j]!='1')
	   			cnt2++;
	   			else
	   			break;
			}
			if(cnt2==c)
			{
				cnt++;
				i=i+k+1;
			}
			else
			i++;
	   	}

	   else
	   i=i+k+1;
   }
	   /*if(i+k+1>=n)
	   break;
	   if(s[i+k+1]=='0')
	   {
	   	cnt++;
	    i=i+k+1;
	   }
	   else
	   i=i+k+1;*/
	   printf("%lld\n",cnt);
	}

    }


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sct(tc) scanf("%lld",&tc)
#define scl(n) scanf("%lld",&n)
#define scll(n,m) scanf("%lld%lld",&n,&m)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
int main()
{
	ll tc,n,cnt,k,i,j,c;
	sct(tc);
	while(tc--)
	{
	scanf("%lld %lld",&n,&k);
	cnt=0;
	string s;
	cin >>s;
	/*if(s[0]=='0')
	{
		cnt++;
	}*/
	for(i=n-1;i>=0;)
	{

	   if(s[i]=='0')
	   {
	   	c=0;
	   	ll cnt2=0;
	   	for(j=i-1;j>=(i-k-1);j--)
	   		{
	   			c++;
	   			if(s[j]!='1')
	   			cnt2++;
	   			else
	   			break;
			}
			if(c==cnt2)
			{
				cnt++;
				i=i-k-1;
			}
			else
			i--;
	   	}

	   else
	   i--;
   }
	   /*if(i+k+1>=n)
	   break;
	   if(s[i+k+1]=='0')
	   {
	   	cnt++;
	    i=i+k+1;
	   }
	   else
	   i=i+k+1;*/
	   printf("%lld\n",cnt);
	}

    }


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sct(tc) scanf("%lld",&tc)
#define scl(n) scanf("%lld",&n)
#define scll(n,m) scanf("%lld%lld",&n,&m)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
int main()
{
   ll tc,n,k,i,j,cnt,l;
   sct(tc);
   while(tc--)
   {
   scanf("%lld %lld",&n,&k);
   cnt=0;
   string s;
   cin >> s;
   if(n<=k)
   cnt=0;
   for(i=0;i<n;)
   {
   	if(s[i]=='0')
   	{
   		bool flag=0;
   	   	for(j=i+1;j<=i+k;j++)
   	   	{
   	   	   if(s[j]=='1')
			{
				flag=1;
				l=j;
				break;
			}
		}
		if(flag==0)
		{
			cnt++;
			i=i+k+1;
		}

		else
		i=l+k+1;
	}
	else
	i=i+k+1;
   }
   printf("%lld\n",cnt);
   }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sct(tc) scanf("%lld",&tc)
#define scl(n) scanf("%lld",&n)
#define scll(n,m) scanf("%lld%lld",&n,&m)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
int main()
{
	ll tc,n,cnt,k,i,j,c;
	sct(tc);
	while(tc--)
	{
	scanf("%lld %lld",&n,&k);
	cnt=0;
	string s;
	cin >>s;
	/*if(s[0]=='0')
	{
		cnt++;
	}*/
	for(i=0;i<n;)
	{

	   if(s[i]=='0')
	   {
	   	c=0;
	   	ll cnt2=0;
	   	for(j=i+1;j<=(i+k);j++)
	   		{
	   			c++;
	   			if(s[j]!='1')
	   			cnt2++;
	   			else
	   			{i=j;
	   			break;}
			}
			if(cnt2==c)
			{
				cnt++;
				i=i+k+1;
			}
	   	}

	   else
	   i=i+k+1;
   }
	   /*if(i+k+1>=n)
	   break;
	   if(s[i+k+1]=='0')
	   {
	   	cnt++;
	    i=i+k+1;
	   }
	   else
	   i=i+k+1;*/
	   printf("%lld\n",cnt);
	}

    }


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sct(tc) scanf("%lld",&tc)
#define scl(n) scanf("%lld",&n)
#define scll(n,m) scanf("%lld%lld",&n,&m)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
int main()
{
	ll tc,i,n,cnt,x,k;
	sct(tc);
	while(tc--)
	{
	scanf("%lld %lld",&n,&k);
	cnt=0;
	string s;
	cin >>s;
	if(s[0]=='0')
	{
		cnt++;
	}
	for(i=0;i<n;)
	{

	   if(i+k+1>=n)
	   break;
	   if(s[i+k+1]=='0')
	   cnt++;
	   i=i+k+1;
	}
	printf("%lld\n",cnt);
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sct(tc) scanf("%lld",&tc)
#define scl(n) scanf("%lld",&n)
#define scll(n,m) scanf("%lld%lld",&n,&m)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
ll ar[1000000];
int main()
{
   ll tc,n,k,i,cnt;
   sct(tc);
   while(tc--)
   {
   scanf("%lld %lld",&n,&k);
   cnt=0;
   string s;
   cin >> s;
   for(i=0;i<n;)
   {
   	if(s[i]=='0')
   	{
   	   if(s[i+k]=='0'||i+k>=n)
		  {
		  	cnt++;
		  	i=i+k+1;
		  }
		else
		i=i+2*k+1;
	}
	else
	i=i+k+1;
   }
   printf("%lld\n",cnt);
   }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sct(tc) scanf("%lld",&tc)
#define scl(n) scanf("%lld",&n)
#define scll(n,m) scanf("%lld%lld",&n,&m)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
int main()
{
	ll tc,n,cnt,k,i,j,c;
	sct(tc);
	while(tc--)
	{
	scanf("%lld %lld",&n,&k);
	cnt=0;
	string s;
	cin >>s;
	/*if(s[0]=='0')
	{
		cnt++;
	}*/
	for(i=0;i<n;)
	{

	   if(s[i]=='0')
	   {
	   	c=0;
	   	ll cnt2=0;
	   	for(j=i+1;j<=(i+k)&&j<n;j++)
	   		{
	   			c++;
	   			if(s[j]!='1')
	   			cnt2++;
	   			else
	   			break;
			}
			if(cnt2==c)
			{
				cnt++;
				i=i+k+1;
			}
			else
			i++;
	   	}

	   else
	   i=i+k+1;
   }

	   printf("%lld\n",cnt);
	}

    }


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sct(tc) scanf("%lld",&tc)
#define scl(n) scanf("%lld",&n)
#define scll(n,m) scanf("%lld%lld",&n,&m)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
int main()
{
	ll tc,n,cnt,k,i,j,c;
	sct(tc);
	while(tc--)
	{
	scanf("%lld %lld",&n,&k);
	cnt=0;
	string s;
	cin >>s;
	/*if(s[0]=='0')
	{
		cnt++;
	}*/
	for(i=0;i<n;)
	{

	   if(s[i]=='0')
	   {
	   	c=0;
	   	ll cnt2=0;
	   	for(j=i+1;j<=(i+k);j++)
	   		{
	   			c++;
	   			if(s[j]!='1')
	   			cnt2++;
	   			else
	   			break;
			}
			if(c==cnt2)
			{
				cnt++;
				i=i+k+1;
			}
			else
			i++;
	   	}

	   else
	   i++;
   }
	   /*if(i+k+1>=n)
	   break;
	   if(s[i+k+1]=='0')
	   {
	   	cnt++;
	    i=i+k+1;
	   }
	   else
	   i=i+k+1;*/
	   printf("%lld\n",cnt);
	}

    }


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sct(tc) scanf("%lld",&tc)
#define scl(n) scanf("%lld",&n)
#define scll(n,m) scanf("%lld%lld",&n,&m)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
int main()
{
	ll tc,n,cnt,k,i,j,c;
	sct(tc);
	while(tc--)
	{
	scanf("%lld %lld",&n,&k);
	cnt=0;
	string s;
	cin >>s;
	/*if(s[0]=='0')
	{
		cnt++;
	}*/
	for(i=n-1;i>=0;)
	{

	   if(s[i]=='0')
	   {
	   	c=0;
	   	ll cnt2=0;
	   	for(j=i-1;j>=(i-k);j--)
	   		{
	   			c++;
	   			if(s[j]!='1')
	   			cnt2++;
	   			else
	   			break;
			}
			if(c==cnt2)
			{
				cnt++;
				i=i-k-1;
			}
			else
			i--;
	   	}

	   else
	   i--;
   }
	   /*if(i+k+1>=n)
	   break;
	   if(s[i+k+1]=='0')
	   {
	   	cnt++;
	    i=i+k+1;
	   }
	   else
	   i=i+k+1;*/
	   printf("%lld\n",cnt);
	}

    }


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sct(tc) scanf("%lld",&tc)
#define scl(n) scanf("%lld",&n)
#define scll(n,m) scanf("%lld%lld",&n,&m)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
int main()
{
   ll tc,n,k,i,j,cnt,l;
   sct(tc);
   while(tc--)
   {
   scanf("%lld %lld",&n,&k);
   cnt=0;
   string s;
   cin >> s;
   for(i=0;i<n;)
   {
   	if(s[i]=='0')
   	{
   		bool flag=0;
   	   	for(j=i+1;j<=i+k&&j<n;j++)
   	   	{
   	   	   if(s[j]=='1')
			{
				flag=1;
				l=j;
				break;
			}
		}
		if(flag==0)
		{
			cnt++;
			i=i+k+1;
		}

		else
		i=l;
	}
	else
	i=i+k+1;
   }
   printf("%lld\n",cnt);
   }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sct(tc) scanf("%lld",&tc)
#define scl(n) scanf("%lld",&n)
#define scll(n,m) scanf("%lld%lld",&n,&m)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
int main()
{
	ll tc,n,cnt,k,i,j,c;
	sct(tc);
	while(tc--)
	{
	scanf("%lld %lld",&n,&k);
	cnt=0;
	string s;
	cin >>s;
	/*if(s[0]=='0')
	{
		cnt++;
	}*/
	for(i=0;i<n;)
	{

	   if(s[i]=='0')
	   {
	   	c=0;
	   	ll cnt2=0;
	   	for(j=i+1;j<=(i+k);j++)
	   		{
	   			c++;
	   			if(s[j]!='1')
	   			cnt2++;
	   			else
	   			break;
			}
			if(cnt2==c)
			{
				cnt++;
				i=i+k+1;
			}
			else
			i++;
	   	}

	   else
	   i=i+k+1;
   }
	   /*if(i+k+1>=n)
	   break;
	   if(s[i+k+1]=='0')
	   {
	   	cnt++;
	    i=i+k+1;
	   }
	   else
	   i=i+k+1;*/
	   printf("%lld\n",cnt);
	}

    }


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sct(tc) scanf("%lld",&tc)
#define scl(n) scanf("%lld",&n)
#define scll(n,m) scanf("%lld%lld",&n,&m)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
int main()
{
	ll tc,n,cnt,k,i,j,c;
	sct(tc);
	while(tc--)
	{
	scanf("%lld %lld",&n,&k);
	cnt=0;
	string s;
	cin >>s;
	/*if(s[0]=='0')
	{
		cnt++;
	}*/
	for(i=0;i<n;)
	{

	   if(s[i]=='0')
	 {
	   	if(i+k>=n)
	   	{
	    cnt++;
	   	break;}
			if(i+k<n&&s[i+k]=='0')
			{
				cnt++;
				i=i+k+1;
			}
			else
			i=i+k;
	   }
	   else
	   i=i+k+1;
   }
	   /*if(i+k+1>=n)
	   break;
	   if(s[i+k+1]=='0')
	   {
	   	cnt++;
	    i=i+k+1;
	   }
	   else
	   i=i+k+1;*/
	   printf("%lld\n",cnt);
	}

    }


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007

int main(){
    FAST
    int t; cin >> t;
    while(t--){
        int n, k; cin >> n >> k;
        string s; cin >> s;
        int ans = 0;
        int cnt = 0;
        int ones = 0;
        int pos1 = 0;
        int pos2 = 0;
        for(int i = 0; i < n; i++){
            if(s[i] == '1'){
                ones++;
                if(ones == 1){
                    pos1 = i;
                }
                pos2 = i;
            }
        }
        if(ones == 0){
            s[0] = '1';
            ans++;
            ones++;
        }
        for(int i = pos1; i < pos2; i++){
            if(ones == 0)break;
            if(s[i] == '1')cnt = 0, ones--;
            else{
                cnt++;
                if(cnt == 2*k + 1)ans++, cnt = 0;
            }
        }
        ans += (pos1 + 1)/(k + 1);
        ans += (n - pos2 - 1)/(k + 1);
        cout << ans << endl;
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007

int main(){
    FAST
    int t; cin >> t;
    while(t--){
        int n, k; cin >> n >> k;
        string s; cin >> s;
        int ans = 0;
        int cnt = 0;
        int ones = 0;
        int pos1 = 0;
        int pos2 = 0;
        for(int i = 0; i < n; i++){
            if(s[i] == '1'){
                ones++;
                if(ones == 1){
                    pos1 = i;
                }
                pos2 = i;
            }
        }
        if(ones == 0){
            s[0] = '1';
            ans++;
            ones++;
        }
        for(int i = pos1; i < pos2; i++){
            if(ones == 0)break;
            if(s[i] == '1')cnt = 0, ones--;
            else{
                cnt++;
                if(cnt == 2*k + 1)ans++, cnt = k + 1;
            }
        }
        ans += (pos1 + 1)/(k + 1);
        ans += (n - pos2 - 1)/(k + 1);
        cout << ans << endl;
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007

int main(){
    FAST
    int t; cin >> t;
    while(t--){
        int n, k; cin >> n >> k;
        string s; cin >> s;
        int ans = 0;
        int cnt = 0;
        int ones = 0;
        vector<int> pos;
        for(int i = 0; i < n; i++){
            if(s[i] == '1')ones++, pos.pb(i);
        }
        if(ones == 0){
            s[0] = '1';
            ans++;
        }
        for(int i = 0; i < n; i++){
            if(s[i] == '1')cnt = 0;
            else{
                cnt++;
                if(cnt == 2*k)ans++, cnt = 0;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007

int main(){
    FAST
    int t; cin >> t;
    while(t--){
        int n, k; cin >> n >> k;
        string s; cin >> s;
        int ans = 0;
        int cnt = 0;
        int ones = 0;
        for(int i = 0; i < n; i++){
            if(s[i] == '1')ones++;
        }
        if(ones == 0){
            s[0] = '1';
            ans++;
        }
        for(int i = 0; i < n; i++){
            if(s[i] == '1')cnt = 0;
            else{
                cnt++;
                if(cnt == k + 1)ans++, cnt = 0;
            }
        }
        cout << ans << endl;

    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007

int main(){
    FAST
    int t; cin >> t;
    while(t--){
        int n, k; cin >> n >> k;
        string s; cin >> s;
        int ans = 0;
        int cnt = 0;
        int ones = 0;
        int pos1 = 0;
        int pos2 = 0;
        for(int i = 0; i < n; i++){
            if(s[i] == '1'){
                ones++;
                if(ones == 1){
                    pos1 = i;
                }
                pos2 = i;
            }
        }
        if(ones == 0){
            s[0] = '1';
            ans++;
            ones++;
        }
        for(int i = pos1; i < pos2; i++){
            if(ones == 0)break;
            if(s[i] == '1')cnt = 0, ones--;
            else{
                cnt++;
                if(cnt == 2*k + 1)ans++, cnt = 0;
            }
        }
        cnt = 0;
        for(int i = 0; i < pos1; i++){
            cnt++;
            if(cnt == k + 1)ans++, cnt = 0;
        }
        cnt = 0;
        for(int i = n - 1; i > pos2; i--){
            cnt++;
            if(cnt == k + 1)ans++, cnt = 0;
        }
        cout << ans << endl;
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007

int main(){
    FAST
    int t; cin >> t;
    while(t--){
        int n, k; cin >> n >> k;
        string s; cin >> s;
        int ans = 0;
        int cnt = 0;
        int ones = 0;
        int pos1 = 0;
        int pos2 = 0;
        for(int i = 0; i < n; i++){
            if(s[i] == '1'){
                ones++;
                if(ones == 1){
                    pos1 = i;
                }
                pos2 = i;
            }
        }
        if(ones == 0){
            s[0] = '1';
            ans++;
            ones++;
        }
        for(int i = pos1; i < pos2; i++){
            if(ones == 0)break;
            if(s[i] == '1')cnt = 0, ones--;
            else{
                cnt++;
                if(cnt == 2*k + 1)ans++, cnt = k;
            }
        }
        ans += (pos1 + 1)/(k + 1);
        ans += (n - pos2 - 1)/(k + 1);
        cout << ans << endl;
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007

int main(){
    FAST
    int t; cin >> t;
    while(t--){
        int n, k; cin >> n >> k;
        string s; cin >> s;
        int ans = 0;
        int cnt = 0;
        int ones = 0;
        int pos1 = 0;
        int pos2 = 0;
        for(int i = 0; i < n; i++){
            if(s[i] == '1'){
                ones++;
                if(ones == 1){
                    pos1 = i;
                }
                pos2 = i;
            }
        }
        if(ones == 0){
            s[0] = '1';
            ans++;
            ones++;
        }
        for(int i = pos1; i < pos2; i++){
            if(ones == 0)break;
            if(s[i] == '1')cnt = 0, ones--;
            else{
                cnt++;
                if(cnt == 2*k)ans++, cnt = 0;
            }
        }
        cnt = 0;
        for(int i = 0; i < pos1; i++){
            cnt++;
            if(cnt == k + 1)ans++, cnt = 0;
        }
        cnt = 0;
        for(int i = n - 1; i > pos2; i--){
            cnt++;
            if(cnt == k + 1)ans++, cnt = 0;
        }
        cout << ans << endl;
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007

int main(){
    FAST
    int t; cin >> t;
    while(t--){
        int n, k; cin >> n >> k;
        string s; cin >> s;
        int ans = 0;
        int cnt = 0;
        int ones = 0;
        int pos1 = 0;
        int pos2 = 0;
        for(int i = 0; i < n; i++){
            if(s[i] == '1'){
                ones++;
                if(ones == 1){
                    pos1 = i;
                }
                pos2 = i;
            }
        }
        if(ones == 0){
            s[0] = '1';
            ans++;
            ones++;
        }
        for(int i = pos1; i < pos2; i++){
            if(ones == 0)break;
            if(s[i] == '1')cnt = 0, ones--;
            else{
                cnt++;
                if(cnt == 2*k + 1)ans++, cnt = k;
            }
        }
        ans += (pos1)/(k + 1);
        ans += (n - pos2 - 1)/(k + 1);
        cout << ans << endl;
    }
    return 0;
}


// from #650
#include <iostream>
#include <vector>
#include <string>
using namespace std;
#define v int
struct name {
    v size;
    v dist;
    vector <v> tbls;
    v count;
} ;
name input () {
    name e;
    bool open = false;
    v c = 0;
    cin >> e.size >> e.dist;
    e.count = 0;
    string tmp;
    cin >> tmp;
    for (v j = 0; j < e.size; j++) {
        if (tmp[j] == '1') {
            e.tbls.push_back (j);
        }
    }
    return e;
}
v how_many (v ib, v ie, v dist) {
    v c = 0;
    while (ib < ie) {
        ib += dist * 2;
        if (ib < ie) {
            c++;
        }
    }
    return c;
}
void result (name &e) {
    if (e.tbls.size() == 0) {
        if (e.size <= e.dist) {
            e.count = 1;
        }
        else {
            e.count += e.size / (e.dist + 1);
        }
    }
    else if (e.tbls.size() == 1) {
        e.count += e.tbls[0] / (e.dist + 1);
        e.count += (e.size - e.tbls[0] - 1) / (e.dist + 1);
    }
    else {
        for (v j = 0; j < e.tbls.size(); j++) {
            e.count += how_many (e.tbls[j], e.tbls[j + 1], e.dist);
        }
    }
    cout << e.count << endl;
}
int main () {
    ios_base::sync_with_stdio(false);
    v n;
    cin >> n;
    for (v i = 0; i < n; i++) {
        name e = input();
        cout << '\n';
        result (e);
    }
    return 0;
}


// from #650
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
#define v int
struct name {
    v size;
    v dist;
    vector <v> tbls;
    v count;
} ;
name input () {
    name e;
    bool open = false;
    v c = 0;
    cin >> e.size >> e.dist;
    e.count = 0;
    string tmp;
    cin >> tmp;
    for (v j = 0; j < e.size; j++) {
        if (tmp[j] == '1') {
            e.tbls.push_back (j);
        }
    }
    return e;
}
v how_many (v ib, v ie, v dist) {
    v c = 0;
    while (ib < ie) {
        ib += dist * 2 + 1;
        if (ib < ie) {
            c++;
        }
    }
    return c;
}
double tmp, siz, d;
void result (name &e) {
    if (e.tbls.size() == 0) {
        if (e.size <= e.dist) {
            e.count = 1;
        }
        else {
            double siz = e.size, d = e.dist,
            tmp = siz / (d + 1);
            e.count += ceil (tmp);
        }
    }
    else if (e.tbls.size() == 1) {
        e.count += e.tbls[0] / (e.dist + 1);
        e.count += (e.size - e.tbls[0] - 1) / (e.dist + 1);
    }
    else {
        for (v j = 0; j < e.tbls.size() - 1; j++) {
            e.count += how_many (e.tbls[j], e.tbls[j + 1], e.dist);
        }
    }
    cout << e.count << endl;
}
int main () {
    ios_base::sync_with_stdio(false);
    v n;
    cin >> n;
    for (v i = 0; i < n; i++) {
        name e = input();
        result (e);
    }
    return 0;
}