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