Cirno is a strict teacher, while Wings is a naughty student.
Cirno assigns a huge amount of homework to

of her students, including Wings every day. Wings wants to finish the homework as soon as possible. He calls on the classmates to copy homework from each other. Due to the different abilities of these students, the time it takes for each to finish the homework independently may be different. After discussion, in order to make everyone finish the homework as soon as possible, these students developed a solution: one can ask other who has finished the homework for answers and then just copy that. Cirno is too strict with her students, she has confiscated all the Internet-capable devices of her students, so these students must copy the homework in a more primitive way — going to another student's home.
There are

bidirectional roads between the homes of

students and each road connects two students' homes. Any two students can reach each other's home directly or indirectly. If student

intends to copy student

's homework, he or she must wait for student

to finish the homework, then leaves for student

's home and copies the homework, and finally returns home (
The homework is considered to be finished only when the student returns home). The time taken for student

to leave for student

's home, copy the homework, and finally return home equals to the distance between student

's home and student

's home.
Soon, Cirno discovered Wings's tricks. She was very angry, so she planned to calculate the earliest time for each student to finish the homework, and increase the amount of homework according to the situation as a punishment. However, the students' learning status and the road lengths will change. Cirno asks you to help her to calculate the earliest time for each student to finish the homework in different situation.