Input file contains multiple test cases.In each case there is natural number Nin the first line, 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
. Numbers in lines of input are separated by a space.
For each case output N lines. i-th line must contain number Si for i-th computer.