#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pl pair<ll,ll>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define pb push_back
#define task "tunnel"
#define TIME (1.0*clock()/CLOCKS_PER_SEC)
using namespace std;
int n,m;
int a,b,c,d;
ll da[500505];
ll db[500505];
ll dc[500505];
ll dd[500505];
vector<pi> adj[500505];
vi dag[500505];
vi rev[500505];
struct edges{
	int fi,se,wei;
} e[500505];
void dijk(int u,ll d[])
{
	priority_queue<pl,vector<pl>,greater<pl>>pq;
	pq.push({0,u});
	for(int i=1;i<=n;i++)
	{
		d[i]=1e18;
	}
	d[u]=0;
	while(!pq.empty())
	{
		ll dist=pq.top().first;
		int v=pq.top().second;
		pq.pop();
		if(dist>d[v])continue;
		for(auto &k:adj[v])
		{
			int x=k.first;
			ll w=k.second;
			if(d[x]>d[v]+w)d[x]=d[v]+w,pq.push({d[x],x});
		}
	}
}
bool chosenone[500505];
int deg[500505];
int rdeg[500505];
ll fc[500505];
ll fd[500505];
void sol()
{
	cin>>n>>m;
	cin>>a>>b>>c>>d;
	for(int i=1;i<=m;i++){
		int u,v,w;
		cin>>u>>v>>w;
		e[i]={u,v,w};
		adj[u].pb({v,w});
		adj[v].pb({u,w});
	}    
	dijk(a,da);
	dijk(b,db);
	dijk(c,dc);
	dijk(d,dd);
	for(int i=1;i<=m;i++)
	{
		int u=e[i].fi;
		int v=e[i].se;
		int w=e[i].wei;
		if(da[u]+w==da[v]
&& da[u]+w+db[v]==da[b])
		{
			dag[u].pb(v);
			rev[v].pb(u);
			deg[v]++;
			rdeg[u]++;
			chosenone[u]=1;
			chosenone[v]=1;
		}
		if(da[v]+w==da[u]
&& da[v]+w+db[u]==da[b])
		{
			dag[v].pb(u);
			rev[u].pb(v);
			deg[u]++;
			rdeg[v]++;
			chosenone[u]=1;
			chosenone[v]=1;
		}
	}

	queue<int>q,q2;
	ll ans=dc[d];
	for(int i=1;i<=n;i++)
	{
		fc[i]=dc[i];
		fd[i]=dd[i];
		
		if(chosenone[i]){
			// cout<<fc[i]<<" "<<fd[i]<<" "<<i<<"\n";
		}
	}
	q.push(a);q2.push(b);

	while(!q.empty())
	{
		int t=q.front();
		q.pop();ans=min(fc[t]+dd[t],ans);
		cout<<fc[t]<<" "<<dd[t]<<" "<<t<<" "<<ans<<"\n";
		for(auto &x:dag[t])
		{
			fc[x]=min(fc[x],fc[t]);
			
			if(--deg[x]==0)q.push(x);		
		}

	}
	while(!q2.empty())
	{
		int t=q2.front();
		q2.pop();ans=min(fd[t]+dc[t],ans);
		
		
		for(auto &x:rev[t])
		{
			fd[x]=min(fd[x],fd[t]);
			
			if(--rdeg[x]==0)q2.push(x);
		}

	}
	cerr<<ans<<"\n";

}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(task".inp","r"))
    {
        freopen(task ".inp","r",stdin);
        freopen(task ".out","w",stdout);
    }
    sol();
    cerr<<"Time : "<<TIME<<"s"<<"\n";
    return 0;
}