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 pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

typedef long long ll;
typedef pair<ll , ll> pii;
typedef long double DB;

const ll N = 100100;
const ll MOD = 1000*1000*1000LL + 7 , INF = MOD*N;


vector <pii> adj1[N];
vector <int> q , par[N] , adj2[2][N];
set <pii> s;

ll num[2][N] , d[2][N] , ans;
int n , m , b , e , deg[N];


void Dijkstra(int st , bool f){

	for(int i = 0 ; i < n ; i++){
	   if(i != st)
		  d[f][i] = INF;
	   s.insert({d[f][i] , i});
	}   

	while(s.size()){

		int v = (*s.begin()).S;
		s.erase(s.begin());

		for(auto u : adj1[v]){
		   ll c = d[f][v] + u.S;
		   if(c < d[f][u.F]){
			  s.erase({d[f][u.F] , u.F});
			  d[f][u.F] = c;
			  s.insert({c , u.F});
		   }
		}

	}

	return;

}


void tsort(int st , bool f){
	
	for(int i = 0 ; i < n ; i++)
	   deg[i] = adj2[1-f][i].size();

	
	num[f][st] = 1;
	q.pb(st);

	int pt1 = 0 , pt2 = 1;

	while(pt1 < pt2){
		
	   for(int u : adj2[f][q[pt1]]){
		  deg[u]--;
		  if(!deg[u])
			 q.pb(u) , pt2++;
	   }

	   pt1++;
	}

	for(int v : q)
	   for(int u : adj2[f][v])
		  num[f][u] = (num[f][u] + num[f][v]) % MOD;
	
	q.clear();
	return;
}


int main(){

	ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
	
	int u , v , w;

	cin >> n >> m >> b >> e;
	b-- , e--;	

	for(int i = 0 ; i < m ; i++){
	   cin >> u >> v >> w;

	   adj1[--u].pb({--v , w});
	   adj1[v].pb({u , w});
	}

	Dijkstra(b , 0);
	Dijkstra(e , 1);	

	for(int i = 0 ; i < n ; i++){
	   for(auto u : adj1[i]){
		  if(d[0][i] + d[1][u.F] + u.S == d[0][e]){
			 adj2[0][i].pb(u.F);
			 adj2[1][u.F].pb(i);
		  }
	   }
	}

	tsort(b , 0);
	tsort(e , 1);

	ans = num[0][e] * num[0][e] % MOD;
	DB x = (DB) d[0][e]/2;

	for(int i = 0 ; i < n ; i++){
	   for(int u : adj2[0][i]){
		  ll y = num[1][u] , z = num[0][i];
		  if((DB) d[0][u] > x && (DB) d[0][i] < x)
			 ans -= (y*y % MOD)*(z*z % MOD) %MOD;
		  
		  ans = (ans + MOD) % MOD;
	   }
	   
	   if((DB) d[0][i] == x && d[1][i] == x){
		  ll z = num[0][i] , y = num[1][i];
	   	  ans -= (z*z % MOD)*(y*y % MOD) % MOD;
	   }

	   ans = (ans + MOD) % MOD;
	}

	cout << ans << endl;

}