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<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<bitset>
#include<complex>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
const int mod=1000000007;
int n,m;
int s,t;
int box[100005],las[400005],edv[400005],edw[400005],cnt=0;
void adde(int u,int v,int w)
{
	las[++cnt]=box[u];
	box[u]=cnt;
	edv[cnt]=v;
	edw[cnt]=w;
}
long long dis1[100005],cnt1[100005],dis2[100005],cnt2[100005],diss[100005];
bool vis[100005];
queue<int>q;
int id[100005];
void spfa(int s,long long* dis,long long* cnt)
{
	memset(dis,23,8*n+8);
	memset(vis,0,sizeof(vis));
	dis[s]=0;
	q.push(s);
	while(!q.empty())
	{
		int now=q.front();
		vis[now]=0;
		q.pop();
		for(int i=box[now];i;i=las[i])
		{
			int v=edv[i];
			if(dis[v]>dis[now]+edw[i])
			{
				dis[v]=dis[now]+edw[i];
				if(!vis[v])
				{
					vis[v]=1;
					q.push(v);
				}
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		id[i]=i;
		diss[i]=dis[i];
	}
	sort(id+1,id+1+n,([](int a,int b){return diss[a]<diss[b];}));
	cnt[s]=1;
	for(int j=1;j<=n;j++)
		for(int i=box[id[j]];i;i=las[i])
			if(dis[edv[i]]==dis[id[j]]+edw[i])
				cnt[edv[i]]=(cnt[edv[i]]+cnt[id[j]])%mod;
}
int main()
{
	read(n);
	read(m);
	read(s);
	read(t);
	int a,b,c;
	for(int i=0;i<m;i++)
	{
		read(a);
		read(b);
		read(c);
		adde(a,b,c);
		adde(b,a,c);
	}
	spfa(s,dis1,cnt1);//cout<<"EM"<<endl;
//	for(int i=1;i<=n;i++)	cout<<i<<' '<<cnt1[i]<<endl;
	spfa(t,dis2,cnt2);
	long long gg=dis1[t];
	long long ans=(cnt1[t]*cnt1[t])%mod;//cout<<ans<<endl;
	for(int i=1;i<=n;i++)
	{
		if(dis1[i]==dis2[i] && dis1[i]+dis2[i]==gg)
			ans=(ans-((cnt1[i]*cnt2[i])%mod)*((cnt1[i]*cnt2[i])%mod))%mod;
		for(int j=box[i];j;j=las[j])
		{
			int v=edv[j];//cout<<dis1[i]<<' '<<dis2[v]<<' '<<edw[j]<<endl;
			if(dis1[i]+dis2[v]+edw[j]==gg && 2*dis1[i]<gg && 2*dis2[v]<gg)
				ans=(ans-((cnt1[i]*cnt2[v])%mod)*((cnt1[i]*cnt2[v])%mod))%mod;
		}
	}
	ans=(ans+mod)%mod;
	cout<<ans<<endl;
	return 0;
}