#Q66. 「一本通 3.1 例 1」黑暗城堡

「一本通 3.1 例 1」黑暗城堡

Description

You know that Dark Castle has NN rooms and MM possible bidirectional passages that can be constructed, along with the length of each passage.

The castle is tree-shaped and satisfies the following conditions:

Let DiD_i be the shortest path length between the ii-th room and the 11-st room if all passages are built;

And let SiS_i be the path length between the ii-th room and the 11-st room in the actually constructed tree-shaped castle;

It is required that for all integers ii (1iN1\le i\le N), Si=DiS_i = D_i holds.

You want to know how many different castle construction schemes exist. Of course, you only need to output the result modulo 23112^{31} -1.

Input Format

The first line contains two integers separated by a space, NN and MM;

The second to the (M+1)(M+1)-th lines each contain three integers separated by spaces, xx, yy, ll, indicating that the passage between the xx-th room and the yy-th room has a length of ll.

Output Format

An integer: the number of different castle construction schemes modulo 23112^{31} -1.

Sample 1

There are 44 rooms and 66 passages, where the lengths of the passages between rooms 1 and 2, 1 and 3, 1 and 4, 2 and 3, 2 and 4, and 3 and 4 are 11, 22, 33, 11, 22, and 11, respectively.

The number of different castle construction schemes modulo 23112^{31} -1 is 66.

4 6
1 2 1
1 3 2
1 4 3
2 3 1
2 4 2
3 4 1

6

Data Range and Hints

For all data, 1N10001\le N\le 1000, 1MN(N1)21\le M\le \frac{N(N-1)}{2}, 1l2001\le l\le 200.