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=[],i=0;i<n;i++)u.push({counter:0,to:[]});for(var l=0;l<n-1;l++){var f=e[l+1].split(" "),a=Number(f[0])-1,c=Number(f[1])-1;u[a].to.push(u[c])}for(var p=0;p<o;p++){var s=e[p+n].split(" "),v=Number(s[0])-1,d=Number(s[1]);u[v].counter+=d;for(var b=u[v].to.concat();b.length>0;){var y=b.shift();y.counter+=d;var m=!0,h=!1,g=void 0;try{for(var x,j=y.to[Symbol.iterator]();!(m=(x=j.next()).done);m=!0){var O=x.value;b.push(O)}}catch(r){h=!0,g=r}finally{try{m||null==j.return||j.return()}finally{if(h)throw g}}}}for(var S=[],N=0,_=u;N<_.length;N++){var P=_[N];S.push(P.counter)}console.log(...S)}},function(r,e){r.exports=require("fs")}]);