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<queue>
#include<cstdio>
using namespace std;
typedef long long ll;
const int maxn=100000,mod=1000000007;
const ll inf=0x3f3f3f3f3f3f3f3f;
int n,m,s,t,ans; queue<int> q;
struct hnode{
	int id; ll v;
	bool operator<(const hnode &t)const{
		return v>t.v;
	}
};
struct edge{int to,len;};
priority_queue<hnode> hp;
struct graph{
	vector<edge> g[maxn+10]; ll dis[maxn+10]; int dz[maxn+10],f[maxn+10];
	vector<edge> z[maxn+10];
	void add(int u,int v,int w){
		g[u].push_back((edge){v,w});
		g[v].push_back((edge){u,w});
	}
	void dijkstra(int s){
		for(int i=1;i<=n;++i) dis[i]=i==s?0:inf;
		hp.push((hnode){s,0});
		for(;!hp.empty();){
			hnode x=hp.top(); hp.pop(); if(x.v>dis[x.id]) continue;
			for(int i=0;i<g[x.id].size();++i){
				edge e=g[x.id][i];
				if(x.v+e.len<dis[e.to]){
					dis[e.to]=x.v+e.len; hp.push((hnode){e.to,dis[e.to]});
				}
			}
		}
	}
	void addeg(int u,int v,int w){z[u].push_back((edge){v,w}); ++dz[v];}
	void buildnew(){
		for(int i=1;i<=n;++i)
			for(int j=0;j<g[i].size();++j){
				edge e=g[i][j]; if(dis[i]+e.len==dis[e.to]) addeg(i,e.to,e.len);
			}
	}
	void topsort(int s){
		f[s]=1; for(int i=1;i<=n;++i) if(!dz[i]) q.push(i);
		for(;!q.empty();q.pop()){
			int x=q.front();
			for(int i=0;i<z[x].size();++i){
				int e=z[x][i].to; (f[e]+=f[x])%=mod;
				if(!--dz[e]) q.push(e);
			}
		}
	}
}g,rg;
int main(){
	scanf("%d%d%d%d",&n,&m,&s,&t);
	for(int i=1;i<=m;++i){
		int l,r,w; scanf("%d%d%d",&l,&r,&w);
		g.add(l,r,w); rg.add(l,r,w);
	}
	g.dijkstra(s); rg.dijkstra(t); 
	g.buildnew(); rg.buildnew(); 
	ll d=g.dis[t];
	g.topsort(s); rg.topsort(t); ans=1ll*g.f[t]*rg.f[s]%mod;
	for(int i=1;i<=n;++i){
		for(int j=0;j<g.g[i].size();++j){
			edge e=g.g[i][j];
			if(g.dis[i]+e.len+rg.dis[e.to]==d&&g.dis[i]*2<d&&g.dis[e.to]*2>d){
				ll now=1ll*g.f[i]*rg.f[e.to]%mod;
				ans-=1ll*now*now%mod;
				ans=(ans+mod)%mod;
			}
		}
		if(g.dis[i]+rg.dis[i]==d&&g.dis[i]*2==d){
			ll now=1ll*g.f[i]*rg.f[i]%mod;
			ans-=1ll*now*now%mod;
			ans=(ans+mod)%mod;
		}
	}
	printf("%d",ans);
}