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 N-1 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 i-th 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 (N-1) lines with descriptions of computers. i-th line contains two natural numbers - number of computer, to which i-th 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. i-th line must contain number Si for i-th 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