- Time limit: 1.00 s
- Memory limit: 512 MB
We have a directed graph with nodes and edges. Edge is from to with cost . There are special nodes in a graph, namely .
Call the minimum cost of a path from node to node . Calculate for every node the value , that is, the sum of distances from that node to every special node.
It is guaranteed that every node is reachable from every other node.
Input
The first line contains the three integers .
Then lines follow. Every line contains the three integers .
The last line contains the integers .
Output
Output integers: the values .
Constraints
Example
Input:
4 6 2 4 1 10 2 3 4 1 2 10 3 4 6 3 1 9 2 3 3 2 3
Output:
23 3 19 43