'use strict';
const main = input => {
  const c = input[0].split(' ').map(val => parseInt(val, 10));
  const n = c[0], q = c[1];
  // console.log(n, q);
  const p = new Array(q), x = new Array(q);
  for(let i=0; i<q; i++) {
    let d = input[n+i].split(' ').map(val => parseInt(val, 10));
    p[i] = d[0];
    x[i] = d[1];
  }
  // console.log(p, x);
  let arr = Array.apply(null, Array(n)).map(()=> 0);
  // console.log(arr);
  for(let i=0; i<q; i++) {
    arr[p[i]-1] += x[i];
  }
  // console.log(arr);
  const a = new Array(n-1), b = new Array(n-1);
  for(let i=0; i<n-1; i++) {
    let f = input[1+i].split(' ').map(val => Number(val));
    a[i] = f[0];
    b[i] = f[1];
  }
  // console.log(a,b);
  for(let i=0; i<n-2; i++) {
    for(let j=i+1; j<n-1; j++) {
      if (a[i]>a[j]) {
        let g = a[i];
        a[i] = a[j];
        a[j] = g;
        let k = b[i];
        b[i] = b[j];
        b[j] = k;
      }
    }
  }
  // console.log(a,b);
  for(let i=0; i<n-1; i++) {
    arr[b[i]-1] += arr[a[i]-1];
  }
  // console.log(arr);
  arr = arr.toString().replace(/,/g,' ');
  
  console.log(arr);
  
};
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));