First Echoes
An underground city has rooms and undirected corridors. Corridor connects rooms and and takes exactly units of time to traverse in either direction.
At time , for each with , a messenger of color is placed in source room . The source rooms are pairwise distinct.
Initially, every room is unvisited. The following rules determine what happens:
- When messengers first appear in an unvisited room at some time , only messenger colors appearing in that room at exactly time matter.
- If those messengers have exactly one distinct color , the room is marked with color . Immediately at time , a copy of color starts traversing every corridor incident to that room.
Determine the final state of every room.
Input
The first line contains three integers , , and (, ), the number of rooms, corridors, and source rooms.
Output
Print one line containing integers , separated by single spaces.
Samples
Sample 1
Input
5 4 2 1 3 1 2 1 3 2 1 2 4 1 4 5 1
Output
1 0 2 -1 -1
Rooms and start with colors and . Room first sees both colors at time , so it freezes. Since no messenger starts from room , rooms and stay silent.