'use strict';
const main = input => {
  const [n, q] = input[0].split(' ').map(val => parseInt(val));
  // console.log(n, q);
  const p = new Array(q), x = new Array(q);
  for(let i=0; i<q; i++) {
    [p[i], x[i]] = input[n+i].split(' ').map(val => parseInt(val, 10));
  }
  // 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++) {
    [a[i], b[i]] = input[1+i].split(' ').map(val => parseInt(val, 10));
  }
  // 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]) {
        [a[i], a[j], b[i], b[j]] = [a[j], a[i], b[j], b[i]];
      }
    }
  }
  // console.log(a,b);
  for(let i=0; i<n-1; i++) {
    arr[b[i]-1] += arr[a[i]-1];
  }
  console.log(arr);
  
};
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));