Crayfish

No attempts yetTime limit1sMemory limit128 MB

Problem

There is a pond where nn turtles live. The pond also has nn houses, numbered from 11 to nn, and exactly one turtle lives in each house. A traveling crayfish, who is a friend of every turtle, is coming to the pond and will stay in one of the houses. The crayfish wants to pick a house from which it can visit as many friends as possible.

Visiting a friend means traveling from the house where the crayfish is staying to that friend's house and then coming back. The crayfish does not count the turtle in whose house it stays.

The crayfish moves between houses along one-way routes, following these rules:

  1. The crayfish moves only along the given routes.
  2. Every route is one-way and joins two different houses. Several routes may join the same pair of houses.
  3. The crayfish travels either forward or backward. Standing in house AA and moving forward, it can go to house BB if there is a route from AA to BB. Moving backward, it can go from house AA to house BB if there is a route from BB to AA.
  4. Some routes are special. Immediately after traversing a special route, the crayfish reverses its direction: forward becomes backward and backward becomes forward. The crayfish can change direction only in this way.
  5. At the start of a trip the crayfish is moving backward. Passing through a friend's house does not change its direction. At the end of the trip the crayfish must again be moving backward (so if the last route it uses is special, it must be moving forward just before entering that route).

Write a program that reads the routes of the pond and, for each house, prints how many friends the crayfish could visit if it stayed in that house.

Input

The first line contains two integers nn and mm (1n100001 \le n \le 10000, 1m1000001 \le m \le 100000): the number of houses and the number of routes. Each of the next mm lines describes one route with three integers aa, bb and ss (1a,bn1 \le a, b \le n, aba \ne b, s{0,1}s \in \{0, 1\}). Here aa is the starting house and bb is the ending house of the route, and the route is special if and only if s=1s = 1.

Output

Print exactly nn lines. Line ii must contain a single integer: the number of friends the crayfish could visit if it stayed in house ii.

Notes

The figure below illustrates a pond with five houses and five routes.

If the crayfish stays in house 11, it can visit houses 22, 33 and 44. Staying in house 22, it can visit houses 33, 44 and 55; staying in house 33, houses 22, 44 and 55; staying in house 44, houses 22, 33 and 55. Staying in house 55, it can visit none of its friends.