There is a country with villages and each village has a number associated with them and roads, a road connects two different villages
In this country, the Prime minister decided to test the hospitals to see if they can handle another wave of the coronavirus pandemic.
A village has the vaccine if the number associated with it is a prime number (villages numbered 2,3,5,7,11... will have a vaccine with them)
For each village find the minimum time required for the vaccine to arrive there if for each road between villages and it takes time to travel this road
Note: The graph does not have self-loops or multi edges
Input :
The first line will contain and , the number of villages and the number of roads respectively
The next lines contain two integers and (meaning there is a road between villages and and it takes time to travel this road)
Output:
Print space-separated integers which is the minimum time for the vaccine to arrive at that village, if it's impossible for the vaccine to arrive at a particular village then print -1
Constraints:
Village number 2,3 and 5 have their own vaccines so the time required for them is 0
Village number 6 is not connected to any village which has a vaccine, therefore -1
Village number 1,4 will get its vaccine in the shortest time from village 2