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 JAVA):

Solution:
// package arc.arc090;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    private static final long MOD = 1000000007;

    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt();
        int m = in.nextInt();

        int s = in.nextInt()-1;
        int t = in.nextInt()-1;

        graph = new List[n];
        for (int i = 0; i < n ; i++) {
            graph[i] = new ArrayList<>();
        }
        for (int i = 0; i < m ; i++) {
//            int l = 0;
//            int r = 0;
//            int d = (int)(Math.random() * 1) + 1;
//            while (l == r) {
//                l = (int)(Math.random() * n);
//                r = (int)(Math.random() * n);
//            }

            int l = in.nextInt()-1;
            int r = in.nextInt()-1;
            int d = in.nextInt();
            graph[l].add(new int[]{r, d});
            graph[r].add(new int[]{l, d});
        }

        long[] fromSDistance, fromSPtn;
        long[] fromTDistance, fromTPtn;

        {
            long[][] fromS = doit(s);
            fromSDistance = fromS[0];
            fromSPtn = fromS[1];

            long[][] fromT = doit(t);
            fromTDistance = fromT[0];
            fromTPtn = fromT[1];
        }

        if (fromSPtn[t] != fromTPtn[s]) {
            throw new RuntimeException("unk");
        }

        long all = fromSPtn[t] * fromTPtn[s] % MOD;
        long D = fromSDistance[t];

        long removePath = 0;
        long removeVec = 0;
        for (int i = 0; i < n ; i++) {
            for (int[] e : graph[i]) {
                int from = i;
                int to = e[0];
                long d = e[1];

                if (fromSDistance[from] + d + fromTDistance[to] == D) {
                    if (fromSDistance[from] + d == fromSDistance[to]) {
                        if (fromTDistance[to] + d == fromTDistance[from]) {
                            long abs = Math.abs(fromSDistance[from] - fromTDistance[to]);
                            if (abs < d) {
                                long way = fromSPtn[from] * fromTPtn[to] % MOD;
                                removePath += way * way % MOD;
                            }
                        }
                    }
                }

                if (fromSDistance[to] + d + fromTDistance[from] == D) {
                    if (fromSDistance[to] + d == fromSDistance[from]) {
                        if (fromTDistance[from] + d == fromTDistance[to]) {
                            long abs = Math.abs(fromSDistance[to] - fromTDistance[from]);
                            if (abs < d) {
                                long way = fromSPtn[to] * fromTPtn[from] % MOD;
                                removePath += way * way % MOD;
                            }
                        }
                    }
                }
                removePath %= MOD;
            }

            if (fromSDistance[i] == fromTDistance[i] && fromSDistance[i] + fromTDistance[i] == D) {
                long way = fromSPtn[i] * fromTPtn[i] % MOD;
                removeVec += way * way % MOD;
                removeVec %= MOD;
            }
        }


//        debug(fromSDistance, fromSPtn);
//        debug(fromTDistance, fromTPtn);
//        debug(all, removePath, removeVec);

        all += MOD - removePath*inv(2)%MOD;
        all += MOD - removeVec;

        out.println(all%MOD);
        out.flush();
    }

    static long pow(long a, long x) {
        long res = 1;
        while (x > 0) {
            if (x % 2 != 0) {
                res = (res * a) % MOD;
            }
            a = (a * a) % MOD;
            x /= 2;
        }
        return res;
    }

    static long inv(long a) {
        return pow(a, MOD - 2) % MOD;
    }

    static long[][] doit(int start) {
        int n = graph.length;
        long[] distance = new long[n];
        long[] ptn = new long[n];
        Arrays.fill(distance, INF);

        distance[start] = 0;
        ptn[start] = 1;

        Queue<State> que = new PriorityQueue<>();
        que.add(new State(start, 0));
        while (que.size() >= 1) {
            State st = que.poll();
            if (distance[st.now] < st.time) {
                continue;
            }
            for (int[] t : graph[st.now]) {
                int to = t[0];
                long d = st.time + t[1];
                if (distance[to] > d) {
                    distance[to] = d;
                    ptn[to] = ptn[st.now];
                    que.add(new State(to, d));
                } else if (distance[to] == d) {
                    ptn[to] += ptn[st.now];
                    ptn[to] %= MOD;
                }
            }
        }
        return new long[][]{distance, ptn};
    }

    static class State implements Comparable<State> {
        int now;
        long time;

        public State(int n, long t) {
            now = n;
            time = t;
        }

        @Override
        public int compareTo(State o) {
            return Long.compare(time, o.time);
        }
    }

    static List<int[]>[] graph;
    static long INF = Long.MAX_VALUE;

    public static void debug(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }

    public static class InputReader {
        private static final int BUFFER_LENGTH = 1 << 12;
        private InputStream stream;
        private byte[] buf = new byte[BUFFER_LENGTH];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private int next() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public char nextChar() {
            return (char) skipWhileSpace();
        }

        public String nextToken() {
            int c = skipWhileSpace();
            StringBuilder res = new StringBuilder();
            do {
                res.append((char) c);
                c = next();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public int nextInt() {
            return (int) nextLong();
        }

        public long nextLong() {
            int c = skipWhileSpace();
            long sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = next();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public double nextDouble() {
            return Double.valueOf(nextToken());
        }

        int skipWhileSpace() {
            int c = next();
            while (isSpaceChar(c)) {
                c = next();
            }
            return c;
        }

        boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
    }
}