149. Computer Network
time limit per test: 0.25
sec.
memory limit per test: 4096
KB
input: standard input
output: standard output
A school bought the first computer some time ago. During the recent years the school bought N1 new computers. Each new computer was connected to one of settled earlier. Managers of school are anxious about slow functioning of the net and want to know for each computer number Si  maximum distance, for which ith computer needs to send signal (i.e. length of cable to the most distant computer). You need to provide this information.
Input
There is natural number N (N<=10000) in the first line of input, followed by (N1) lines with descriptions of computers. ith line contains two natural numbers  number of computer, to which ith computer is connected and length of cable used for connection. Total length of cable does not exceed 10^9. Numbers in lines of input are separated by a space.
Output
Write N lines in output file. ith line must contain number Si for ith computer (1<=i<=N).
Sample test(s)
Input
3
1 1
1 2
Output
2
3
3
Author:  Andrew V. Lazarev, Michael R. Mirzayanov

Resource:  Saratov Subregional School Team Contest, 2002

Date:  Fall, 2002

Server time: 20160524 16:42:05  Online Contester Team © 2002  2016. All rights reserved. 

