Parade

For each road, count the pairs of intersections whose shortest distance grows when that road is removed from the graph.

Medium6GraphShortest pathBrute forceNo attempts yetTime limit5sMemory limit512 MB

Problem

A city has NN intersections and MM roads. The intersections are numbered 00 through N1N-1 and the roads are numbered 00 through M1M-1. Every road is bidirectional and joins two different intersections. At most one road joins any given pair of intersections. The city is connected, so you can travel from any intersection to any other one along roads.

The mayor picks one road and holds a parade on it. While the parade runs, nobody can travel along that road.

The city runs one bus line for every pair of intersections (X,Y)(X, Y), so there are N(N1)/2N(N-1)/2 lines. A line is affected by the parade when the shortest distance between XX and YY in the graph without the parade road is longer than the original shortest distance. A pair that can no longer reach each other counts as affected.

For each road, count the bus lines that are affected when the parade is held on that road.

Input

The first line contains the number of intersections NN (1N1001 \le N \le 100) and the number of roads MM (1M20001 \le M \le 2000).

Each of the next MM lines describes one road, given in order from road 00 to road M1M-1. A road is three integers from, to and time, meaning that traveling between intersection from and intersection to takes time. Both endpoint numbers are between 00 and N1N-1 and are different, and the travel time is between 11 and 10001000.

Output

Print, for road 00 through road M1M-1 in order, the number of bus lines affected when the parade is held on that road. Separate the numbers with spaces and print them on one line.