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 reg register
typedef long long ll;
using namespace std;
const int mod=1e9+7;
const int MN=1e5+5;
const ll inf=0x3f3f3f3f3f3f3f3f;
int to[MN<<2],nxt[MN<<2],c[MN<<2],h[MN],cnt;
inline void ins(int s,int t,int w){
	to[++cnt]=t;nxt[cnt]=h[s];c[cnt]=w;h[s]=cnt;
	to[++cnt]=s;nxt[cnt]=h[t];c[cnt]=w;h[t]=cnt;
}
ll disS[MN],disT[MN];
int gS[MN],gT[MN];
typedef pair<ll,int>pli;
priority_queue<pli,vector<pli>,greater<pli> >q;
bool vis[MN];
int n,m,S,T,x[MN<<1],y[MN<<1],W[MN<<1];
inline void Dij(ll* dis,int* g,int s){
	memset(dis,0x3f,sizeof(ll)*(n+1));
	memset(vis,0,sizeof(vis));
	dis[s]=0;g[s]=1;q.push(make_pair(0,s));
	while(!q.empty()){
		static pli v;v=q.top();q.pop();
		if(vis[v.second])continue;vis[v.second]=true;
		for(reg int st,i=h[st=v.second];i;i=nxt[i])
			if(dis[to[i]]>dis[st]+c[i])
				dis[to[i]]=dis[st]+c[i],
				q.push(make_pair(dis[to[i]],to[i])),
				g[to[i]]=g[st];
			else if(dis[to[i]]==dis[st]+c[i])g[to[i]]=(g[to[i]]+g[st])%mod;
	}
}
int main(){
	scanf("%d%d%d%d",&n,&m,&S,&T);
	for(reg int i=1,s,t,w;i<=m;i++)
		scanf("%d%d%d",&s,&t,&w),ins(s,t,w),x[i]=s,y[i]=t,W[i]=w;
	Dij(disS,gS,S);Dij(disT,gT,T);
	reg int ans=1ll*gS[T]*gS[T]%mod;
	for(reg int i=1;i<=n;i++)
		if(disS[i]+disT[i]==disS[T]&&disS[i]==disT[i])
			ans=(ans-1ll*gS[i]*gS[i]%mod*gT[i]%mod*gT[i]%mod+mod)%mod;
	for(reg int i=1;i<=m;i++){
		if(disS[x[i]]>=disS[y[i]])swap(x[i],y[i]);
		if(disS[x[i]]+W[i]!=disS[y[i]])continue;
		if(disT[y[i]]+W[i]!=disT[x[i]])continue;
		if(disS[x[i]]+W[i]+disT[y[i]]!=disS[T])continue;
		if(disS[x[i]]+W[i]<=disT[y[i]])continue;
		if(disT[y[i]]+W[i]<=disS[x[i]])continue;
		ans=(ans-1ll*gS[x[i]]*gS[x[i]]%mod*gT[y[i]]%mod*gT[y[i]]%mod+mod)%mod;
	}printf("%d\n",ans);
	return 0;
}