function Main(input) {
  const inputs = input.split("\n");
  const a = inputs[0].split(" ").map(num => parseInt(num, 10));
  const N = a[0];
  const Q = a[1];
  var hash = {};
  var results = new Array(N).fill(0);
  var data = new Array(N).fill(0);
  inputs.slice(1, N).forEach(list => {
    const nodes = list.split(" ").map(num => parseInt(num, 10));
    const node = nodes[0];
    const nextNode = nodes[1];
    if (!hash[node]) {
      hash[node] = [nextNode];
    } else {
      hash[node].push(nextNode);
    }
    Object.keys(hash).filter((key) => hash[key].indexOf(node) !== -1).forEach((key) => {
      hash[key].push(nextNode);
    })
  });
  inputs.slice(N).forEach(list => {
    const nodeAndNum = list.split(" ").map(num => parseInt(num, 10));
    const node = nodeAndNum[0];
    const num = nodeAndNum[1];
    data[node - 1] += num;
  });
  (data).forEach((v, index) => {
    if (v !== 0) {
      results[index] += v;
      if (hash[index + 1]) {
        hash[index + 1].forEach(n => results[n - 1] += v);
      }
    }
  });
  console.log(results.join(" "));
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));