In the town of Aizu, where PCK lives, there are N points and M roads connecting each point. Each point is numbered from 1 to N, and all roads can be traveled in both directions. You can also reach other points from any point by taking some of the paths.
PCK's house is at point 1 and his school is at point N. PCK wants to find out the shortest way to school for each of the paths he must take from all the paths in the town of Aizu. However, the route to school must meet the following conditions:
You are given a number of points and information about the roads that connect the points directly. Create a program to find the distance of the school route when each path is chosen.
The input is given in the following format.
N M s1 t1 d1 s2 t2 d2 : sM tM dM
The first line gives the number of points N (2≤N≤20) and the number of roads M (1≤M≤N(N−1)/2). In the following M lines, the information on the roads that directly connect the two points is given. si and ti (1≤si<ti≤N) are the numbers of the two points connected by the ith path, and di (1≤di≤1000) is the distance of the path. However, for any two points, no more than one road can connect them directly.
The output is the M lines. Output the distance of the school route when the route given in the ith input is always used, in the ith line. However, if there is no school route that uses the ith given road, output "-1".
5 5 1 2 4 1 3 1 1 4 3 2 4 2 4 5 6
12 -1 9 12 9