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