Problem: We have a graph with N vertices and M edges, and there are two people on the graph: Takahashi and Aoki.

The i-th edge connects Vertex U_i and Vertex V_i. The time it takes to traverse this edge is D_i minutes, regardless of direction and who traverses the edge (Takahashi or Aoki).

Takahashi departs Vertex S and Aoki departs Vertex T at the same time. Takahashi travels to Vertex T and Aoki travels to Vertex S, both in the shortest time possible. Find the number of the pairs of ways for Takahashi and Aoki to choose their shortest paths such that they never meet (at a vertex or on an edge) during the travel, modulo 10^9 + 7.

Constraints

* 1 \leq N \leq 100 000
* 1 \leq M \leq 200 000
* 1 \leq S, T \leq N
* S \neq T
* 1 \leq U_i, V_i \leq N (1 \leq i \leq M)
* 1 \leq D_i \leq 10^9 (1 \leq i \leq M)
* If i \neq j, then (U_i, V_i) \neq (U_j, V_j) and (U_i, V_i) \neq (V_j, U_j).
* U_i \neq V_i (1 \leq i \leq M)
* D_i are integers.
* The given graph is connected.

Input

Input is given from Standard Input in the following format:


N M
S T
U_1 V_1 D_1
U_2 V_2 D_2
:
U_M V_M D_M


Output

Print the answer.

Examples

Input

4 4
1 3
1 2 1
2 3 1
3 4 1
4 1 1


Output

2


Input

3 3
1 3
1 2 1
2 3 1
3 1 2


Output

2


Input

8 13
4 2
7 3 9
6 2 3
1 6 4
7 6 9
3 8 9
1 2 2
2 8 12
8 6 9
2 5 5
4 2 18
5 3 7
5 1 515371567
4 8 6


Output

6

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=200005;
const LL mo=1e9+7;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
struct Edge{
	int to,nex; LL w;
}e[N*4];
int n,m,s,t,head[N],vis[N],tot,id[N];
LL ds[N],dt[N],fs[N],ft[N],g[N];
inline void ade(int u,int v,LL w)
{e[++tot]=(Edge){v,head[u],w};head[u]=tot;}
inline void add(int &x,int y)
{
	x+=y; if(x>mo) x-=mo;
}
inline LL sqr(LL x)
{
	return x*x%mo;
}
int cmp(int x,int y)
{
	return g[x]<g[y];
}
void spfa(int s,LL *dist,LL *f)
{
	queue<int> q; q.push(s);
	for(int i=0;i<=n;i++) dist[i]=1e15,id[i]=i;
	clr(vis,0); dist[s]=0; vis[s]=f[s]=1;
	//for(int i=1;i<=n;i++) cout<<dist[i]<<' '; cout<<endl;
	while(!q.empty()){
		int u=q.front(); q.pop(); vis[u]=0;
		for(int i=head[u];i;i=e[i].nex){
			int v=e[i].to; LL w=e[i].w;
			if(dist[v]>dist[u]+w){
				dist[v]=dist[u]+w;
				if(!vis[v])
				  vis[v]=1,q.push(v);
			}
		}
	}
	for(int i=1;i<=n;i++) g[i]=dist[i];
	sort(id+1,id+n+1,cmp);
//	for(int i=1;i<=n;i++) cout<<dist[i]<<' '; cout<<endl;
//	for(int i=1;i<=n;i++) cout<<id[i]<<' '; cout<<endl<<endl;
	for(int i=1;i<=n;i++){
		int u=id[i];
		for(int j=head[u];j;j=e[j].nex){
			int v=e[j].to; LL w=e[j].w;
			if(dist[v]==dist[u]+w)
			  (f[v]+=f[u])%=mo;
		}
	}
}
int main()
{
	n=read();m=read();s=read();t=read();
	for(int i=1;i<=m;i++){
		int u=read(),v=read(),w=read();
		ade(u,v,w); ade(v,u,w);
	}
	spfa(s,ds,fs); spfa(t,dt,ft);
//	cout<<"S: ";for(int i=1;i<=n;i++) cout<<fs[i]<<' '; cout<<endl;
//	cout<<"T: ";for(int i=1;i<=n;i++) cout<<ft[i]<<' '; cout<<endl;
	LL ans=sqr(fs[t]),len=ds[t];
	if(len%2==0)
	for(int u=1;u<=n;u++){
		if(ds[u]==(len/2))
		  ans=(ans-sqr(fs[u])*sqr(ft[u])%mo+mo)%mo;
	}
	int k1=len&1;
	//cout<<ans<<' '<<k1<<endl;
	for(int u=1;u<=n;u++){
		for(int i=head[u];i;i=e[i].nex){
			int v=e[i].to; LL w=e[i].w;
			if(ds[u]<(len/2)+k1 && dt[v]<(len/2)+k1 && ds[u]+w+dt[v]==len){
				ans=(ans-sqr(fs[u])*sqr(ft[v])%mo+mo)%mo;
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}