Shortest Paths#2968

Shortest Paths

1 second
128 megabytes
Very easy (≈850)

A weighted directed graph and a starting vertex are given.

For each vertex , output the length of the shortest path from to .

Input

The first line contains three integers , , (2 \leq n \leq 2000, 1 \leq m \leq 5000): the number of vertices and edges in the graph, and the starting vertex number.

The next lines describe the edges of the graph. Each edge is given by three integers: the starting vertex, the ending vertex, and the weight of the edge. The weight is an integer, and its absolute value does not exceed 10^{15}. The graph may contain multiple edges and loops.

Output

Print lines: for each vertex , print the length of the shortest path from to . If there is no path between and , print "*". If there is no shortest path between and , print "-".

Examples

Example 1

Loading
Loading