In the event of technical difficulties with Szkopuł, please contact us via email at [email protected].
If you would like to talk about tasks, solutions or technical problems, please visit our Discord servers. They are moderated by the community, but members of the support team are also active there.
In Byteland there is a pond occupied by turtles. In this pond there are also houses, numbered from to . In each of these houses lives exactly one turtle. Soon the crayfish migrant (who lives in Bytemerica) will come to Byteland. This crayfish is very social and all turtles are his friends. During his visit, the crayfish plans to stay at one of his friend's house. But the problem is, in which house he should stay.
Crayfish migrant is interested in houses which will allow him to visit as many friends as possible. One could think, that visiting friends is not a problem, but in a Byteland pond it is harder that is seems. Firstly, in order to visit someone, one must reach his house. Secondly, one must also get back. We assume, that the crayfish migrant will not visit the turtle, in whose house he will stay.
Crayfish moves according to the following rules:
Write a program which:
The first line of the standard input contains two integers and (, ). These numbers denote respectively: the number of houses and the number of routes. In the following lines there are descriptions of particular routes, each on a separate line. Each description consists of three integers , and (, ). Integer denotes the starting house number, denotes ending house number. Route is special if and only if .
Exactly lines are to be written to the standard output. In the -th line exactly one integer is to be written, this integer is the number of friends the crayfish could visit, if he stayed at house number .
For the input data:
5 5 2 1 1 2 3 0 3 4 0 4 2 0 5 3 1
the correct result is:
3 3 3 3 0
Staying at house number 1 the crayfish can visit friends from houses 2, 3, 4. Staying at house number 2 the crayfish can visit friends from houses 3, 4, 5. Staying at house number 3 the crayfish can visit friends from houses 2, 4, 5. Staying at house number 4 the crayfish can visit friends from houses 2, 3, 5. Staying at house number 5 the crayfish can visit none of his friends.
Task author: Szymon Acedanski.