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<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

const int N=1e5+100,M=4e5+100;
const int mod=1e9+7;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

int head[N],nxt[M],to[M],w[M],n;
struct Q{ int k; LL dis; inline bool operator < (const Q &b) const { return dis>b.dis; } };
struct Graph{
	LL dis[N];int f[N];bool out[N];
	inline void shortroad(int k) {
		int i;priority_queue<Q>q;
		for (i=1;i<=n;i++) dis[i]=OO;
		q.push((Q){k,dis[k]=0});f[k]=1;
		while (!q.empty()) {
			k=q.top().k;q.pop();
			if (out[k]) continue;out[k]=true;
			for (i=head[k];i;i=nxt[i])
				if (dis[k]+w[i]<dis[to[i]])
					q.push((Q){to[i],dis[to[i]]=dis[k]+w[i]}),f[to[i]]=f[k];
				else if (dis[k]+w[i]==dis[to[i]])
					(f[to[i]]+=f[k])%=mod;
		}
	}
}G1,G2;
int main()
{
	n=gi();int m=gi(),i,S=gi(),T=gi(),a,b,ans,tot=1,t;
	for (i=1;i<=m;i++) {
		a=gi(),b=gi();
		to[++tot]=b,nxt[tot]=head[a],head[a]=tot;
		to[++tot]=a,nxt[tot]=head[b],head[b]=tot;
		w[tot]=w[tot-1]=gi();
	}
	G1.shortroad(S);
	G2.shortroad(T);
	ans=1LL*G1.f[T]*G2.f[S]%mod;
	for (i=1;i<=n;i++)
		if (G1.dis[i]+G2.dis[i]==G1.dis[T]&&G1.dis[i]==G2.dis[i])
			t=1LL*G1.f[i]*G2.f[i]%mod,ans=(ans-1LL*t*t)%mod;
	for (i=2;i<=tot;i++) {
		a=to[i^1],b=to[i];
		if (G1.dis[a]+G2.dis[b]+w[i]==G1.dis[T]&&G1.dis[a]<G2.dis[a]&&G1.dis[b]>G2.dis[b])
			t=1LL*G1.f[a]*G2.f[b]%mod,ans=(ans-1LL*t*t)%mod;
	}
	cout<<(ans+mod)%mod<<endl;
	return 0;
}