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 data= new Array(N).fill(0);
  var results = new Array(N).fill(0);
  inputs.slice(1, N).forEach(nodeLine => {
    const nodes = nodeLine.split(" ").map(num => parseInt(num, 10));
    const a = nodes[0] - 1;
    const b = nodes[1] - 1;
    hash[a] ? hash[a].push(b) : hash[a] = [b];
    hash[b] ? hash[b].push(a) : hash[b] = [a];
  });
  inputs.slice(N).forEach(valueList => {
    const values = valueList.split(" ").map(num => parseInt(num, 10));
    const node = values[0] - 1;
    const value = values[1];
    data[node] += value;
  })
  
  var isCalcs = new Array(N).fill(false);
  
  function dfs(topNode, topNodeVal) {
    if (hash[topNode]){
      hash[topNode].forEach(node => {
        if (!isCalcs[node]) {
          const result = topNodeVal + data[node];
          results[node] = result;
          isCalcs[node] = true;
          dfs(node, result);
        }
      });
    }
  };
  results[0] = data[0];
  isCalcs[0] = true;
  dfs(0, data[0]);
  console.log(results.join(" "));
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));