#include <stdio.h>
#include <bits/stdc++.h>
typedef int integer;
#define int long long
#define rep(x, y, z) for(int (x) = (y); (x) < (z); (x)++)
#define fil(a,b) memset((a),(b),sizeof(a))
#define mod 1000000007
#define endl '\n'
#define mp make_pair
#define pb push_back
#define sz(x) (int) (x).size()
#define srt(x) sort((x).begin(), (x).end())
#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define vvi vector<vi>
#define fi first
#define se second
#define INF 1e12
#define EPS 1e-9
using namespace std;

int n, m, s, t, L;
int parent[1000];
int adj[1000][1000];
vi dist;

void dijkstra(){
	priority_queue< ii, vii, greater<ii> > pq;
	dist.clear();
	dist.resize(n, INF);
	dist[s] = 0;
	pq.push(mp(0, s));
	while (!pq.empty()){
		ii node = pq.top(); pq.pop();
		int u = node.se, cost = node.fi;
		if (cost != dist[u]) continue;
		for (int i = 0; i < n; i++){
			int d = adj[u][i];
			if (!d) d = 1;
			if (d == -1) continue;
			if (cost + d < dist[i]){
				dist[i] = cost + d;
				parent[i] = u;
				pq.push(mp(dist[i], i));
			}
		}
	}
}

integer main() {
	ios_base::sync_with_stdio(false);
	cin >> n >> m >> L >> s >> t;
	memset(adj, -1, sizeof adj);
	vii output(m);
	for (int i = 0; i < m; i++){
		int a, b, c;
		cin >> a >> b >> c;
		adj[a][b] = adj[b][a] = c;
		output[i] = mp(a, b);
	}
	dijkstra();
	int shortest = dist[t];
	int tempA = -1, tempB = -1;
	int cur = t;
	if (shortest >= INF){
		cout << "NO\n";
		return 0;
	}
	while (cur != s){
		int p = parent[cur];
		if (adj[p][cur] == 0){
			tempA = p;
			tempB = cur;
			adj[p][cur] = adj[cur][p] = 1;
		}
		cur = p;
	}
	//cout << dist[t] << ' ' << shortest << endl;
	if (L < shortest){
		cout << "NO\n";
		return 0;
	}
	for (int i = 0; i < n; i++){
		for (int j = i+1; j < n; j++){
			if (adj[i][j] == 0)
				adj[i][j] = adj[j][i] = INF;
		}
	}
	if (tempA != -1){
		adj[tempA][tempB] = adj[tempB][tempA] = L - shortest + 1;
		shortest = L;
	}
	if (shortest != L){
		cout << "NO\n";
		return 0;
	}
	dijkstra();
	if (dist[t] != L){
		cout << "NO\n";
		return 0;
	}
	cout << "YES\n";
	for (int i = 0; i < m; i++){
		int u = output[i].fi, v = output[i].se;
		cout << u << ' ' << v << ' ' << adj[u][v] << endl;
	}
}


#include <stdio.h>
#include <bits/stdc++.h>
typedef int integer;
#define int long long
#define rep(x, y, z) for(int (x) = (y); (x) < (z); (x)++)
#define fil(a,b) memset((a),(b),sizeof(a))
#define mod 1000000007
#define endl '\n'
#define mp make_pair
#define pb push_back
#define sz(x) (int) (x).size()
#define srt(x) sort((x).begin(), (x).end())
#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define vvi vector<vi>
#define fi first
#define se second
#define INF 1e15
#define EPS 1e-9
using namespace std;

int n, m, s, t, L;
int parent[1000];
int adj[1000][1000];
vi dist;

void dijkstra(){
	priority_queue< ii, vii, greater<ii> > pq;
	dist.clear();
	dist.resize(n, INF);
	dist[s] = 0;
	pq.push(mp(0, s));
	while (!pq.empty()){
		ii node = pq.top(); pq.pop();
		int u = node.se, cost = node.fi;
		if (cost != dist[u]) continue;
		for (int i = 0; i < n; i++){
			int d = adj[u][i];
			if (d == -1) continue;
			if (cost + d < dist[i]){
				dist[i] = cost + d;
				parent[i] = u;
				pq.push(mp(dist[i], i));
			}
		}
	}
}

integer main() {
	ios_base::sync_with_stdio(false);
	cin >> n >> m >> L >> s >> t;
	memset(adj, -1, sizeof adj);
	vii output(m);
	for (int i = 0; i < m; i++){
		int a, b, c;
		cin >> a >> b >> c;
		adj[a][b] = adj[b][a] = c;
		output[i] = mp(a, b);
	}
	dijkstra();
	int shortest = dist[t];
	int tempA, tempB;
	int cur = t;
	while (cur != s){
		int p = parent[cur];
		if (adj[p][cur] == 0){
			tempA = p;
			tempB = cur;
			adj[p][cur] = adj[cur][p] = 1;
			shortest++;
		}
		cur = p;
	}
	if (L < shortest){
		cout << "NO\n";
		return 0;
	}
	for (int i = 0; i < n; i++){
		for (int j = i+1; j < n; j++){
			if (adj[i][j] == 0)
				adj[i][j] = adj[j][i] = INF;
		}
	}
	adj[tempA][tempB] = adj[tempB][tempA] = L - shortest + 1;
	dijkstra();
	if (dist[t] != L){
		cout << "NO\n";
		return 0;
	}
	cout << "YES\n";
	for (int i = 0; i < m; i++){
		int u = output[i].fi, v = output[i].se;
		cout << u << ' ' << v << ' ' << adj[u][v] << endl;
	}
}


#include <stdio.h>
#include <bits/stdc++.h>
typedef int integer;
#define int long long
#define rep(x, y, z) for(int (x) = (y); (x) < (z); (x)++)
#define fil(a,b) memset((a),(b),sizeof(a))
#define mod 1000000007
#define endl '\n'
#define mp make_pair
#define pb push_back
#define sz(x) (int) (x).size()
#define srt(x) sort((x).begin(), (x).end())
#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define vvi vector<vi>
#define fi first
#define se second
#define INF 1e12
#define EPS 1e-9
using namespace std;

int n, m, s, t, L;
int parent[1000];
int adj[1000][1000];
vi dist;

void dijkstra(){
	priority_queue< ii, vii, greater<ii> > pq;
	dist.clear();
	dist.resize(n, INF);
	dist[s] = 0;
	pq.push(mp(0, s));
	while (!pq.empty()){
		ii node = pq.top(); pq.pop();
		int u = node.se, cost = node.fi;
		if (cost != dist[u]) continue;
		for (int i = 0; i < n; i++){
			int d = adj[u][i];
			if (d == -1) continue;
			if (cost + d < dist[i]){
				dist[i] = cost + d;
				parent[i] = u;
				pq.push(mp(dist[i], i));
			}
		}
	}
}

integer main() {
	ios_base::sync_with_stdio(false);
	cin >> n >> m >> L >> s >> t;
	memset(adj, -1, sizeof adj);
	vii output(m);
	for (int i = 0; i < m; i++){
		int a, b, c;
		cin >> a >> b >> c;
		adj[a][b] = adj[b][a] = c;
		output[i] = mp(a, b);
	}
	dijkstra();
	int shortest = dist[t];
	int tempA = -1, tempB = -1;
	int cur = t;
	if (shortest >= INF){
		cout << "NO\n";
		return 0;
	}
	while (cur != s){
		int p = parent[cur];
		if (adj[p][cur] == 0){
			tempA = p;
			tempB = cur;
			adj[p][cur] = adj[cur][p] = 1;
			shortest++;
		}
		cur = p;
	}
	if (L < shortest){
		cout << "NO\n";
		return 0;
	}
	for (int i = 0; i < n; i++){
		for (int j = i+1; j < n; j++){
			if (adj[i][j] == 0)
				adj[i][j] = adj[j][i] = INF;
		}
	}
	if (tempA != -1){
		adj[tempA][tempB] = adj[tempB][tempA] = L - shortest + 1;
		shortest = L;
	}
	if (shortest != L){
		cout << "NO\n";
		return 0;
	}
	dijkstra();
	if (dist[t] != L){
		cout << "NO\n";
		return 0;
	}
	cout << "YES\n";
	for (int i = 0; i < m; i++){
		int u = output[i].fi, v = output[i].se;
		cout << u << ' ' << v << ' ' << adj[u][v] << endl;
	}
}


#include <stdio.h>
#include <bits/stdc++.h>
typedef int integer;
#define int long long
#define rep(x, y, z) for(int (x) = (y); (x) < (z); (x)++)
#define fil(a,b) memset((a),(b),sizeof(a))
#define mod 1000000007
#define endl '\n'
#define mp make_pair
#define pb push_back
#define sz(x) (int) (x).size()
#define srt(x) sort((x).begin(), (x).end())
#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define vvi vector<vi>
#define fi first
#define se second
#define INF 1e12
#define EPS 1e-9
using namespace std;

priority_queue< ii, vii, greater<ii> > pq;
int n, m, s, t, L;
int parent[1000];
int adj[1000][1000];
int variable[1000][1000];
vi edges[1000];
vi dist;
vii output;

void dijkstra(){

	dist.clear();
	dist.resize(n, INF);
	dist[s] = 0;
	pq.push(mp(0, s));
	while (!pq.empty()){
		ii node = pq.top(); pq.pop();
		int u = node.se, cost = node.fi;
		if (cost != dist[u]) continue;
		for (int i = 0; i < sz(edges[u]); i++){
			int v = edges[u][i];
			int d = adj[u][v];
			if (!d) continue;

			if (cost + d < dist[v]){
				dist[v] = cost + d;
				parent[v] = u;
				pq.push(mp(dist[v], v));
			}
		}
	}
}

integer main() {
	ios_base::sync_with_stdio(false);
	cin >> n >> m >> L >> s >> t;
	memset(adj, -1, sizeof adj);
	memset(variable, -1, sizeof variable);
	for (int i = 0; i < m; i++){
		int a, b, c;
		cin >> a >> b >> c;
		adj[a][b] = adj[b][a] = c;
		if (!c)
			variable[a][b] = variable[b][a] = 1;
		edges[a].pb(b);
		edges[b].pb(a);
		output.pb(mp(a, b));
	}
	dijkstra();
	if (dist[t] < L){
		cout << "NO\n";
		return 0;
	}
	for (int i = 0; i < n; i++)
		for (int j = i+1; j < n; j++)
			if (adj[i][j] == 0)
				adj[i][j] = adj[j][i] = 1;
	dijkstra();

	if (dist[t] > L){
		cout << "NO\n";
		return 0;
	}
	while (dist[t] != L){
		int cur = t;
		while (cur != s){
			int p = parent[cur];
			if (variable[cur][p] == 1){
				int diff = L - dist[t];
				adj[cur][p] = adj[p][cur] = diff + adj[cur][p];
				break;
			}
			cur = p;
		}
		dijkstra();
	}

	cout << "YES\n";
	for (int i = 0; i < m; i++){
		int u = output[i].fi, v = output[i].se;
		cout << u << ' ' << v << ' ' << adj[u][v] << endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define INF (1LL<<52)
#define MAX 100000
#define pb push_back
#define mp make_pair
#define MOD 1000000007
typedef long long Int;
typedef pair<Int,Int> pii;
typedef vector<Int> vi;
typedef vector<pii> vii;
vii V;
vii G[1003];
bool flag=0;
Int n,m,L,s,t;
vector<pair<pii,Int> >Edges;
struct cmp
{
    bool operator ()(pii a,pii b)
    {
        return a.fs>b.fs;
    }
};
priority_queue<pii,vii,cmp>pq;
bool check(pii A,Int u,Int v)
{
    if (A.fs==u&&A.sc==v)
        return 1;
    if (A.fs==v&&A.sc==u)
        return 1;
    return 0;
}
Int dijkstra()
{
    vi d(n+1,INF);
    pq.push(mp(0,s));
    d[s]=0;
    while (!pq.empty())
    {
        Int x=pq.top().fs;
        Int y=pq.top().sc;
        pq.pop();
        if (x>d[y])
            continue;
        for (Int i=0;i<G[y].size();++i)
        {
            if (x+G[y][i].sc<d[G[y][i].fs])
            {
                d[G[y][i].fs]=x+G[y][i].sc;
                pq.push(mp(d[G[y][i].fs],G[y][i].fs));
            }
        }
    }
    return d[t];
}
Int dijkstra2(pii A)//A edge wt is 0
{
    flag=0;
    vi d(n+1,INF);
    vi par(n+1,-1);
    pq.push(mp(0,s));
    d[s]=0;
    par[s]=s;
    while (!pq.empty())
    {
        Int x=pq.top().fs;
        Int y=pq.top().sc;
        pq.pop();
        if (x>d[y])
            continue;
        for (Int i=0;i<G[y].size();++i)
        {
            Int e=G[y][i].sc;
            if (check(A,y,G[y][i].fs))
                e=0;
            if (x+e<d[G[y][i].fs])
            {
                par[G[y][i].fs]=y;
                d[G[y][i].fs]=x+e;
                pq.push(mp(d[G[y][i].fs],G[y][i].fs));
            }
        }
    }
    if (d[t]>L)
        return d[t];
    Int x=t;
    while (x!=s&&par[x]!=-1)
    {
        if (check(A,par[x],x))
            flag=1;
        x=par[x];
    }
    return d[t];
}
int main()
{
    cin>>n>>m>>L>>s>>t;
    for (Int i=0;i<m;++i)
    {
        Int u,v,w;
        cin>>u>>v>>w;
        if (w==0)
        {
            w=INF;
            V.pb(mp(u,v));
        }
        Edges.pb(mp(mp(u,v),w));
        G[u].pb(mp(v,w));
        G[v].pb(mp(u,w));
    }
    Int plen=dijkstra();
    if (plen<L)
    {
        cout<<"NO";
        return 0;
    }
    else if(plen==L)
    {
        for (Int i=0;i<Edges.size();++i)
            cout<<Edges[i].fs.fs<<" "<<Edges[i].fs.sc<<" "<<Edges[i].sc<<"\n";
        return 0;
    }
    for (Int i=0;i<V.size();++i)
    {
        plen=dijkstra2(mp(V[i].fs,V[i].sc));
        //cout<<plen<<"\n";
        if (plen>L||flag==0)
            continue;
        cout<<"YES\n";
        for (Int j=0;j<Edges.size();++j)
        {
            //cout<<Edges[i].fs.fs<<" "<<Edges[i].fs.sc<<" "<<check(Edges[i].fs,V[i].fs,V[i].sc)<<"\n";
            if (check(Edges[j].fs,V[i].fs,V[i].sc))
                Edges[j].sc=L-plen;
        }
        for (Int j=0;j<Edges.size();++j)
            cout<<Edges[j].fs.fs<<" "<<Edges[j].fs.sc<<" "<<Edges[j].sc<<"\n";
        return 0;
    }
    cout<<"NO";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define MAX 100000
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF (Int)(1e18)
typedef long long Int;
typedef pair<Int,Int> pii;
typedef vector<Int> vi;
typedef vector<pii> vii;
vii Edges;
vii G[1002];
map<pii,Int>Map;
Int n,m,L,s,t;
Int d[1002][2];
pii par[1002][2];
struct cmp
{
    bool operator ()(pair<Int,pii>a,pair<Int,pii>b)
    {
        return a.sc.fs>b.sc.fs;
    }
};
priority_queue<pair<Int,pii>,vector<pair<Int,pii> >,cmp>pq;
void dijkstra()
{
    for (Int i=0;i<1002;++i)
    {
        d[i][0]=d[i][1]=(Int)INF;
        par[i][0]=par[i][1]=mp(-1,-1);
    }
    pq.push(mp(0,mp(s,0)));
    d[s][0]=0;
    par[s][0]=mp(s,0);
    while (!pq.empty())
    {
        pii u=pq.top().sc;
        Int x=pq.top().fs;
        pq.pop();
        if (x>d[u.fs][u.sc])
            continue;
        for (Int i=0;i<G[u.fs].size();++i)
        {
            Int v=G[u.fs][i].fs;
            Int w=G[u.fs][i].sc;
            if (w)
            {
                if (x+w<d[v][u.sc])
                {
                    par[v][u.sc]=u;
                    d[v][u.sc]=w+x;
                    pq.push(mp(d[v][u.sc],mp(v,u.sc)));
                }
                continue;
            }
            w=1000*MAX;
            if (x+w<d[v][1])
            {
                par[v][1]=u;
                d[v][1]=w+x;
                pq.push(mp(d[v][1],mp(v,1)));
            }
        }
    }
}
int main()
{
    cin>>n>>m>>L>>s>>t;
    for (Int i=0;i<m;++i)
    {
        Int u,v,w;
        cin>>u>>v>>w;
        G[u].pb(mp(v,w));
        G[v].pb(mp(u,w));
        Map[mp(u,v)]=w;
        Map[mp(v,u)]=w;
    }
    dijkstra();
    if (d[t][0]==L)
    {
        map<pii,Int>::iterator it;
        cout<<"YES\n";
        for (it=Map.begin();it!=Map.end();++it)
        {
            if ((it->fs).fs<(it->fs).sc)
                continue;
            if (it->sc)
                cout<<(it->fs).fs<<" "<<(it->fs).sc<<" "<<it->sc<<"\n";
            else
                cout<<(it->fs).fs<<" "<<(it->fs).sc<<" "<<1000*MAX<<"\n";
        }
        return 0;
    }
    if (d[t][0]<L||d[t][1]==INF)
    {
        cout<<"NO";
        return 0;
    }
    //cout<<d[t][1]<<"\n";
    pii u=mp(t,1);//current node
    while (u.fs!=s||u.sc!=0)
    {
        pii v=par[u.fs][u.sc];
        Int w=Map[mp(u.fs,v.fs)];
        if (w==0)
            Edges.pb(mp(u.fs,v.fs));
        u=v;
    }
    //for (Int i=0;i<Edges.size();++i)
        //cout<<Edges[i].fs<<" "<<Edges[i].sc<<"\n";
    if (d[t][1]-1000*MAX*Edges.size()+Edges.size()>L)
    {
        cout<<"NO";
        return 0;
    }
    for (Int i=0;i<Edges.size()-1;++i)
    {
        Map[mp(Edges[i].fs,Edges[i].sc)]=1;
        Map[mp(Edges[i].sc,Edges[i].fs)]=1;
    }
    Int x=d[t][1]-1000*MAX*Edges.size()+Edges.size()-1;
    x=L-x;
    Map[mp(Edges[Edges.size()-1].fs,Edges[Edges.size()-1].sc)]=x;
    Map[mp(Edges[Edges.size()-1].sc,Edges[Edges.size()-1].fs)]=x;
    map<pii,Int>::iterator it;
    cout<<"YES\n";
    for (it=Map.begin();it!=Map.end();++it)
    {
        if ((it->fs).fs<(it->fs).sc)
            continue;
        cout<<(it->fs).fs<<" "<<(it->fs).sc<<" "<<it->sc<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define MAX 100000
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF (Int)(1e18)
typedef long long Int;
typedef pair<Int,Int> pii;
typedef vector<Int> vi;
typedef vector<pii> vii;
vii Edges;
vii G[1002];
map<pii,Int>Map;
Int n,m,L,s,t;
Int d[1002][2];
pii par[1002][2];
struct cmp
{
    bool operator ()(pair<Int,pii>a,pair<Int,pii>b)
    {
        return a.sc.fs>b.sc.fs;
    }
};
priority_queue<pair<Int,pii>,vector<pair<Int,pii> >,cmp>pq;
void dijkstra()
{
    for (Int i=0;i<1002;++i)
    {
        d[i][0]=d[i][1]=(Int)INF;
        par[i][0]=par[i][1]=mp(-1,-1);
    }
    pq.push(mp(0,mp(s,0)));
    d[s][0]=0;
    par[s][0]=mp(s,0);
    while (!pq.empty())
    {
        pii u=pq.top().sc;
        Int x=pq.top().fs;
        pq.pop();
        if (x>d[u.fs][u.sc])
            continue;
        for (Int i=0;i<G[u.fs].size();++i)
        {
            Int v=G[u.fs][i].fs;
            Int w=G[u.fs][i].sc;
            if (w)
            {
                if (x+w<d[v][u.sc])
                {
                    par[v][u.sc]=u;
                    d[v][u.sc]=w+x;
                    pq.push(mp(d[v][u.sc],mp(v,u.sc)));
                }
                continue;
            }
            w=1000*MAX;
            if (x+w<d[v][1])
            {
                par[v][1]=u;
                d[v][1]=w+x;
                pq.push(mp(d[v][1],mp(v,1)));
            }
        }
    }
}
int main()
{
    cin>>n>>m>>L>>s>>t;
    for (Int i=0;i<m;++i)
    {
        Int u,v,w;
        cin>>u>>v>>w;
        G[u].pb(mp(v,w));
        G[v].pb(mp(u,w));
        Map[mp(u,v)]=w;
        Map[mp(v,u)]=w;
    }
    dijkstra();
    if (d[t][0]==L)
    {
        map<pii,Int>::iterator it;
        cout<<"YES\n";
        for (it=Map.begin();it!=Map.end();++it)
        {
            if ((it->fs).fs<(it->fs).sc)
                continue;
            if (it->sc)
                cout<<(it->fs).fs<<" "<<(it->fs).sc<<" "<<it->sc<<"\n";
            else
                cout<<(it->fs).fs<<" "<<(it->fs).sc<<" "<<1000*MAX<<"\n";
        }
        return 0;
    }
    if (d[t][0]<L||d[t][1]==INF)
    {
        cout<<"NO";
        return 0;
    }
    //cout<<d[t][1]<<"\n";
    pii u=mp(t,1);//current node
    while (u.fs!=s||u.sc!=0)
    {
        pii v=par[u.fs][u.sc];
        Int w=Map[mp(u.fs,v.fs)];
        if (w==0)
            Edges.pb(mp(u.fs,v.fs));
        u=v;
    }
    //for (Int i=0;i<Edges.size();++i)
        //cout<<Edges[i].fs<<" "<<Edges[i].sc<<"\n";
    if (d[t][1]-1000*MAX*Edges.size()+Edges.size()>L)
    {
        cout<<"NO";
        return 0;
    }
    for (Int i=0;i<Edges.size()-1;++i)
    {
        Map[mp(Edges[i].fs,Edges[i].sc)]=1;
        Map[mp(Edges[i].sc,Edges[i].fs)]=1;
    }
    Int x=d[t][1]-1000*MAX*Edges.size()+Edges.size()-1;
    x=L-x;
    Map[mp(Edges[Edges.size()-1].fs,Edges[Edges.size()-1].sc)]=x;
    Map[mp(Edges[Edges.size()-1].sc,Edges[Edges.size()-1].fs)]=x;
    map<pii,Int>::iterator it;
    cout<<"YES\n";
    for (it=Map.begin();it!=Map.end();++it)
    {
        if ((it->fs).fs<(it->fs).sc)
            continue;
        if (it->sc)
            cout<<(it->fs).fs<<" "<<(it->fs).sc<<" "<<it->sc<<"\n";
        else
            cout<<(it->fs).fs<<" "<<(it->fs).sc<<" "<<1000*MAX<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define MAX 100000
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF (Int)(1e18)
typedef long long Int;
typedef pair<Int,Int> pii;
typedef vector<Int> vi;
typedef vector<pii> vii;
vii Edges;
vii G[1002];
map<pii,Int>Map;
Int n,m,L,s,t;
Int d[1002][2];
pii par[1002][2];
struct cmp
{
    bool operator ()(pair<Int,pii>a,pair<Int,pii>b)
    {
        return a.sc.fs>b.sc.fs;
    }
};
priority_queue<pair<Int,pii>,vector<pair<Int,pii> >,cmp>pq;
void dijkstra()
{
    for (Int i=0;i<1002;++i)
    {
        d[i][0]=d[i][1]=(Int)INF;
        par[i][0]=par[i][1]=mp(-1,-1);
    }
    pq.push(mp(0,mp(s,0)));
    d[s][0]=0;
    par[s][0]=mp(s,0);
    while (!pq.empty())
    {
        pii u=pq.top().sc;
        Int x=pq.top().fs;
        pq.pop();
        if (x>d[u.fs][u.sc])
            continue;
        for (Int i=0;i<G[u.fs].size();++i)
        {
            Int v=G[u.fs][i].fs;
            Int w=G[u.fs][i].sc;
            if (w)
            {
                if (x+w<d[v][u.sc])
                {
                    par[v][u.sc]=u;
                    d[v][u.sc]=w+x;
                    pq.push(mp(d[v][u.sc],mp(v,u.sc)));
                }
                continue;
            }
            w=10000*MAX;
            if (x+w<d[v][1])
            {
                par[v][1]=u;
                d[v][1]=w+x;
                pq.push(mp(d[v][1],mp(v,1)));
            }
        }
    }
}
int main()
{
    cin>>n>>m>>L>>s>>t;
    for (Int i=0;i<m;++i)
    {
        Int u,v,w;
        cin>>u>>v>>w;
        G[u].pb(mp(v,w));
        G[v].pb(mp(u,w));
        Map[mp(u,v)]=w;
        Map[mp(v,u)]=w;
    }
    dijkstra();
    if (d[t][0]==L)
    {
        map<pii,Int>::iterator it;
        cout<<"YES\n";
        for (it=Map.begin();it!=Map.end();++it)
        {
            if ((it->fs).fs<(it->fs).sc)
                continue;
            if (it->sc)
                cout<<(it->fs).fs<<" "<<(it->fs).sc<<" "<<it->sc<<"\n";
            else
                cout<<(it->fs).fs<<" "<<(it->fs).sc<<" "<<10000*MAX<<"\n";
        }
        return 0;
    }
    if (d[t][0]<L||d[t][1]==INF)
    {
        cout<<"NO";
        return 0;
    }
    //cout<<d[t][1]<<"\n";
    pii u=mp(t,1);//current node
    while (u.fs!=s||u.sc!=0)
    {
        pii v=par[u.fs][u.sc];
        Int w=Map[mp(u.fs,v.fs)];
        if (w==0)
            Edges.pb(mp(u.fs,v.fs));
        u=v;
    }
    //for (Int i=0;i<Edges.size();++i)
        //cout<<Edges[i].fs<<" "<<Edges[i].sc<<"\n";
    if (d[t][1]-10000*MAX*Edges.size()+Edges.size()>L)
    {
        cout<<"NO";
        return 0;
    }
    for (Int i=0;i<Edges.size()-1;++i)
    {
        Map[mp(Edges[i].fs,Edges[i].sc)]=1;
        Map[mp(Edges[i].sc,Edges[i].fs)]=1;
    }
    Int x=d[t][1]-10000*MAX*Edges.size()+Edges.size()-1;
    x=L-x;
    Map[mp(Edges[Edges.size()-1].fs,Edges[Edges.size()-1].sc)]=x;
    Map[mp(Edges[Edges.size()-1].sc,Edges[Edges.size()-1].fs)]=x;
    map<pii,Int>::iterator it;
    cout<<"YES\n";
    for (it=Map.begin();it!=Map.end();++it)
    {
        if ((it->fs).fs<(it->fs).sc)
            continue;
        if (it->sc)
            cout<<(it->fs).fs<<" "<<(it->fs).sc<<" "<<it->sc<<"\n";
        else
            cout<<(it->fs).fs<<" "<<(it->fs).sc<<" "<<10000*MAX<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define INF (1LL<<52)
#define MAX 100000
#define pb push_back
#define mp make_pair
#define MOD 1000000007
typedef long long Int;
typedef pair<Int,Int> pii;
typedef vector<Int> vi;
typedef vector<pii> vii;
vii V;
vii G[1003];
bool flag=0;
Int n,m,L,s,t;
vector<pair<pii,Int> >Edges;
struct cmp
{
    bool operator ()(pii a,pii b)
    {
        return a.fs>b.fs;
    }
};
priority_queue<pii,vii,cmp>pq;
bool check(pii A,Int u,Int v)
{
    if (A.fs==u&&A.sc==v)
        return 1;
    if (A.fs==v&&A.sc==u)
        return 1;
    return 0;
}
Int dijkstra()
{
    vi d(n+1,INF);
    pq.push(mp(0,s));
    d[s]=0;
    while (!pq.empty())
    {
        Int x=pq.top().fs;
        Int y=pq.top().sc;
        pq.pop();
        if (x>d[y])
            continue;
        for (Int i=0;i<G[y].size();++i)
        {
            if (x+G[y][i].sc<d[G[y][i].fs])
            {
                d[G[y][i].fs]=x+G[y][i].sc;
                pq.push(mp(d[G[y][i].fs],G[y][i].fs));
            }
        }
    }
    return d[t];
}
Int dijkstra2(pii A)//A edge wt is 0
{
    flag=0;
    vi d(n+1,INF);
    vi par(n+1,-1);
    pq.push(mp(0,s));
    d[s]=0;
    par[s]=s;
    while (!pq.empty())
    {
        Int x=pq.top().fs;
        Int y=pq.top().sc;
        pq.pop();
        if (x>d[y])
            continue;
        for (Int i=0;i<G[y].size();++i)
        {
            Int e=G[y][i].sc;
            if (check(A,y,G[y][i].fs))
                e=0;
            if (x+e<d[G[y][i].fs])
            {
                par[G[y][i].fs]=y;
                d[G[y][i].fs]=x+e;
                pq.push(mp(d[G[y][i].fs],G[y][i].fs));
            }
        }
    }
    if (d[t]>L)
        return d[t];
    Int x=t;
    while (x!=s&&par[x]!=-1)
    {
        if (check(A,par[x],x))
            flag=1;
        x=par[x];
    }
    return d[t];
}
int main()
{
    cin>>n>>m>>L>>s>>t;
    for (Int i=0;i<m;++i)
    {
        Int u,v,w;
        cin>>u>>v>>w;
        if (w==0)
        {
            w=INF;
            V.pb(mp(u,v));
        }
        Edges.pb(mp(mp(u,v),w));
        G[u].pb(mp(v,w));
        G[v].pb(mp(u,w));
    }
    Int plen=dijkstra();
    if (plen<L)
    {
        cout<<"NO";
        return 0;
    }
    else if(plen==L)
    {
        cout<<"YES\n";
        for (Int i=0;i<Edges.size();++i)
            cout<<Edges[i].fs.fs<<" "<<Edges[i].fs.sc<<" "<<Edges[i].sc<<"\n";
        return 0;
    }
    for (Int i=0;i<V.size();++i)
    {
        plen=dijkstra2(mp(V[i].fs,V[i].sc));
        if (plen>L||flag==0)
            continue;
        cout<<"YES\n";
        for (Int j=0;j<Edges.size();++j)
        {
            if (check(Edges[j].fs,V[i].fs,V[i].sc))
            {
                Edges[j].sc=L-plen;
                break;
            }
        }
        for (Int j=0;j<Edges.size();++j)
            cout<<Edges[j].fs.fs<<" "<<Edges[j].fs.sc<<" "<<Edges[j].sc<<"\n";
        return 0;
    }
    cout<<"NO";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define MAX (Int)(1e14)
#define INF (Int)(1e18)
typedef long long Int;
typedef pair<Int,Int> pii;
typedef vector<Int> vi;
typedef vector<pii> vii;
Int n,m,L,s,t;
vi G[1002];
vii Edges,sedges;
Int w[1002][1002];
Int d[1002],par[1002];
struct cmp
{
    bool operator()(pii a,pii b)
    {
        return a.fs>b.fs;
    }
};
Int dijkstra()
{
    for (Int i=0;i<=n;++i)
    {
        d[i]=INF;
        par[i]=-1;
    }
    priority_queue<pii,vii,cmp>pq;
    pq.push(mp(0,s));
    d[s]=0;
    par[s]=s;
    while (!pq.empty())
    {
        Int x=pq.top().fs;
        Int y=pq.top().sc;
        pq.pop();
        if (x>d[y])
            continue;
        for (Int i=0;i<G[y].size();++i)
        {
            Int v=G[y][i];
            Int wt=w[y][v];
            if (wt)
            {
                if (x+wt<d[v])
                {
                    par[v]=y;
                    d[v]=x+wt;
                    pq.push(mp(d[v],v));
                }
                continue;
            }
            wt=MAX;
            if (x+wt<d[v])
            {
                par[v]=y;
                d[v]=x+wt;
                pq.push(mp(d[v],v));
            }
        }
    }
    return d[t];
}

int main()
{
    cin>>n>>m>>L>>s>>t;
    for (Int i=0;i<m;++i)
    {
        Int u,v,wt;
        cin>>u>>v>>wt;
        G[u].pb(v);
        G[v].pb(u);
        w[u][v]=w[v][u]=wt;
        if (wt==0)
            sedges.pb(mp(u,v));
        Edges.pb(mp(u,v));
    }
    Int plen;
    for (Int i=0;i<sedges.size();++i)
        w[sedges[i].fs][sedges[i].sc]=w[sedges[i].sc][sedges[i].fs]=1;
    while ((plen=dijkstra())<L)
    {
        //cout<<plen<<" Mark\n";
        //for (Int x=t;x!=s;x=par[x])
            //cout<<x<<" "<<par[x]<<"\n";
        for (Int i=0;i<sedges.size();++i)
        {
            //cout<<sedges[i].fs<<" "<<sedges[i].sc<<"\n";
            w[sedges[i].fs][sedges[i].sc]=w[sedges[i].sc][sedges[i].fs]=MAX;
        }
        sedges.clear();
        bool flag=0;
        for (Int x=t;x!=s;x=par[x])
        {
            if (w[x][par[x]]==MAX&&flag==0)
            {
                flag=1;
                w[x][par[x]]=w[par[x]][x]=L-plen+1;
                sedges.pb(mp(x,par[x]));
            }
            else if (w[x][par[x]]==MAX)
            {
                w[x][par[x]]=w[par[x]][x]=1;
                sedges.pb(mp(x,par[x]));
            }
        }
        /*for (Int i=0;i<sedges.size();++i)
        {
            cout<<sedges[i].fs<<" "<<sedges[i].sc<<"\n";
            //w[sedges[i].fs][sedges[i].sc]=w[sedges[i].sc][sedges[i].fs]=MAX;
        }*/
    }
    if (plen>L)
    {
        cout<<"NO";
        return 0;
    }
    cout<<"YES\n";
    for (Int i=0;i<Edges.size();++i)
        cout<<Edges[i].fs<<" "<<Edges[i].sc<<" "<<w[Edges[i].fs][Edges[i].sc]<<"\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define MAX (Int)(1e14)
#define INF (Int)(1e18)
typedef long long Int;
typedef pair<Int,Int> pii;
typedef vector<Int> vi;
typedef vector<pii> vii;
Int n,m,L,s,t;
vi G[1002];
vii Edges,sedges;
Int w[1002][1002];
Int d[1002],par[1002];
struct cmp
{
    bool operator()(pii a,pii b)
    {
        return a.fs>b.fs;
    }
};
Int dijkstra()
{
    for (Int i=0;i<=n;++i)
    {
        d[i]=INF;
        par[i]=-1;
    }
    priority_queue<pii,vii,cmp>pq;
    pq.push(mp(0,s));
    d[s]=0;
    par[s]=s;
    while (!pq.empty())
    {
        Int x=pq.top().fs;
        Int y=pq.top().sc;
        pq.pop();
        if (x>d[y])
            continue;
        for (Int i=0;i<G[y].size();++i)
        {
            Int v=G[y][i];
            Int wt=w[y][v];
            if (wt)
            {
                if (x+wt<d[v])
                {
                    par[v]=y;
                    d[v]=x+wt;
                    pq.push(mp(d[v],v));
                }
                continue;
            }
            wt=MAX;
            if (x+wt<d[v])
            {
                par[v]=y;
                d[v]=x+wt;
                pq.push(mp(d[v],v));
            }
        }
    }
    return d[t];
}
Int dijkstra2()
{
    for (Int i=0;i<=n;++i)
        d[i]=INF;
    priority_queue<pii,vii,cmp>pq;
    pq.push(mp(0,s));
    d[s]=0;
    while (!pq.empty())
    {
        Int x=pq.top().fs;
        Int y=pq.top().sc;
        pq.pop();
        if (x>d[y])
            continue;
        for (Int i=0;i<G[y].size();++i)
        {
            Int v=G[y][i];
            Int wt=w[y][v];
            if (wt==0)
                wt=MAX;
            if (x+wt<d[v])
            {
                d[v]=x+wt;
                pq.push(mp(d[v],v));
            }
        }
    }
    return d[t];
}
int main()
{
    cin>>n>>m>>L>>s>>t;
    for (Int i=0;i<m;++i)
    {
        Int u,v,wt;
        cin>>u>>v>>wt;
        G[u].pb(v);
        G[v].pb(u);
        w[u][v]=w[v][u]=wt;
        if (wt==0)
            sedges.pb(mp(u,v));
        Edges.pb(mp(u,v));
    }
    Int plen;
    if ((plen=dijkstra2())<L)
    {
        cout<<"NO";
        return 0;
    }
    else if (plen==L)
    {
        cout<<"YES\n";
        for (Int i=0;i<Edges.size();++i)
        {
            if (w[Edges[i].fs][Edges[i].sc])
                cout<<Edges[i].fs<<" "<<Edges[i].sc<<" "<<w[Edges[i].fs][Edges[i].sc]<<"\n";
            else
                cout<<Edges[i].fs<<" "<<Edges[i].sc<<" "<<MAX<<"\n";
        }
        return 0;
    }
    for (Int i=0;i<sedges.size();++i)
        w[sedges[i].fs][sedges[i].sc]=w[sedges[i].sc][sedges[i].fs]=1;
    while ((plen=dijkstra())<L)
    {
        for (Int i=0;i<sedges.size();++i)
            w[sedges[i].fs][sedges[i].sc]=w[sedges[i].sc][sedges[i].fs]=MAX;
        sedges.clear();
        bool flag=0;
        for (Int x=t;x!=s;x=par[x])
        {
            if (w[x][par[x]]==MAX&&flag==0)
            {
                flag=1;
                w[x][par[x]]=w[par[x]][x]=L-plen+1;
                sedges.pb(mp(x,par[x]));
            }
            else if (w[x][par[x]]==MAX)
            {
                w[x][par[x]]=w[par[x]][x]=1;
                sedges.pb(mp(x,par[x]));
            }
        }
    }
    if (plen>L)
    {
        cout<<"NO";
        return 0;
    }
    cout<<"YES\n";
    for (Int i=0;i<Edges.size();++i)
        cout<<Edges[i].fs<<" "<<Edges[i].sc<<" "<<w[Edges[i].fs][Edges[i].sc]<<"\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define MAX 10000000000
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF (Int)(1e18)
typedef long long Int;
typedef pair<Int,Int> pii;
typedef vector<Int> vi;
typedef vector<pii> vii;
vii Edges;
vii G[1002];
map<pii,Int>Map;
Int n,m,L,s,t;
Int d[1002][2];
pii par[1002][2];
struct cmp
{
    bool operator ()(pair<Int,pii>a,pair<Int,pii>b)
    {
        return a.sc.fs>b.sc.fs;
    }
};
priority_queue<pair<Int,pii>,vector<pair<Int,pii> >,cmp>pq;
void dijkstra()
{
    for (Int i=0;i<1002;++i)
    {
        d[i][0]=d[i][1]=(Int)INF;
        par[i][0]=par[i][1]=mp(-1,-1);
    }
    pq.push(mp(0,mp(s,0)));
    d[s][0]=0;
    par[s][0]=mp(s,0);
    while (!pq.empty())
    {
        pii u=pq.top().sc;
        Int x=pq.top().fs;
        pq.pop();
        if (x>d[u.fs][u.sc])
            continue;
        for (Int i=0;i<G[u.fs].size();++i)
        {
            Int v=G[u.fs][i].fs;
            Int w=G[u.fs][i].sc;
            if (w)
            {
                if (x+w<d[v][u.sc])
                {
                    par[v][u.sc]=u;
                    d[v][u.sc]=w+x;
                    pq.push(mp(d[v][u.sc],mp(v,u.sc)));
                }
                continue;
            }
            w=10000*MAX;
            if (x+w<d[v][1])
            {
                par[v][1]=u;
                d[v][1]=w+x;
                pq.push(mp(d[v][1],mp(v,1)));
            }
        }
    }
}
int main()
{
    cin>>n>>m>>L>>s>>t;
    for (Int i=0;i<m;++i)
    {
        Int u,v,w;
        cin>>u>>v>>w;
        G[u].pb(mp(v,w));
        G[v].pb(mp(u,w));
        Map[mp(u,v)]=w;
        Map[mp(v,u)]=w;
    }
    dijkstra();
    if (d[t][0]==L)
    {
        map<pii,Int>::iterator it;
        cout<<"YES\n";
        for (it=Map.begin();it!=Map.end();++it)
        {
            if ((it->fs).fs<(it->fs).sc)
                continue;
            if (it->sc)
                cout<<(it->fs).fs<<" "<<(it->fs).sc<<" "<<it->sc<<"\n";
            else
                cout<<(it->fs).fs<<" "<<(it->fs).sc<<" "<<10000*MAX<<"\n";
        }
        return 0;
    }
    if (d[t][0]<L||d[t][1]==INF)
    {
        cout<<"NO";
        return 0;
    }
    //cout<<d[t][1]<<"\n";
    pii u=mp(t,1);//current node
    while (u.fs!=s||u.sc!=0)
    {
        pii v=par[u.fs][u.sc];
        Int w=Map[mp(u.fs,v.fs)];
        if (w==0)
            Edges.pb(mp(u.fs,v.fs));
        u=v;
    }
    //for (Int i=0;i<Edges.size();++i)
        //cout<<Edges[i].fs<<" "<<Edges[i].sc<<"\n";
    if (d[t][1]-10000*MAX*Edges.size()+Edges.size()>L)
    {
        cout<<"NO";
        return 0;
    }
    for (Int i=0;i<Edges.size()-1;++i)
    {
        Map[mp(Edges[i].fs,Edges[i].sc)]=1;
        Map[mp(Edges[i].sc,Edges[i].fs)]=1;
    }
    Int x=d[t][1]-10000*MAX*Edges.size()+Edges.size()-1;
    x=L-x;
    Map[mp(Edges[Edges.size()-1].fs,Edges[Edges.size()-1].sc)]=x;
    Map[mp(Edges[Edges.size()-1].sc,Edges[Edges.size()-1].fs)]=x;
    map<pii,Int>::iterator it;
    cout<<"YES\n";
    for (it=Map.begin();it!=Map.end();++it)
    {
        if ((it->fs).fs<(it->fs).sc)
            continue;
        if (it->sc)
            cout<<(it->fs).fs<<" "<<(it->fs).sc<<" "<<it->sc<<"\n";
        else
            cout<<(it->fs).fs<<" "<<(it->fs).sc<<" "<<10000*MAX<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define INF (1LL<<52)
#define MAX 100000
#define pb push_back
#define mp make_pair
#define MOD 1000000007
typedef long long Int;
typedef pair<Int,Int> pii;
typedef vector<Int> vi;
typedef vector<pii> vii;
vii V;
vii G[1003];
bool flag=0;
Int n,m,L,s,t;
vector<pair<pii,Int> >Edges;
struct cmp
{
    bool operator ()(pii a,pii b)
    {
        return a.fs>b.fs;
    }
};
priority_queue<pii,vii,cmp>pq;
bool check(pii A,Int u,Int v)
{
    if (A.fs==u&&A.sc==v)
        return 1;
    if (A.fs==v&&A.sc==u)
        return 1;
    return 0;
}
Int dijkstra()
{
    vi d(n+1,INF);
    pq.push(mp(0,s));
    d[s]=0;
    while (!pq.empty())
    {
        Int x=pq.top().fs;
        Int y=pq.top().sc;
        pq.pop();
        if (x>d[y])
            continue;
        for (Int i=0;i<G[y].size();++i)
        {
            if (x+G[y][i].sc<d[G[y][i].fs])
            {
                d[G[y][i].fs]=x+G[y][i].sc;
                pq.push(mp(d[G[y][i].fs],G[y][i].fs));
            }
        }
    }
    return d[t];
}
Int dijkstra2(pii A)//A edge wt is 0
{
    flag=0;
    vi d(n+1,INF);
    vi par(n+1,-1);
    pq.push(mp(0,s));
    d[s]=0;
    par[s]=s;
    while (!pq.empty())
    {
        Int x=pq.top().fs;
        Int y=pq.top().sc;
        pq.pop();
        if (x>d[y])
            continue;
        for (Int i=0;i<G[y].size();++i)
        {
            Int e=G[y][i].sc;
            if (check(A,y,G[y][i].fs))
                e=0;
            if (x+e<d[G[y][i].fs])
            {
                par[G[y][i].fs]=y;
                d[G[y][i].fs]=x+e;
                pq.push(mp(d[G[y][i].fs],G[y][i].fs));
            }
        }
    }
    if (d[t]>L)
        return d[t];
    Int x=t;
    while (x!=s&&par[x]!=-1)
    {
        if (check(A,par[x],x))
            flag=1;
        x=par[x];
    }
    return d[t];
}
int main()
{
    cin>>n>>m>>L>>s>>t;
    for (Int i=0;i<m;++i)
    {
        Int u,v,w;
        cin>>u>>v>>w;
        if (w==0)
        {
            w=INF;
            V.pb(mp(u,v));
        }
        Edges.pb(mp(mp(u,v),w));
        G[u].pb(mp(v,w));
        G[v].pb(mp(u,w));
    }
    Int plen=dijkstra();
    if (plen<L)
    {
        cout<<"NO";
        return 0;
    }
    else if(plen==L)
    {
        cout<<"YES\n";
        for (Int i=0;i<Edges.size();++i)
            cout<<Edges[i].fs.fs<<" "<<Edges[i].fs.sc<<" "<<Edges[i].sc<<"\n";
        return 0;
    }
    for (Int i=0;i<V.size();++i)
    {
        plen=dijkstra2(mp(V[i].fs,V[i].sc));
        if (plen>=L||flag==0)//this problem >=
            continue;
        cout<<"YES\n";
        for (Int j=0;j<Edges.size();++j)
        {
            if (check(Edges[j].fs,V[i].fs,V[i].sc))
            {
                Edges[j].sc=L-plen;
                break;
            }
        }
        for (Int j=0;j<Edges.size();++j)
            cout<<Edges[j].fs.fs<<" "<<Edges[j].fs.sc<<" "<<Edges[j].sc<<"\n";
        return 0;
    }
    cout<<"NO";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define INF (1LL<<52)
#define MAX 100000
#define pb push_back
#define mp make_pair
#define MOD 1000000007
typedef long long Int;
typedef pair<Int,Int> pii;
typedef vector<Int> vi;
typedef vector<pii> vii;
vii V;
vii G[1003];
bool flag=0;
Int n,m,L,s,t;
vector<pair<pii,Int> >Edges;
struct cmp
{
    bool operator ()(pii a,pii b)
    {
        return a.fs>b.fs;
    }
};
priority_queue<pii,vii,cmp>pq;
bool check(pii A,Int u,Int v)
{
    if (A.fs==u&&A.sc==v)
        return 1;
    if (A.fs==v&&A.sc==u)
        return 1;
    return 0;
}
Int dijkstra()
{
    vi d(n+1,INF);
    pq.push(mp(0,s));
    d[s]=0;
    while (!pq.empty())
    {
        Int x=pq.top().fs;
        Int y=pq.top().sc;
        pq.pop();
        if (x>d[y])
            continue;
        for (Int i=0;i<G[y].size();++i)
        {
            if (x+G[y][i].sc<d[G[y][i].fs])
            {
                d[G[y][i].fs]=x+G[y][i].sc;
                pq.push(mp(d[G[y][i].fs],G[y][i].fs));
            }
        }
    }
    return d[t];
}
Int dijkstra2(pii A)//A edge wt is 0
{
    flag=0;
    vi d(n+1,INF);
    vi par(n+1,-1);
    pq.push(mp(0,s));
    d[s]=0;
    par[s]=s;
    while (!pq.empty())
    {
        Int x=pq.top().fs;
        Int y=pq.top().sc;
        pq.pop();
        if (x>d[y])
            continue;
        for (Int i=0;i<G[y].size();++i)
        {
            Int e=G[y][i].sc;
            if (check(A,y,G[y][i].fs))
                e=0;
            if (x+e<d[G[y][i].fs])
            {
                par[G[y][i].fs]=y;
                d[G[y][i].fs]=x+e;
                pq.push(mp(d[G[y][i].fs],G[y][i].fs));
            }
        }
    }
    if (d[t]>L)
        return d[t];
    Int x=t;
    while (x!=s&&par[x]!=-1)
    {
        if (check(A,par[x],x))
            flag=1;
        x=par[x];
    }
    return d[t];
}
int main()
{
    cin>>n>>m>>L>>s>>t;
    for (Int i=0;i<m;++i)
    {
        Int u,v,w;
        cin>>u>>v>>w;
        if (w==0)
        {
            w=INF;
            V.pb(mp(u,v));
        }
        Edges.pb(mp(mp(u,v),w));
        G[u].pb(mp(v,w));
        G[v].pb(mp(u,w));
    }
    Int plen=dijkstra();
    if (plen<L)
    {
        cout<<"NO";
        return 0;
    }
    else if(plen==L)
    {
        cout<<"YES\n";
        for (Int i=0;i<Edges.size();++i)
            cout<<Edges[i].fs.fs<<" "<<Edges[i].fs.sc<<" "<<Edges[i].sc<<"\n";
        return 0;
    }
    for (Int i=0;i<V.size();++i)
    {
        plen=dijkstra2(mp(V[i].fs,V[i].sc));
        if (plen>L||flag==0)
            continue;
        cout<<"YES\n";
        for (Int j=0;j<Edges.size();++j)
        {
            if (check(Edges[j].fs,V[i].fs,V[i].sc))
                Edges[j].sc=L-plen;
        }
        for (Int j=0;j<Edges.size();++j)
            cout<<Edges[j].fs.fs<<" "<<Edges[j].fs.sc<<" "<<Edges[j].sc<<"\n";
        return 0;
    }
    cout<<"NO";
    return 0;
}


#include <stdio.h> // PLEASE
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cassert>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>

using namespace std;
typedef long long ll;
typedef pair <ll, ll> pp;
#define MAXN 1005
#define MAXM 10005
#define MAXP 25
#define INF 2000000000
#define A first
#define B second
#define MP make_pair
int N, M, s, t;
ll z, L, x, y;
bool bad[MAXN][MAXN];
ll baddist[MAXN][MAXN];
vector <pp> adj[MAXN];
ll d[MAXN];
int visited[MAXN];
pair <ll, pp> edge[MAXM];
bool notyet[MAXN][MAXN];

bool in(ll a, ll b)
{
	if(d[a]+baddist[a][b] == d[b]) return true;
	if(d[b]+baddist[b][a] == d[a]) return true;
	return false;
}
int main(void)
{
	scanf("%d%d%lld%d%d", &N, &M, &L, &s, &t);
		int cnt = 0;
	for(int i=0; i<M; i++) {
		scanf("%lld%lld%lld", &x, &y, &z);
		if(z == 0) {
			bad[x][y] = true;
			bad[y][x] = true;
			notyet[x][y] = true;
			notyet[y][x] = true;
			baddist[x][y] = 1;
			baddist[y][x] = 1;
			z=1;
		}
		//printf("%lld %lld %lld\n", x, y, z);
		edge[i] = MP(x, MP(y, z));
		adj[x].push_back(pp(y, z));
		adj[y].push_back(pp(x, z));
	}
	int f = 0;
	while(f != 1) {
		f = 1;
		memset(visited, 0, sizeof(visited));
		priority_queue<pp, vector<pp>, greater<pp> > PQ;
		d[s] = 0;
		PQ.push(pp(0, s));
		while(!PQ.empty()) {
			ll val = PQ.top().first;
			ll cur = PQ.top().second;
			PQ.pop();
			if(visited[cur]) continue;
			visited[cur] = 1;
			d[cur] = val;
			for(int i=0; i<adj[cur].size(); i++) {
				ll nxt = adj[cur][i].first;
				if(notyet[cur][nxt]) PQ.push(pp(val+baddist[cur][nxt], nxt));
				else PQ.push(pp(val+adj[cur][i].second, adj[cur][i].first));
			}
		}
		if(d[t] == L) {
			printf("YES\n");
			for(int i=0; i<M; i++) {
				printf("%lld %lld %lld\n", edge[i].A, edge[i].B.A, edge[i].B.B);
			}
			return 0;
		}
		if(d[t] > L) break;
		for(int i=0; i<M; i++) {
			ll a = edge[i].A;
			ll b = edge[i].B.A;
			if(!bad[a][b]) continue;
			if(in(a, b)) {
				cnt++;
				edge[i].B.B = L-d[t]+baddist[a][b];
				baddist[a][b] = edge[i].B.B;
				baddist[b][a] = edge[i].B.B;
				bad[a][b] = false;
				bad[b][a] = false;
				f = 0;
				break;
			}
		}
		if(cnt == N) break;
	}
	printf("NO\n");
}


#include <stdio.h> // PLEASE
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cassert>
#include <math.h>
#include <limits.h>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
typedef pair <ll, ll> pp;
#define MAXN 1005
#define MAXM 10005
#define MAXP 25
#define INF 2000000000
#define A first
#define B second
#define MP make_pair
ll N, M, L, st, e;
ll wt[MAXM], a[MAXM], b[MAXM], good[MAXM];
ll d1[MAXN], d2[MAXN], need;
vector <pp> adj[MAXN];

void dijk(ll *dist, ll f)
{
	set <pp> pq;
	for(ll i=0; i<N; i++) dist[i] = INF;
	dist[st] = 0;
	for(ll i=0; i<N; i++) pq.insert(MP(dist[i], i));
	while(!pq.empty()) {
		ll v = pq.begin()->second;
		pq.erase(pq.begin());
		for(ll i=0; i<adj[v].size(); i++) {
			ll e = adj[v][i].first;
			ll u = adj[v][i].second;
			if(dist[u] > dist[v] + wt[e]) {
				if(f) {
					if(good[e]) if(dist[v] + wt[e] < d1[u] + need) wt[e] = d1[u] + need - dist[v];
				}
			}
			if(dist[u] > dist[v] + wt[e]) {
				pq.erase(MP(dist[u], u));
				dist[u] = dist[v] + wt[e];
				pq.insert(MP(dist[u], u));
			}
		}
	}
}
ll main()
{
	cin >> N >> M >> L >> st >> e;
	for(ll i=0; i<M; i++)
	{
		cin >> a[i];
		cin >> b[i];
		adj[a[i]].push_back(pp(i, b[i]));
		adj[b[i]].push_back(pp(i, a[i]));
		cin >> wt[i];
		if(wt[i] == 0) good[i] = wt[i] = 1;
	}

	dijk(d1, 0);

	if(d1[e] > L) {
		printf("NO\n");
		return 0;
	}
	need = L-d1[e];
	dijk(d2, 1);
	if(d2[e] != L) {
		printf("NO\n");
		return 0;
	}

	prllf("YES\n");
	for(ll i=0; i<M; i++) {
		printf("%d %d %d\n", a[i], b[i], wt[i]);
	}
}


#include <stdio.h> // PLEASE
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cassert>
#include <math.h>
#include <limits.h>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
typedef pair <int, int> pp;
#define MAXN 1005
#define MAXM 10005
#define MAXP 25
#define INF 2000000000
#define A first
#define B second
#define MP make_pair
int N, M, L, st, e;
int wt[MAXM], a[MAXM], b[MAXM], good[MAXM];
int d1[MAXN], d2[MAXN], need;
vector <pp> adj[MAXN];

void dijk(int *dist, int f)
{
	set <pp> pq;
	for(int i=0; i<N; i++) dist[i] = INF;
	dist[st] = 0;
	for(int i=0; i<N; i++) pq.insert(MP(dist[i], i));
	while(!pq.empty()) {
		int v = pq.begin()->second;
		pq.erase(pq.begin());
		for(int i=0; i<adj[v].size(); i++) {
			int e = adj[v][i].first;
			int u = adj[v][i].second;
			if(dist[u] > dist[v] + wt[e]) {
				if(f) {
					if(good[e]) if(dist[v] + wt[e] < d1[u] + need) wt[e] = d1[u] + need - dist[v];
				}
			}
			if(dist[u] > dist[v] + wt[e]) {
				pq.erase(MP(dist[u], u));
				dist[u] = dist[v] + wt[e];
				pq.insert(MP(dist[u], u));
			}
		}
	}
}
int main()
{
	cin >> N >> M >> L >> st >> e;
	for(int i=0; i<M; i++)
	{
		cin >> a[i];
		cin >> b[i];
		adj[a[i]].push_back(pp(i, b[i]));
		adj[b[i]].push_back(pp(i, a[i]));
		cin >> wt[i];
		if(wt[i] == 0) good[i] = wt[i] = 1;
	}

	dijk(d1, 0);

	if(d1[e] > L) {
		printf("NO\n");
		return 0;
	}
	need = L-d1[e];
	dijk(d2, 1);
	if(d2[e] != L) {
		printf("NO\n");
		return 0;
	}

	printf("YES\n");
	for(int i=0; i<M; i++) {
		printf("%d %d %d\n", a[i], b[i], wt[i]);
	}
}


#include <stdio.h> // PLEASE
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cassert>
#include <math.h>
#include <limits.h>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
typedef pair <ll, ll> pp;
#define MAXN 1005
#define MAXM 10005
#define MAXP 25
#define INF 2000000000
#define A first
#define B second
#define MP make_pair
ll N, M, L, st, e;
ll wt[MAXM], a[MAXM], b[MAXM], good[MAXM];
ll d1[MAXN], d2[MAXN], need;
vector <pp> adj[MAXN];

void dijk(ll *dist, ll f)
{
	set <pp> pq;
	for(ll i=0; i<N; i++) dist[i] = INF;
	dist[st] = 0;
	for(ll i=0; i<N; i++) pq.insert(MP(dist[i], i));
	while(!pq.empty()) {
		ll v = pq.begin()->second;
		pq.erase(pq.begin());
		for(ll i=0; i<adj[v].size(); i++) {
			ll e = adj[v][i].first;
			ll u = adj[v][i].second;
			if(dist[u] > dist[v] + wt[e]) {
				if(f) {
					if(good[e]) if(dist[v] + wt[e] < d1[u] + need) wt[e] = d1[u] + need - dist[v];
				}
			}
			if(dist[u] > dist[v] + wt[e]) {
				pq.erase(MP(dist[u], u));
				dist[u] = dist[v] + wt[e];
				pq.insert(MP(dist[u], u));
			}
		}
	}
}
int main()
{
	cin >> N >> M >> L >> st >> e;
	for(ll i=0; i<M; i++)
	{
		cin >> a[i];
		cin >> b[i];
		adj[a[i]].push_back(pp(i, b[i]));
		adj[b[i]].push_back(pp(i, a[i]));
		cin >> wt[i];
		if(wt[i] == 0) good[i] = wt[i] = 1;
	}

	dijk(d1, 0);

	if(d1[e] > L) {
		printf("NO\n");
		return 0;
	}
	need = L-d1[e];
	dijk(d2, 1);
	if(d2[e] != L) {
		printf("NO\n");
		return 0;
	}

	printf("YES\n");
	for(ll i=0; i<M; i++) {
		printf("%d %d %d\n", a[i], b[i], wt[i]);
	}
}


t=int(input())
for _ in range(t):
    n=int(input())
    l=list(map(int,input().split()))
    l.sort()
    m=l[1]-l[0]
    for i in range(n-1):
        m=min(m,l[i+1]-l[i])
    print(m)


t=int(input())
for _ in range(t):
    n=int(input())
    l=list(map(int,input().split()))
    l.sort()
    m=l[1]=l[0]
    for i in range(n-1):
        m=min(m,l[i+1]-l[i])
    print(m)


t=int(input())
for _ in range(t):
    n=int(input())
    ls=list(map(int,input().split()))
    for i in ls:
        if ls.count(i)>=2:
            print("0")
            break
    else:
        ls.sort()
        print(ls[1]-ls[0])


t=int(input())
for _ in range(t):
	n=int(input())
	ls=list(map(int,input().split()))
	ls.sort()
	tmp=ls[-1]
	for i in range(1,n):
		if tmp>ls[i]-ls[i-1]:
			tmp=ls[i]-ls[i-1]
		if tmp==0:
			break
	print(tmp)


t=int(input())
for i in range(t):
    n=int(input())
    str1=input()
    list1=list(map(int,str1.split( )))
    list1.sort()
    list2=['']
    m=0
    while m<(len(list1)-1):
        list2.append(list1[m+1]-list1[m])
        m=m+1
    list2=list2[1::]
    print(min(list2))


t=int(input())
for i in range(t):
    n=int(input())
    str1=input()
    list1=list(map(int,str1.split( )))
    list1.sort()
    list2=['']
    for g in range(len(list1)-1):
        list2.append(list1[i+1]-list1[i])
    list2=list2[1::]
    print(min(list2))


t=int(input())
for i in range(t):
    n=int(input())
    str1=input()
    list1=list(map(int,str1.split( )))
    list1.sort()
    list2=['']
    for g in range(len(list1)-2):
        list2.append(list1[i+1]-list1[i])
    print(min(list2))


t=int(input())
for i in range(t):
    n=int(input())
    str1=input()
    list1=list(map(int,str1.split( )))
    list1.sort()
    list2=['']
    m=0
    while m<(len(list1)-1:
        list2.append(list1[m+1]-list1[m])
        m=m+1
    list2=list2[1::]
    print(min(list2))


t=int(input())
for i in range(t):
    n=int(input())
    str1=input()
    list1=list(map(int,str1.split( )))
    list1.sort()
    list2=['']
    for g in range(len(list1)-2):
        list2.append(list1[i+1]-list1[i])
    list2[1::]
    print(min(list2))


t=int(input())
for i in range(t):
    n=int(input())
    str1=input()
    list1=list(map(int,str1.split( )))
    list1.sort()
    list2=('')
    for g in range(len(list1)-2):
        list2.append(list1[i+1]-list1[i])
        list2=list2[1::]
    print(min(list2))


t=int(input())
for i in range(t):
    n=int(input())
    str1=input()
    list1=list(map(int,str1.split( )))
    list1.sort()
    list2=['']
    for g in range(len(list1)-2):
        list2.append(list1[i+1]-list1[i])
    list2=list2[1::]
    print(min(list2))


t=int(input())
for i in range(t):
    n=int(input())
    str1=input()
    list1=list(map(int,str1.split( )))
    list1.sort()
    list2=['']
    for g in range(len(list1)-2):
        list2.append(list1[i+1]-list1[i])
        list2=list2[1::]
    print(min(list2))


t=int(input())
for i in range(t):
    n=int(input())
    str1=input()
    list1=list(map(int,str1.split( )))
    list1.sort()
    list2=['']
    for g in range(len(list1)):
        list2.append(list1[i+1]-list1[i])
    list2=list2[1::]
    print(min(list2))


t = int(input())
for _ in range(t):
    n = int(input())
    s = [int(i) for i in input().split()]
    s.sort()
    m = 1000
    for i in range(1, len(s)):
        dif = s[i] - s[i-1]
        if  dif < m:
            m = dif
    print(m)


t = int(input())
for _ in range(t):
    n = int(input())
    s = [int(a) for i in input().split()]
    s.sort()
    m = 0
    for i in range(1, len(s)):
        if s[i] - s[i-1] == 0:
            break
        else:
            m = s[i] - s[i-1]
    print(m)


# https://codeforces.com/problemset/problem/1360/B
# 800

t = int(input())

for _ in range(t):
    n = input()

    min_diff = float("inf")
    a = list(map(int, input().split()))
    a.sort()
    ps = None
    for s in a:
        if ps is not None:
            diff = abs(ps - s)
            print(diff)
            min_diff = min(diff, min_diff)

        ps = s

    print(min_diff)


# https://codeforces.com/problemset/problem/1360/B
# 800

t = int(input())

for _ in range(t):
    n = input()

    min_diff = float("inf")
    a = list(map(int, input().split()))
    a.sort()
    ps = None
    for s in a:
        if ps is not None:
            diff = abs(ps - s)
            min_diff = min(diff, min_diff)

        ps = s

    print(min_diff)


for _ in range(int(input())):
	a = int(input())
	z = sorted(list(map(int,input().split())))
	if len(set(z))!=a:print(0)
	else:
		x = 1000
		for i in range(1,a):
			q = abs(z[i]-z[i-1])
			if q<2:x = 1;break
			else:x = min(x,q)
		print(x)


for _ in range(int(input())):
	a = int(input())
	z = sorted(list(map(int,input().split())))
	if len(set(z))!=a:print(0)
	else:print(z[-1]-z[-2])


def findMinDiff(arr, n):
    diff = 10 ** 20
    for i in range(n - 1):
        for j in range(i + 1, n):
            if abs(arr[i] - arr[j]) < diff:
                diff = abs(arr[i] - arr[j])
    return diff
t = int(input())
for i in range(t):
    k = int(input())
    a = [x for x in map(int,input().split())]
    print(findMinDiff(a,k))


def findMinDiff(arr, n):
    diff = 10**20
    for i in range(n-1):
        for j in range(i+1,n):
            if abs(arr[i]-arr[j]) < diff:
                diff = abs(arr[i] - arr[j])
    return diff
k = int(input())
a = [x for x in map(int,input().split())]
print(findMinDiff(a,k))


t = int(input())
for i in range(t):
    k = int(input())
    a = [x for x in map(int,input().split())]
    differ = abs(a[0] - a[1])
    fl = True
    for i in range(k-1):
        if a.count(a[i]) > 1:
            print(0)
            fl = False
            break
        elif abs(a[i+1] - a[i]) < differ:
            differ = abs(a[i + 1] - a[i-1])
    if fl:
        print(differ)


# def findMinDiff(arr:list):
#     for i in arr:
#         if arr.count(i) > 1:
#             return 0
#     m1 = max(arr)
#     arr.remove(m1)
#     m2 = max(arr)
#     return abs(m1-m2)
k = int(input())
a = [x for x in map(int,input().split())]
differ = abs(a[0] - a[1])
fl = True
for i in range(k-1):
    if a.count(a[i]) > 1:
        print(0)
        fl = False
        break
    elif abs(a[i+1] - a[i]) < differ:
        differ = abs(a[i + 1] - a[i-1])
if fl:
    print(differ)


z = int(input())
for q in range(z):
    x = int(input())
    lst = [int(i) for i in input().split()]
    lst.sort()
    if len(lst)==2:
        print (lst[1]-lst[0])
        continue
    s = None
    for i in range(len(lst)-2):
        if s is None:
            s = lst[i+1]-lst[i]
            continue
        tmp = lst[i+1]-lst[i]
        if tmp<s:
            s = tmp
    print (s)


z = int(input())
for q in range(z):
    x = int(input())
    lst = [int(i) for i in input().split()]
    lst.sort()
    if len(lst)==2:
        print (lst[1]-lst[0])
        continue
    s = None
    for i in range(len(lst)-1):
        if s is None:
            s = lst[i+1]-lst[i]
            continue
        tmp = lst[i+1]-lst[i]
        if tmp<s:
            s = tmp
    print (s)


t = int(input())
while t > 0:
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    res = 1001
    for i in range(1, n):
        res = min(res, a[i] - a[i - 1])
    print(res)
    t -= 1


t = int(input())
while t > 0:
    n = int(input())
    a = list(map(int, input().split()))
    res = 1001
    for i in range(1, n):
        res = min(res, a[i] - a[i - 1])
    print(res)
    t -= 1


n=int(input())
for i in range(n):
    k = int(input())
    x = list(map(int, input().split()))
    x.sort()
    m=x[-1]
    x
    for j in range(k):
        if m>x[i+1]-x[i]:
            m=x[i+1]-x[i]
    print(m)


n=int(input())
for i in range(n):
    k = int(input())
    x = list(map(int, input().split()))
    x.sort()
    m=x[-1]
    for j in range(1,len(x)):
        if m>x[j]-x[j-1]:
            m=x[j]-x[j-1]
    print(m)


import sys
mx = sys.maxsize
n = int(input())
for i in range(n):
    t = int(input())
    arr = list(map(int,input().split(' ')))
    arr = sorted(arr)
    for j in range(len(arr)-1):
        mx = min(mx,abs(arr[j]-arr[j+1]))
print(mx)


import sys
n = int(input())
for i in range(n):
    mx = sys.maxsize
    t = int(input())
    arr = list(map(int,input().split(' ')))
    arr = sorted(arr)
    for j in range(len(arr)-1):
        mx = min(mx,abs(arr[j]-arr[j+1]))
    print(mx)


import sys
mx = sys.maxint
n = int(input())
for i in range(n):
    t = int(input())
    arr = list(map(int,input()))
    sorted(arr)
    for j in range(len(arr)-1):
        mx = min(mx,abs(arr[j]-arr[j+1]))
print(mx)


import sys
mx = sys.maxsize
n = int(input())
for i in range(n):
    t = int(input())
    arr = list(map(int,input().split(' ')))
    arr = sorted(arr)
    for j in range(len(arr)-1):
        mx = min(mx,abs(arr[j]-arr[j+1]))
    print(mx)


def func(n):
    for i in range(n):
        inp = int(input())
        k = list(map(int,input().split()))
        flag = True
        for i in k:
            if k.count(i)>1:
                print(0)
                flag = False
                break
        if flag:
            k.sort()
            a = k[:1]
            b = k[1:]
            print(abs(a[0]-min(b)))
n = int(input())
func(n)


def func(n):
    for i in range(n):
        inp = int(input())
        k = list(map(int,input().split()))
        k.sort()
        minimum = 1000
        for i in range(len(k)-1):
            if k[i+1]-k[i] < minimum:
                minimum = k[i+1]-k[i]
        print(minimum)
n = int(input())
func(n)


t = int(input())
s = []
for i in range(t):
    n = int(input())
    s = [int(i) for i in input().split()]
    copy = s[:]
    if len(set(s)) < len(s):
        print(0)
    else:
        a = min(s)
        s.remove(min(s))
        b = min(s)
        c = max(copy)
        copy.remove(max(copy))
        d = max(copy)
        print(min(b - a, c - d))


t = int(input())
s = []
for i in range(t):
    n = int(input())
    s = [int(i) for i in input().split()]
    if len(set(s)) < len(s):
        print(0)
    else:
        a = min(s)
        s.remove(min(s))
        b = min(s)
        print(b - a)


t = int(input())
s = []
for i in range(t):
    n = int(input())
    s = [int(i) for i in input().split()]
    copy = s[:]
    a = min(s)
    s.remove(min(s))
    b = min(s)
    c = max(copy)
    copy.remove(max(copy))
    d = max(copy)
    print(min(b - a, c - d))


t = int(input())
for i in range(t):
    n = int(input())
    x = []
    z = 0
    y = 1
    s = [int(i) for i in input().split()]
    while z != n - 1:
        for j in range(y, n):
            x.append(((s[z] - s[j])**2)**0.5)
        z += 1
        y += 1
    print(int(min(x)))


for _ in range(int(input())):
    n = int(input())
    l = list(map(int,input().split()))
    l.sort()
    i = 1
    o = []
    while(i < len(l)):
        s = abs(l[i]-l[i-1])
        o.append(s)
        i = i+1

    o.sort()
    print(o[-1])


for _ in range(int(input())):
    n = int(input())
    l = list(map(int,input().split()))
    l.sort()
    i = 1
    o = []
    while(i < len(l)):
        s = abs(l[i]-l[i-1])
        o.append(s)
        i = i+1

    o.sort()
    print(o[0])


for _ in range(int(input())):
    n = int(input())
    l = list(map(int,input().split()))
    d = set()
    f = 0
    for i in l:
        if i in d:
            f = 1
            break

        else:
            d.add(i)

    if f == 1:
        print(0)

    else:
        l.sort()
        x = l[-1]
        y = l[-2]
        print(abs(x - y))


t=int(input())

for i in range(t):
    n=int(input())
    s=list(map(int,input().split()))
    s.sort()
    ans=9999
    zero=False
    for j in range(len(s)-1):
        if abs(s[j]-s[j+1])==0:
            print(0)
            zero=True
            break
        elif abs(s[j]-s[j+1])<ans:
            ans=abs(s[j]-s[j+1])

    if not zero:
        print(ans)


t=int(input())

for i in range(t):
    n=int(input())
    s=list(map(int,input().split()))
    s.sort()
    ans=9999
    zero=False
    for j in range(len(s)-2):
        if abs(s[j]-s[j+1])==0:
            print(0)
            zero=True
            break
        elif abs(s[j]-s[j+1])<ans:
            ans=abs(s[j]-s[j+1])
    if len(s)==2:
        print(abs(s[0]-s[1]))
    elif not zero:
        print(ans)


t=int(input())

for i in range(t):
    n=int(input())
    s=list(map(int,input().split()))
    s.sort()
    ans=9999
    zero=False
    for j in range(len(s)-2):
        if abs(s[j]-s[j+1])==0:
            print(0)
            zero=True
            break
        elif abs(s[j]-s[j+1])<ans:
            ans=abs(s[j]-s[j+1])
    if not zero:
        print(ans)


t = int(input())
i = 1
while i <= t:

    n = int(input())
    list1 = list(map(int, input().split()))

    minn = 10000

    list1.sort()

    for j in range(n - 1):
        diff = list1[j + 1] - list1[j]
        minn = min(minn, diff)
    print(minn)
    i=i+1


t=int(input())
i=0
while i<=t:
    i=i+1
    n=int(input())
    list=sorted(map(int,input().split()))

    minn=10000

    for j in range(n-1):
        diff=list[j+1]-list[j]
        minn=min(minn,diff)
    print(minn)


from typing import List

t = int(input())
i = 0
while i <= t:
    i = i + 1
    n = int(input())
    list1 = list(map(int, input().split()))

    minn = 10000

    list1.sort()

    for j in range(n - 1):
        diff = list1[j + 1] - list1[j]
        minn = min(minn, diff)
    print(minn)


t=int(input())
for _ in range (t):
    n=int(input())
    a=str(input()).split(" ")
    for i in range (n):
        a[i]=int(a[i])
    a.sort()
    l=[]
    for i in range (n-1):
    	l.append(a[i+1]-a[i])
    l.sort()
    print(l[0])


t=int(input())
for _ in range(t):
    n=int(input())
    a=str(input()).split(" ")
    for j in range (n):
        a[j]=int(a[j])
    a.sort()
    l=[]
    for i in range (n-1):
    	l.append(a[i+1]-a[i])
    l.sort()
    print(l[0])


import os,io
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

t = int(input())
for _ in range(t):
    n = int(input())
    s = list(map(input().split()))
    s.sort()
    minDiff = 1001
    for i in range(n-1):
        if s[i+1] - s[i] < minDiff:
            minDiff = s[i+1] - s[i]
    print(minDiff)


import os,io
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

t = int(input())
for _ in range(t):
    n = int(input())
    s = list(map(int,input().split()))
    s.sort()
    minDiff = 1001
    for i in range(n-1):
        if s[i+1] - s[i] < minDiff:
            minDiff = s[i+1] - s[i]
    print(minDiff)


def absdif(p,q):
    if p>q:
        return p-q;
    elif q>p:
        return q-p;
    else:
        return 0;
def small(a,n):
    min=absdif(a[0],a[1])
    for i in range(n):
        for j in range(i+1,n):
            b=absdif(a[i],a[j])
            if min>b:
                min=b
            else:
                continue
        i=i+1
    return min;
t=int(input())
for i in range(t):
    n=int(input())
    a=list(map(int,input().split()))
    print(small(a,n))


t=int(input())
k=[]
def absdif(p,q):
    if p>q:
        return p-q;
    elif q>p:
        return q-p;
    else:
        return 0;
def small(a,n):
    min=absdif(a[0],a[1])
    for i in range(n):
        for j in range(i+1,n-1):
            b=absdif(a[i],a[j])
            if min>b:
                min=b
        i=i+1
    return min;

b=[]
for i in range(t):
    n=int(input())
    a=list(map(int,input().split()))
    b.append(small(a,n))
for x in b:
    print(x)


for t in range(int(input())):
    n=int(input())
    li = list(map(int,input().split()))

    li.sort()
    a = max(li)
    for i in range(n-1):
        if a > li[i+1]-li[i]:
            a = li[i+1]-li[i]
    print(a)


t = int(input())
for i in range(t):
    n = int(input())
    num = n / 2
    listt = list(map(int, input().split()))
    listd = list(set(listt))
    listt.sort()
    listd.sort()
    if listt != listd:
        print("0")
    elif n % 2 != 0:
        if abs(listt[int(num - 1.5)] - listt[int(num - 0.5)]) > abs(listt[int(num - 0.5)] - listt[int(num + 0.5)]):
            print(abs(listt[int(num - 0.5)] - listt[int(num + 0.5)]))
        else:
            print(abs(listt[int(num - 1.5)] - listt[int(num - 0.5)]))
    else:
        if abs(listt[int(num - 2)] - listt[int(num - 1)]) > abs(listt[int(num - 1)] - listt[int(num)]):
            print(abs(listt[int(num - 1)] - listt[int(num)]))
        else:
            print(abs(listt[int(num - 2)] - listt[int(num - 1)]))


t = int(input())
for i in range(t):
    n = int(input())
    listt = list(map(int, input().split()))
    listt.sort()
    listm = []
    for i in range(len(listt) - 1):
        listm.append(listt[i + 1] - listt[i])
    print(min(listm))


try:
    while True:
        t = int(input())
        for i in range(t):
            n = int(input())
            num = n / 2
            listt = list(map(int, input().split()))
            listt.sort()
            if n % 2 != 0:
                if abs(listt[int(num - 1.5)] - listt[int(num - 0.5)]) > abs(listt[int(num - 0.5)] - listt[int(num + 0.5)]):
                    print(abs(listt[int(num - 0.5)] - listt[int(num + 0.5)]))
                else:
                    print(abs(listt[int(num - 1.5)] - listt[int(num - 0.5)]))
            else:
                if abs(listt[int(num - 2)] - listt[int(num - 1)]) > abs(listt[int(num - 1)] - listt[int(num)]):
                    print(abs(listt[int(num - 1)] - listt[int(num)]))
                else:
                    print(abs(listt[int(num - 2)] - listt[int(num - 1)]))
except EOFError:
    pass


fun min(a:Int, b:Int) : Int
{
    if (a<b) return a else return  b
}

fun main()
{

     val t = readLine()!!.toInt()
        repeat(t)
        {
            val n = readLine()!!.toInt()
            var arr:MutableList<Int> = readLine()!!.split(' ').map(String::toInt).toMutableList()

            var res = 20000
            arr.sort()
            for (i in 0..arr.size-2)
                res = min(res, arr.get(i+1)-arr.get(i))

            println(res)
        }

}


private fun readLn() = readLine()!!
private fun readString() = readLn().trim()
private fun readInt() = readLn().toInt()
private fun readLong() = readLn().toLong()
private val regSpace = "\\s+".toRegex()
private fun readSomeInts(): List<Int> {
    return readLn().trim().split(regSpace).map { it.toInt() }
}
private fun readSomeLongs(): List<Long> {
    return readLn().trim().split(regSpace).map { it.toLong() }
}

data class idxValue (val idx: Int, val value: Int)

fun main() {
    val t = readInt()
    repeat (t) {
        val n: Int = readInt()
        val xs = readSomeInts().sorted()
        check(n == xs.size)
        val ds = mutableListOf<Int>()
        for (i in 1 until n) {
            val d = xs[i] - xs[i - 1]
            ds.add(Math.abs(d))
        }
        val dmin = ds.min()

        println(dmin);
    }
}


import java.io.BufferedReader
import java.io.BufferedWriter
import java.io.InputStreamReader
import java.io.OutputStreamWriter

val reader = BufferedReader(InputStreamReader(System.`in`))
val writer = BufferedWriter(OutputStreamWriter(System.`out`))

fun readIntList() = reader.readLine().split(' ').map(String::toInt)
fun readLongList() = reader.readLine().split(' ').map(String::toLong)
fun readDoubleList() = reader.readLine().split(' ').map(String::toDouble)
fun readStringList() = reader.readLine().split(' ')
fun readInt() = reader.readLine().toInt()
fun readLong() = reader.readLine().toLong()
fun readDouble() = reader.readLine().toDouble()

fun main() {
    var t = readInt()
    repeat(t){
        var n = readInt()
        var list = readIntList().sorted()
        var min = 100000
        for (i in 1..n-1){
            if(min>list[i]-list[i-1]){
                min = list[i]-list[i-1]
            }
        }
        println(min)
    }
}


fun main() {
    repeat(readLine()!!.toInt()){
        readLine()
        val athletes = readLine()!!.split(" ").map { it.toInt() }.sorted()
        println(athletes.zipWithNext().map { it.second - it.first }.min())
    }
}


fun main() {
    val count = readLine()!!.toInt()
    repeat(count){
        val number = readLine()!!.toInt()
        val athletes = readLine()!!.split(" ").map { it.toInt() }
        val sortedAthletes = athletes.sortedDescending()
        var minDistance = sortedAthletes[0] - sortedAthletes[1]
        var temp: Int
        for (i in 1 until number-1){
            temp = sortedAthletes[i] - sortedAthletes[i+1]
            if (temp < minDistance)
                minDistance = temp
        }
        println(minDistance)
    }
}


private fun cin_ch() = readLine()!!.split(" ").map{it.toInt()}
private fun cin_array() = readLine()!!.split(" ").map(String::toInt)
private fun cin_string() = readLine()!!.split(" ")
fun main() {
var test = cin_ch()[0];
while (test>0) {
var k = cin_ch()[0];
var array = cin_array();
var myarray = ArrayList<Int> ();
for (i in 0..k-1) {
    myarray.add(array[i]);
}
myarray.sort();
var ans = myarray[k-1] + 5;
for (i in 0..k-2)
{
    if ((myarray[i+1]-myarray[i])<ans) ans = myarray[i+1] - myarray[i];
}
println(ans);
test = test - 1;
}
}


fun main(){
    val t = readLine()!!.toInt()
    repeat(t){
        val n = readLine()!!.toInt()
        val s = readLine()!!.split(" ").map(String::toInt).sorted()
        (1 until n).map { s[it] - s[it-1] }.min()?.let { println(it) }
    }
}


fun main() {
    val r = System.`in`.bufferedReader()
    val s = StringBuilder()
    var n = r.readLine()!!.toInt()
    repeat(n){
        val len = r.readLine()!!.toInt()
        val v = r.readLine()!!.split(" ").map { it.toInt() }.sorted()
        var min = Int.MAX_VALUE
        for (i in 1..len-1){
            if (v[i]-v[i-1]<min){
                min = v[i]-v[i-1]
            }
        }
        println(min)
    }
}


fun main() {
    val count = readLine()!!.toInt()
    for (i in 0 until count) {
        readLine()
        var list = readLine()!!.split(" ")
        list = list.sorted()
        var min = Int.MAX_VALUE
        for (j in 0 until list.size - 1) {
            val a = list[j + 1].toInt() - list[j].toInt()
            if (a < min) {
                min = a
            }
        }
        println(min)
    }
}


fun main() {
    val count = readLine()!!.toInt()
    for (i in 0 until count) {
        readLine()
        var list = readLine()!!.split(" ").map { str -> str.toInt() }
        list = list.sorted()
        var min = Int.MAX_VALUE
        println(list)
        for (j in 0 until list.size - 1) {
            val a = list[j + 1].toInt() - list[j].toInt()
            if (a < min) {
                min = a
            }
        }
        println(min)
    }
}


fun main() {
    val count = readLine()!!.toInt()
    for (i in 0 until count) {
        readLine()
        var list = readLine()!!.split(" ").map { str -> str.toInt() }
        list = list.sorted()
        var min = Int.MAX_VALUE
        for (j in 0 until list.size - 1) {
            val a = list[j + 1].toInt() - list[j].toInt()
            if (a < min) {
                min = a
            }
        }
        println(min)
    }
}


import java.io.*
import java.util.*

object Main {
    var `in`: IO? = null
    var out: PrintWriter? = null

    @Throws(Exception::class)
    fun init_io(filename: String) {
        if (filename == "") {
            `in` = IO(System.`in`)
            out = PrintWriter(BufferedWriter(OutputStreamWriter(System.out)), true)
        } else {
            `in` = IO(FileInputStream("$filename.in"))
            out = PrintWriter(BufferedWriter(FileWriter("$filename.out")), true)
        }
    }

    const val mod: Long = 998244353

    /*
fun main(args: Array<String>) {
    Main.main(args);
}
*/
    @Throws(Exception::class)
    fun solve(tc: Int) {
        val n = `in`!!.nint()
        val a = IntArray(n)
        for (i in 0 until n) a[i] = `in`!!.nint()
        var v = mod.toInt()
        rsort(a)
        for (i in 0 until n - 1) v = Math.min(v, a[i + 1] - a[i])
        out!!.println(v)
    }

    @Throws(Exception::class)
    @JvmStatic
    fun main(_u_n_u_s_e_d_: Array<String>) {
        init_io("")
        var t = 1
        t = `in`!!.nint()
        for (tc in 0 until t) {
            solve(tc)
        }
    }

    fun minv(v: Long): Long {
        return mpow(v, mod - 2)
    }

    fun mpow(base: Long, exp: Long): Long {
        var base = base
        var exp = exp
        var res: Long = 1
        while (exp > 0) {
            if (exp and 1 == 1L) {
                res = res * base % mod
            }
            base = base * base % mod
            exp = exp shr 1
        }
        return res
    }

    fun gcd(x: Long, y: Long): Long {
        return if (x == 0L) y else gcd(y % x, x)
    }

    fun rsort(arr: LongArray) {
        val r = Random()
        for (i in arr.indices) {
            val j = i + r.nextInt(arr.size - i)
            val t = arr[i]
            arr[i] = arr[j]
            arr[j] = t
        }
        Arrays.sort(arr)
    }

    fun rsort(arr: IntArray) {
        val r = Random()
        for (i in arr.indices) {
            val j = i + r.nextInt(arr.size - i)
            val t = arr[i]
            arr[i] = arr[j]
            arr[j] = t
        }
        Arrays.sort(arr)
    }

    /* static void qsort(long[] arr) {
    Long[] oarr = new Long[arr.length];
    for (int i = 0; i < arr.length; i++) {
      oarr[i] = arr[i];
    }

    ArrayList<Long> alist = new ArrayList<Long>(Arrays.asList(oarr));
    Collections.sort(alist);

    for (int i = 0; i < arr.length; i++) {
      arr[i] = (long)alist.get(i);
    }
  } */
    fun reverse(arr: LongArray) {
        for (i in 0 until arr.size / 2) {
            val temp = arr[i]
            arr[i] = arr[arr.size - 1 - i]
            arr[arr.size - 1 - i] = temp
        }
    }

    fun atos(arr: LongArray?): String {
        var s = Arrays.toString(arr)
        s = s.substring(1, s.length - 1)
        return s.replace(",", "")
    }

    class IO(x: InputStream?) {
        var `in`: BufferedReader
        var tokens: StringTokenizer

        @Throws(Exception::class)
        fun nint(): Int {
            return nstr().toInt()
        }

        @Throws(Exception::class)
        fun nlong(): Long {
            return nstr().toLong()
        }

        @Throws(Exception::class)
        fun ndouble(): Double {
            return nstr().toDouble()
        }

        @Throws(Exception::class)
        fun nstr(): String {
            if (!tokens.hasMoreTokens()) tokens = StringTokenizer(`in`.readLine())
            return tokens.nextToken()
        }

        @Throws(Exception::class)
        fun nla(n: Int): LongArray {
            val arr = LongArray(n)
            for (i in 0 until n) {
                arr[i] = nlong()
            }
            return arr
        }

        init {
            `in` = BufferedReader(InputStreamReader(x))
            tokens = StringTokenizer(`in`.readLine())
        }
    }

    internal class Pair<A : Comparable<A>?, B : Comparable<B>?>(var f: A, var s: B) : Comparable<Pair<A, B>> {
        override fun compareTo(other: Pair<A, B>): Int {
            val v = f!!.compareTo(other.f)
            return if (v != 0) v else s!!.compareTo(other.s)
        }

        override fun toString(): String {
            return "(" + f.toString() + ", " + s.toString() + ")"
        }

    }
}

fun main(args: Array<String>) {
    Main.main(args);
}


import java.util.*
import kotlin.math.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong()
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of ints

fun main () {
    var t = readInt()
    for (i in 1..t) {
        var n = readInt()
        var s = readInts()
        var minDiff = 1000
        for (j in 0..(n-1)) {
            for (k in (j+1)..(n-1)) {
                if (abs(s[j] - s[k]) < minDiff) {
                    minDiff = abs(s[j] - s[k])
                }
            }
        }
        println(minDiff)
    }
}


fun readInt() = readLine()!!.toInt()

fun readIntArray() = readLine()!!.split(' ').map { it.toInt() }

fun main() {
    val t = readInt()

    (1..t).forEach {
        val n = readInt()
        val s = readIntArray()
        val sortedS = s.sorted()

        println((1 until sortedS.size).map { sortedS[it] - sortedS[it - 1] }.min())
    }
}


import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val MOD = 1_000_000_007L

class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    for (t in 0 until ni()) {
      out.println(solve2())
    }
  }

  fun solve2(): Int {
    val N = ni()
    val S = na(N)
    S.sort()
    return (0 until N - 1).map { S[it + 1] - S[it]}.min()!!
  }

  private val isDebug = try {
    // なんか本番でエラーでる
    System.getenv("MY_DEBUG") != null
  } catch (t: Throwable) {
    false
  }

  private var tokenizer: StringTokenizer? = null
  private val reader = BufferedReader(InputStreamReader(stream), 32768)
  private fun next(): String {
    while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
      tokenizer = StringTokenizer(reader.readLine())
    }
    return tokenizer!!.nextToken()
  }

  private fun ni() = next().toInt()
  private fun nl() = next().toLong()
  private fun ns() = next()
  private fun na(n: Int, offset: Int = 0): IntArray {
    return map(n) { ni() + offset }
  }
  private fun nal(n: Int, offset: Int = 0): LongArray {
    val res = LongArray(n)
    for (i in 0 until n) {
      res[i] = nl() + offset
    }
    return res
  }

  private fun na2(n: Int, offset: Int = 0): Array<IntArray> {
    val a  = Array(2){IntArray(n)}
    for (i in 0 until n) {
      for (e in a) {
        e[i] = ni() + offset
      }
    }
    return a
  }

  private inline fun map(n: Int, f: (Int) -> Int): IntArray {
    val res = IntArray(n)
    for (i in 0 until n) {
      res[i] = f(i)
    }
    return res
  }

  private inline fun debug(msg: () -> String) {
    if (isDebug) System.err.println(msg())
  }

  private fun debug(a: LongArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: IntArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: BooleanArray) {
    debug { a.map { if (it) 1 else 0 }.joinToString("") }
  }

  private fun debugDim(A: Array<LongArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }
  private fun debugDim(A: Array<IntArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }

  /**
   * 勝手にimport消されるのを防ぎたい
   */
  private fun hoge() {
    min(1, 2)
    max(1, 2)
    abs(-10)
  }
}

fun main() {
  val out = java.io.PrintWriter(System.out)
  Solver(System.`in`, out).solve()
  out.flush()
}


import java.util.*
fun readln() = readLine()!!
fun readint() = readln().toInt()
fun readlong() = readln().toLong()
fun readdouble() = readln().toDouble()
fun readstrings() = readln().split(" ")
fun readints() = readstrings().map { it.toInt() }
fun readlongs() = readstrings().map { it.toLong() }
fun readdoubles() = readstrings().map { it.toDouble() }

fun main() {
    var tt = readint()
    while (tt-- > 0) {
        var n=readint()
        var t=readints()
        var s=t.toMutableList()
        s.sort()
        var ans=10000000
        for(i in 0..n-2){
            ans=minOf(ans,s[i+1]-s[i])
        }
        println(ans)
    }
}

// kotlin sol.jar<in>out


import java.util.*
import java.io.*

val MOD = 924844033

fun main(args: Array<String>)
{
	Thread(null, Main(), "whatever", 1 shl 28).start()
}

class Main : Runnable {

	override fun run()
	{
		val inputStream = System.`in`
		val outputStream = System.out
		val `in` = InputReader(inputStream)
		val out = PrintWriter(outputStream)
		val solver = TaskD()
		var test = 1
		test = `in`.nextInt()
		for (t in 1..test)
		{
			solver.solve(t, `in`, out)
		}
		out.close()
	}

	internal class TaskD
	{
		fun solve(testNumber: Int, `in`: InputReader, out: PrintWriter) {
			val INF = 4000000000000000000L
			val dx = intArrayOf(-1, 1, 0, 0)
			val dy = intArrayOf(0, 0, -1, 1)

			var n = `in`.nextInt()
			var a = IntArray(n){`in`.nextInt()}
			var res = Math.abs(a[0]-a[1])
			for (i in 0..n-1)
				for (j in i+1..n-1)
					res = Math.min(res, Math.abs(a[i]-a[j]))
			out.println(res)
		}

	}

	internal class InputReader(stream: InputStream) {
		var reader: BufferedReader
		var tokenizer: StringTokenizer? = null

		init {
			reader = BufferedReader(InputStreamReader(stream), 32768)
			tokenizer = null
		}

		operator fun next(): String {
			while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
				try {
					tokenizer = StringTokenizer(reader.readLine())
				} catch (e: IOException) {
					throw RuntimeException(e)
				}

			}
			return tokenizer!!.nextToken()
		}

		fun nextInt(): Int {
			return Integer.parseInt(next())
		}

		fun nextLong(): Long {
		    return next().toLong()
		}

	}
}

fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a%b)

fun power(a: Long, b: Long, p: Long): Long
{
	if (b == 0L) return 1L
	var t = power(a, b/2, p)
	t = t*t%p
	if (b%2 == 1L) t = t*a%p
	return t
}


fun main() {
    val t = readLine()!!.toInt()
    repeat(t) {
        readLine()
        val s = readLine()!!.split(" ").map { it.toInt() }.sorted()
        println(s.zipWithNext().minBy { it.second - it.first }!!)
    }
}


fun main() {
    val t = readLine()!!.toInt()
    repeat(t) {
        readLine()
        val s = readLine()!!.split(" ").map { it.toInt() }.sorted()
        println(s.zipWithNext().map { it.second - it.first }.min())
    }
}


import java.util.*
import kotlin.io.readLine
import kotlin.math.ceil
import kotlin.math.ln
import kotlin.math.max
import kotlin.math.pow
import kotlin.system.measureTimeMillis

fun main(args: Array<String>) {
    val t = readLine()!!.toInt()
    for (i in 1..t) {
        val n = readIntLine()
        val arr = readIntLine()

        println(arr.sorted().zipWithNext().map { it.second - it.first }.min())
    }
//    println(listOf(1, 3).sorted().zipWithNext().map { it.second - it.first }.min())
}

fun calc(k: Int, arr: List<Int>) {
    val resArray = MutableList(arr.size) { 0 }

    val special = 2.0.pow(ceil(ln(k.toDouble()) / ln(2.0))).toInt()
    val scoreTree = MutableList(2 * special + 2) { 0 }

    var max = -1
    for (i in 0 until k) {
        scoreTree[special + i] = arr[i]
        max = max(max, arr[i])
        resArray[i] = max
    }

    fun merge(scoreLeft: Int, scoreRight: Int): Int = max(scoreLeft, scoreRight)

    (1 until special).reversed().forEach { i ->
        val l = 2 * i
        val r = 2 * i + 1
        val merged = merge(scoreTree[l], scoreTree[r])
        scoreTree[i] = merged
    }

    fun update(ind: Int, v: Int) {
        if (ind != 0) {
            if (ind >= special) {
                scoreTree[ind] = v
                update(ind / 2, v)
            } else {
                val l = 2 * ind
                val r = 2 * ind + 1
                val merged = merge(scoreTree[l], scoreTree[r])
                scoreTree[ind] = merged
                update(ind / 2, v)
            }
        }
    }

    fun useThisUpdate(i: Int, v: Int) = update(i + special - 1, v)

    var ind = k
    while(ind != arr.size) {
        useThisUpdate(ind % k + 1, arr[ind])
        resArray[ind] = scoreTree[1]
        ind++
    }

    print(resArray[0])
    for (i in 1 until resArray.size)
        print(" " + resArray[i])
    println()
}

fun readIntLine(): List<Int> = readLine()!!.split(" ").map { it.toInt() }


import java.util.*
import kotlin.io.readLine
import kotlin.math.ceil
import kotlin.math.ln
import kotlin.math.max
import kotlin.math.pow
import kotlin.system.measureTimeMillis

fun main(args: Array<String>) {
    val t = readLine()!!.toInt()
    for (i in 1..t) {
        val n = readIntLine()
        val arr = readIntLine()

        println(arr.sorted().zipWithNext().minBy { it.second - it.first })
    }
//    println(measureTimeMillis { calc(30000, (1..100000).toList()) })
}

fun calc(k: Int, arr: List<Int>) {
    val resArray = MutableList(arr.size) { 0 }

    val special = 2.0.pow(ceil(ln(k.toDouble()) / ln(2.0))).toInt()
    val scoreTree = MutableList(2 * special + 2) { 0 }

    var max = -1
    for (i in 0 until k) {
        scoreTree[special + i] = arr[i]
        max = max(max, arr[i])
        resArray[i] = max
    }

    fun merge(scoreLeft: Int, scoreRight: Int): Int = max(scoreLeft, scoreRight)

    (1 until special).reversed().forEach { i ->
        val l = 2 * i
        val r = 2 * i + 1
        val merged = merge(scoreTree[l], scoreTree[r])
        scoreTree[i] = merged
    }

    fun update(ind: Int, v: Int) {
        if (ind != 0) {
            if (ind >= special) {
                scoreTree[ind] = v
                update(ind / 2, v)
            } else {
                val l = 2 * ind
                val r = 2 * ind + 1
                val merged = merge(scoreTree[l], scoreTree[r])
                scoreTree[ind] = merged
                update(ind / 2, v)
            }
        }
    }

    fun useThisUpdate(i: Int, v: Int) = update(i + special - 1, v)

    var ind = k
    while(ind != arr.size) {
        useThisUpdate(ind % k + 1, arr[ind])
        resArray[ind] = scoreTree[1]
        ind++
    }

    print(resArray[0])
    for (i in 1 until resArray.size)
        print(" " + resArray[i])
    println()
}

fun readIntLine(): List<Int> = readLine()!!.split(" ").map { it.toInt() }


//package codeforces.round644div3

import java.util.*
import kotlin.math.min

fun main() {

    val reader = Scanner(System.`in`)
    val times = reader.nextInt()
    repeat(times) {
        val numberOfAthletes = reader.nextInt()
        val athletes = Array(numberOfAthletes) { 0 }
        repeat(numberOfAthletes) { index ->
            athletes[index] = reader.nextInt()
        }
        athletes.sort()
        var minDiff = 1001
        for (i in 0 until numberOfAthletes - 1) {
            minDiff = min(minDiff, (athletes[i + 1] - athletes[i]))
        }
        println(minDiff)
    }
}


import kotlin.math.abs
fun main() {
    val t= readLine()!!.toInt()
    for(i in 0 until t) {
        val n = readLine()!!.toInt()
        val arr = mutableListOf<Int>()

        val nums = readLine()!!
        nums.split(" ").forEach { arr.add(it.toInt()) }

        arr.sort()
        var minDiff = Int.MAX_VALUE
        for (j in 0 until n-1) {
            if(minDiff == 0)
                break
            val diff = abs(arr[j] - arr[j+1])
            if( diff < minDiff)
                minDiff = diff
        }
        println(minDiff)
    }
}


import java.util.*
import kotlin.math.*
fun readint()=readLine()!!.toInt()
fun readll()=readLine()!!.toLong()
fun readdb()=readLine()!!.toDouble()
fun readstring()=readLine()!!
fun readline_int()=(readLine()!!.split(" ").map{it.toInt()}).toIntArray()
fun readline_ll()=(readLine()!!.split(" ").map{it.toLong()}).toLongArray()
fun readline_db()=(readLine()!!.split(" ").map{it.toDouble()}).toDoubleArray()
fun main(args: Array<String>) {
    val t = readint();
    repeat(t) {
        val n = readint();
        val v = readline_int().sorted();
        var mi = 10000000;
        for (i in 1..n-1) {
            mi = min(mi, v[i] - v[i - 1]);
        }
        println(mi);
    }
}


import kotlin.math.abs
import kotlin.math.min

private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map { it.toInt() }

fun main() {
    val t = readInt()
    for (i in (1..t)) {
        val n = readInt()
        val s = readInts().sorted()
        var ans = Int.MAX_VALUE
        for (j in 0 until n - 1) {
            ans = min(ans, abs(s[j] - s[j + 1]))
        }
        println(ans)
    }
}


#include<bits/stdc++.h>
using namespace std;
char s[105];
int a[105], b[105], tmp[30];
int main()
{
    int n, cnt, flag, tot;
    scanf("%d",&n);
    for(int i = 1; i <= n; i++){
        memset(tmp,0,sizeof(tmp));
        cnt = 0; flag = 1; tot = 0;
        scanf("%s",s+1);
        int len = strlen(s+1);
        for(int j = 1; j <= len; j++){
            if(tmp[s[j]-'a']){
                tmp[s[j]-'a']++; continue;
            }
            a[++tot] = s[j]-'a';
            tmp[s[j]-'a']++;
        }
        sort(a+1,a+tot+1);
        for(int j = 2; j <= tot; j += 2) b[++cnt] = a[j];
        for(int j = 1; j <= tot; j += 2) b[++cnt] = a[j];
        for(int j = 1; j <= cnt; j++){
            if(abs(b[j]-b[j+1]) == 1){
                flag = 0;
                break;
            }
        }
        if(flag){
            for(int j = 1; j <= cnt; j++){
                printf("%c",b[j]+'a');
                while(--tmp[b[j]]) printf("%c",b[j]+'a');
            }
            printf("\n");
        }
        else printf("No answer\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
char s[105];
int a[105], b[105], odd[105], even[105];
int main()
{
    int t, len, tot, p1, p2;
    scanf("%d",&t);
    while(t--){
        tot = 0; p1 = 0; p2 = 0;
        memset(a,0,sizeof(a));
        scanf("%s",s+1);
        len = strlen(s+1);
        for(int i = 1; i <= len; i++){
            if(a[s[i]-'a']){
                a[s[i]-'a']++;
                continue;
            }
            a[s[i]-'a']++;
            b[++tot] = s[i]-'a';
        }
        sort(b+1,b+tot+1);
        if(tot == 1){
            while(a[b[1]]--) printf("%c",b[1]+'a');
            printf("\n");
            continue;
        }
        for(int i = 1; i <= tot; i += 2) odd[++p1] = b[i];
        for(int i = 2; i <= tot; i += 2) even[++p2] = b[i];
        if(abs(even[1]-odd[p1]) > 1){
            for(int i = 1; i <= p1; i++){
                while(a[odd[i]]--) printf("%c",odd[i]+'a');
            }
            for(int i = 1; i <= p2; i++){
                while(a[even[i]]--) printf("%c",even[i]+'a');
            }
            printf("\n");
        }
        else if(abs(odd[1]-even[p2]) > 1){
            for(int i = 1; i <= p2; i++){
                while(a[even[i]]--) printf("%c",even[i]+'a');
            }
            for(int i = 1; i <= p1; i++){
                while(a[odd[i]]--) printf("%c",odd[i]+'a');
            }
            printf("\n");
        }
        else printf("No answer\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
char s[105];
int a[105], b[105], tmp[30];
int main()
{
    int n, cnt, flag, tot;
    scanf("%d",&n);
    for(int i = 1; i <= n; i++){
        cnt = 0; flag = 1; tot = 0;
        scanf("%s",s+1);
        int len = strlen(s+1);
        for(int j = 1; j <= len; j++){
            if(tmp[s[j]-'a']){
                tmp[s[j]-'a']++; continue;
            }
            a[++tot] = s[j]-'a';
            tmp[s[j]-'a']++;
        }
        sort(a+1,a+tot+1);
        for(int j = 2; j <= tot; j += 2) b[++cnt] = a[j];
        for(int j = 1; j <= tot; j += 2) b[++cnt] = a[j];
        for(int j = 1; j <= cnt; j++){
            if(abs(b[j]-b[j+1]) == 1){
                flag = 0;
                break;
            }
        }
        if(flag){
            for(int j = 1; j <= cnt; j++){
                printf("%c",b[j]+'a');
                while(--tmp[b[j]]) printf("%c",b[j]+'a');
            }
            printf("\n");
        }
        else printf("No answer\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
char s[105];
int a[105], b[105], odd[105], even[105];
int main()
{
    int t, len, tot, p1, p2;
    scanf("%d",&t);
    while(t--){
        tot = 0; p1 = 0; p2 = 0;
        memset(a,0,sizeof(a));
        scanf("%s",s+1);
        len = strlen(s+1);
        for(int i = 1; i <= len; i++){
            if(a[s[i]-'a']){
                a[s[i]-'a']++;
                continue;
            }
            a[s[i]-'a']++;
            b[++tot] = s[i]-'a';
        }
        sort(b+1,b+tot+1);
        for(int i = 1; i <= tot; i += 2) odd[++p1] = b[i];
        for(int i = 2; i <= tot; i += 2) even[++p2] = b[i];
        if(abs(even[1]-odd[p1]) > 1){
            for(int i = 1; i <= p1; i++){
                while(a[odd[i]]--) printf("%c",odd[i]+'a');
            }
            for(int i = 1; i <= p2; i++){
                while(a[even[i]]--) printf("%c",even[i]+'a');
            }
            printf("\n");
        }
        else if(abs(odd[1]-even[p2]) > 1){
            for(int i = 1; i <= p2; i++){
                while(a[even[i]]--) printf("%c",even[i]+'a');
            }
            for(int i = 1; i <= p1; i++){
                while(a[odd[i]]--) printf("%c",odd[i]+'a');
            }
            printf("\n");
        }
        else printf("No answer\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
char s[105];
int a[105], b[105], tmp[30];
int main()
{
    int n, cnt, flag, tot;
    scanf("%d",&n);
    for(int i = 1; i <= n; i++){
        memset(tmp,0,sizeof(tmp));
        cnt = 0; flag = 1; tot = 0;
        scanf("%s",s+1);
        int len = strlen(s+1);
        for(int j = 1; j <= len; j++){
            if(tmp[s[j]-'a']){
                tmp[s[j]-'a']++; continue;
            }
            a[++tot] = s[j]-'a';
            tmp[s[j]-'a']++;
        }
        sort(a+1,a+tot+1);
        if(tot%2){
            for(int j = 1; j <= tot; j += 2) b[++cnt] = a[j];
            for(int j = 2; j <= tot; j += 2) b[++cnt] = a[j];
        }
        else{
            for(int j = 2; j <= tot; j += 2) b[++cnt] = a[j];
            for(int j = 1; j <= tot; j += 2) b[++cnt] = a[j];
        }
        for(int j = 1; j < cnt; j++){
            if(abs(b[j]-b[j+1]) == 1){
                flag = 0;
                break;
            }
        }
        if(flag){
            for(int j = 1; j <= cnt; j++){
                printf("%c",b[j]+'a');
                while(--tmp[b[j]]) printf("%c",b[j]+'a');
            }
            printf("\n");
        }
        else printf("No answer\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
char s[105];
int a[105], b[105], odd[105], even[105];
int main()
{
    int t, len, tot, p1, p2;
    scanf("%d",&t);
    while(t--){
        tot = 0; p1 = 0; p2 = 0;
        memset(a,0,sizeof(a));
        scanf("%s",s+1);
        len = strlen(s+1);
        for(int i = 1; i <= len; i++){
            if(a[s[i]-'a']){
                a[s[i]-'a']++;
                continue;
            }
            a[s[i]-'a']++;
            b[++tot] = s[i]-'a';
        }
        sort(b+1,b+tot+1);
        if(tot == 1){ printf("%c\n",b[1]+'a'); continue; }
        for(int i = 1; i <= tot; i += 2) odd[++p1] = b[i];
        for(int i = 2; i <= tot; i += 2) even[++p2] = b[i];
        if(abs(even[1]-odd[p1]) > 1){
            for(int i = 1; i <= p1; i++){
                while(a[odd[i]]--) printf("%c",odd[i]+'a');
            }
            for(int i = 1; i <= p2; i++){
                while(a[even[i]]--) printf("%c",even[i]+'a');
            }
            printf("\n");
        }
        else if(abs(odd[1]-even[p2]) > 1){
            for(int i = 1; i <= p2; i++){
                while(a[even[i]]--) printf("%c",even[i]+'a');
            }
            for(int i = 1; i <= p1; i++){
                while(a[odd[i]]--) printf("%c",odd[i]+'a');
            }
            printf("\n");
        }
        else printf("No answer\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int t;
string S;
vector<char> s;
vector<pair<char, int>> ans;
int main() {
	cin >> t;
	while(t--) {
		cin >> S;
		for(int i = 0; i < S.size(); i++) {
			s.push_back(S[i]);
		}
		sort(s.begin(), s.end());
		ans.push_back(make_pair(s[0], 1));
		for(int i = 1; i < s.size(); i++) {
			if(s[i] == ans.back().first) {
				ans.back().second++;
			}
			else {
				ans.push_back(make_pair(s[i], 1));
			}
		}
		/*for(int i = 0; i < ans.size(); i++) {
			cout << ans[i].first << " " << ans[i].second << endl;
		}*/
		if(ans.size() == 1) {
			for(int i = 0; i < ans[0].second; i++) {
				cout << ans[0].first;
			}
			//cout << endl;
		}
		else if(ans.size() == 2) {
			if(ans[0].first == ans[1].first - 1) {
				cout << "No answer";
			}
			else {
				for(int j = 0; j < ans[0].second; j++) {
					cout << ans[0].first;
				}
				for(int j = 0; j < ans[1].second; j++) {
					cout << ans[1].first;
				}
			}
		}
		else if(ans.size() == 3) {
			if(ans[0].first == ans[1].first - 1 && ans[1].first == ans[2].first - 1) {
				cout << "No answer";
			}
			else {
				for(int j = 0; j < ans[1].second; j++) {
					cout << ans[1].first;
				}
				if(ans[0].first == ans[1].first - 1) {
					for(int j = 0; j < ans[2].second; j++) {
						cout << ans[2].first;
					}
					for(int j = 0; j < ans[0].second; j++) {
						cout << ans[0].first;
					}
				}
				else {
					for(int j = 0; j < ans[0].second; j++) {
						cout << ans[0].first;
					}
					for(int j = 0; j < ans[2].second; j++) {
						cout << ans[2].first;
					}
				}
			}
		}
		else {
			for(int j = 0; j < ans[2].second; j++) {
				cout << ans[2].first;
			}
			for(int j = 0; j < ans[0].second; j++) {
				cout << ans[0].first;
			}
			for(int i = 4; i < ans.size(); i += 2) {
				for(int j = 0; j < ans[i].second; j++) {
					cout << ans[i].first;
				}
			}
			for(int j = 0; j < ans[3].second; j++) {
				cout << ans[3].first;
			}
			for(int j = 0; j < ans[1].second; j++) {
				cout << ans[1].first;
			}
			for(int i = 5; i < ans.size(); i += 2) {
				for(int j = 0; j < ans[i].second; j++) {
					cout << ans[i].first;
				}
			}
			//cout << endl;
		}
		cout << endl;
		ans.clear();
		s.clear();
	}
}


#include<bits/stdc++.h>
using namespace std;
int t;
string S;
vector<char> s;
vector<pair<char, int>> ans;
int main() {
	cin >> t;
	while(t--) {
		cin >> S;
		for(int i = 0; i < S.size(); i++) {
			s.push_back(S[i]);
		}
		sort(s.begin(), s.end());
		ans.push_back(make_pair(s[0], 1));
		for(int i = 1; i < s.size(); i++) {
			if(s[i] == ans.back().first) {
				ans.back().second++;
			}
			else {
				ans.push_back(make_pair(s[i], 1));
			}
		}
		/*for(int i = 0; i < ans.size(); i++) {
			cout << ans[i].first << " " << ans[i].second << endl;
		}*/
		if(ans.size() < 4) {
			cout << "No answer" << endl;
		}
		else {
			for(int j = 0; j < ans[2].second; j++) {
				cout << ans[2].first;
			}
			for(int j = 0; j < ans[0].second; j++) {
				cout << ans[0].first;
			}
			for(int i = 4; i < ans.size(); i += 2) {
				for(int j = 0; j < ans[i].second; j++) {
					cout << ans[i].first;
				}
			}
			for(int i = 1; i < ans.size(); i += 2) {
				for(int j = 0; j < ans[i].second; j++) {
					cout << ans[i].first;
				}
			}
			cout << endl;
		}
		ans.clear();
		s.clear();
	}
}


#include<bits/stdc++.h>
using namespace std;
int t;
string S;
vector<char> s;
vector<pair<char, int>> ans;
int main() {
	cin >> t;
	while(t--) {
		cin >> S;
		for(int i = 0; i < S.size(); i++) {
			s.push_back(S[i]);
		}
		sort(s.begin(), s.end());
		ans.push_back(make_pair(s[0], 1));
		for(int i = 1; i < s.size(); i++) {
			if(s[i] == ans.back().first) {
				ans.back().second++;
			}
			else {
				ans.push_back(make_pair(s[i], 1));
			}
		}
		/*for(int i = 0; i < ans.size(); i++) {
			cout << ans[i].first << " " << ans[i].second << endl;
		}*/
		if(ans.size() == 1) {
			for(int i = 0; i < ans[0].second; i++) {
				cout << ans[0].first;
			}
			cout << endl;
		}
		else if(ans.size() < 4) {
			cout << "No answer" << endl;
		}
		else {
			for(int j = 0; j < ans[2].second; j++) {
				cout << ans[2].first;
			}
			for(int j = 0; j < ans[0].second; j++) {
				cout << ans[0].first;
			}
			for(int i = 4; i < ans.size(); i += 2) {
				for(int j = 0; j < ans[i].second; j++) {
					cout << ans[i].first;
				}
			}
			for(int j = 0; j < ans[3].second; j++) {
				cout << ans[3].first;
			}
			for(int j = 0; j < ans[1].second; j++) {
				cout << ans[1].first;
			}
			for(int i = 5; i < ans.size(); i += 2) {
				for(int j = 0; j < ans[i].second; j++) {
					cout << ans[i].first;
				}
			}
			cout << endl;
		}
		ans.clear();
		s.clear();
	}
}