The Other Way

Count the number of distinct shortest paths between two towns in a weighted undirected multigraph, modulo 10^9+9.

Medium5GraphShortest pathDynamic programmingNo attempts yetTime limit2sMemory limit256 MB

Problem

Kir lives in a country with NN towns, numbered 1 through NN. The towns are joined by MM roads, and every road can be walked in both directions.

Kir wants to go from town SS to town EE. He has always taken the same route, so he now wants to walk a different one, and he wonders how many different shortest routes from town SS to town EE there are. Two routes are different when one of them uses a road that the other does not. Roads are counted one by one, so if several roads join the same pair of towns, which road you take changes the route.

A shortest route is one whose total road length is as small as possible.

Answer Kir's question.

Input

The first line contains NN, MM, SS, and EE, separated by single spaces. (2N1000002 \le N \le 100000, N1M300000N-1 \le M \le 300000, 1S,EN1 \le S, E \le N, SES \neq E)

Each of the next MM lines describes one road with AA, BB, and CC, separated by single spaces. It means a road of length CC joins town AA and town BB in both directions. (1A,BN1 \le A, B \le N, 1C10000000001 \le C \le 1000000000)

Several roads may join the same pair of towns, and a road with A=BA = B may appear.

Output

Print the number of shortest routes from town SS to town EE, modulo 1000000009 (109+910^9 + 9). If no route from town SS to town EE exists, print 0.