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