Adi of Adi and Sorin would like to visit their country this summer. They live in a country that can be represented as a graph with nodes and edges, where each city is a node and each bidirectional road between two cities is a weighted edge in the same graph (where the weight of the edge represents the length of the road in kilometers).
Since they really like the cities Constanța and Timișoara, they decided to visit both of these cities in their vacantion. More formaly, we will note the city of Constanța as node and the city of Timișoara as node . Now, if they want to start their journey in city and end it in city , then their path will have the following properties:
- the length of the path is as small as possible (where the length is equal to the sum of weights of the edges in the path);
- the path visits both and .
Task
Let be the length of the path that Adi of Adi and Sorin will visit if they start their journey in node and end it in node . Note that a node or an edge can occur multiple times in the path. Your task is to calculate . Since this number can be very large, calculate it modulo .
Input data
The first line of the input contains the numbers , , and . The next lines will each contain three numbers , and , representing a weighted edge between and of weight .
Output data
Output a single number, the sum of for all ordered pairs of nodes modulo .
Constraints and clarifications
- There will be no self-loops or multiple edges in the input.
# | Points | Constraints |
---|---|---|
1 | 12 | , |
2 | 29 | , |
3 | 59 | No additional constraints. |
Example
stdin
3 2 1 3
1 2 1
3 1 1
3 2 3
stdout
6
Explanation