Graph 1, 1/2, 1/3, 1/4#5471

Graph 1, 1/2, 1/3, 1/4

1 second
128 megabytes
Medium

Given a connected, weighted, undirected graph with edge weights , \dfrac{1}{2}, \dfrac{1}{3}, and \dfrac{1}{4}. Find the shortest path from vertex to all others.

Input

The first line contains two integers and (1 \leq n \leq 10^6, 1 \leq m \leq 8 \times 10^5) — the number of vertices and edges in the graph. The edges are given on separate lines. Each edge is given with three integers: , and (1 \leq u, v \leq n, u \leq v, 1 \leq w \leq 4), meaning that there is an undirected edge between and with weight \dfrac{1}{w}.

Output

For each vertex from to , print one number — the length of the shortest path from vertex to it, with at least digits after the decimal point.

prb5471.gif

Examples

Example 1

Loading
Loading