module.exports=function(r){var e={};function t(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return r[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=r,t.c=e,t.d=function(r,e,n){t.o(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:n})},t.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},t.t=function(r,e){if(1&e&&(r=t(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var o in r)t.d(n,o,function(e){return r[e]}.bind(null,o));return n},t.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return t.d(e,"a",e),e},t.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},t.p="",t(t.s=0)}([function(r,e,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(r,e){r.exports=function(r){for(var e=r.split("\n"),t=e[0].split(" "),n=Number(t[0]),o=Number(t[1]),u=[],l=0;l<n;l++)u.push([]);for(var i=0;i<n-1;i++){var a=e[i+1].split(" "),f=Number(a[0])-1,c=Number(a[1])-1;u[f].push(c)}for(var p=new Array(n),s=n-1;s>=0;s--){p[s]=[s];var v=!0,y=!1,d=void 0;try{for(var b,m=u[s][Symbol.iterator]();!(v=(b=m.next()).done);v=!0){var x=b.value;p[s].push(...p[x])}}catch(r){y=!0,d=r}finally{try{v||null==m.return||m.return()}finally{if(y)throw d}}}for(var h=[],g=0;g<o;g++){var S=e[g+n].split(" "),j=Number(S[0])-1,O=Number(S[1]);g>0&&h[g-1].p==j?h[g-1].x+=O:h.push({x:O,p:j})}for(var N=new Array(n).fill(0),_=0,w=h;_<w.length;_++){var P=w[_],M=!0,T=!1,A=void 0;try{for(var F,q=p[P.p][Symbol.iterator]();!(M=(F=q.next()).done);M=!0){N[F.value]+=P.x}}catch(r){T=!0,A=r}finally{try{M||null==q.return||q.return()}finally{if(T)throw A}}}console.log(...N)}},function(r,e){r.exports=require("fs")}]);