module.exports=function(t){var r={};function e(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,e),i.l=!0,i.exports}return e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:n})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,r){if(1&r&&(t=e(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var i in t)e.d(n,i,function(r){return t[r]}.bind(null,i));return n},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},e.p="",e(e.s=0)}([function(t,r,e){e(1)(e(3).readFileSync("/dev/stdin","UTF-8"))},function(t,r,e){function n(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=[],n=!0,i=!1,o=void 0;try{for(var u,s=t[Symbol.iterator]();!(n=(u=s.next()).done)&&(e.push(u.value),!r||e.length!==r);n=!0);}catch(t){i=!0,o=t}finally{try{n||null==s.return||s.return()}finally{if(i)throw o}}return e}(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var i=e(2);t.exports=function(t){for(var r=t.split("\n"),e=n(r[0].split(" ").map(function(t){return Number(t)}),2),o=e[0],u=e[1],s=new Array(o),a=0;a<o-1;a++){var l=n(r[a+1].split(" ").map(function(t){return Number(t)-1}),2),f=l[0],c=l[1];s[f]||(s[f]=[]),s[c]||(s[c]=[]),s[f].push(c),s[c].push(f)}for(var p=new Array(o).fill(0),d=0;d<u;d++){var v=n(r[d+o].split(" ").map(function(t){return Number(t)}),2),y=v[0],h=v[1];p[y-1]+=h}var m=new i,b=new Array(o).fill(0);for(m.enq(0);m.size>0;){var x=m.deq();b[x]=1;var g=!0,w=!1,j=void 0;try{for(var S,O=s[x][Symbol.iterator]();!(g=(S=O.next()).done);g=!0){var q=S.value;1!=b[q]&&(p[q]+=p[x],m.enq(q))}}catch(t){w=!0,j=t}finally{try{g||null==O.return||O.return()}finally{if(w)throw j}}}console.log(p.join(" "))}},function(t,r,e){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e4;this.size=0,this.items=[],this.ind=0,this.maxGap=t}enq(t){this.size+=1,this.items.push(t),this.items.size-this.ind>this.maxGap&&(this.items=this.items.slice(this.ind))}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}}},function(t,r){t.exports=require("fs")}]);