{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cscript type\u003d\u0027text/x-mathjax-config\u0027\u003eMathJax.Hub.Config({tex2jax: { inlineMath: [[\u0027$\u0027,\u0027$\u0027]] } }); \u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027 src\u003d\u0027https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\u0027\u003e\u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027\u003esetTimeout(function(){MathJax.Hub.Queue([\u0027Typeset\u0027, MathJax.Hub, \u0027left_view\u0027]);}, 2000);\u003c/script\u003e\n\u003cdiv class\u003d\"panel_content\"\u003e\n A school bought the first computer some time ago(so this computer\u0027s id is 1). 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 the maximum distance Si 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. \n \u003cbr\u003e \n \u003ccenter\u003e \n \u003cimg style\u003d\"max-width:100%;\" SRC\u003d\"CDN_BASE_URL/3f5ab5c3d97280e16503ce9ef614b5c5?v\u003d1576772352\"\u003e \n \u003c/center\u003e \n \u003cbr\u003e \n \u003cbr\u003eHint: the example input is corresponding to this graph. And from the graph, you can see that the computer 4 is farthest one from 1, so S1 \u003d 3. Computer 4 and 5 are the farthest ones from 2, so S2 \u003d 2. Computer 5 is the farthest one from 3, so S3 \u003d 3. we also get S4 \u003d 4, S5 \u003d 4. \n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"Input file contains 50 -100 test cases.In each case there is natural number N (N\u0026lt;\u003d10000) in 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 10^9. Numbers in lines of input are separated by a space."}},{"title":"Output","value":{"format":"HTML","content":"For each case output N lines. i-th line must contain number Si for i-th computer (1\u0026lt;\u003di\u0026lt;\u003dN)."}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e5\n1 1\n2 1\n3 1\n1 1\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003e3\n2\n3\n4\n4\u003c/pre\u003e"}}]}