import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;
import std.range;

class Node {
  public int id;
  public Node from;
  public Node[] subNodes;

  public int count;

  this(int id) {
    this.id = id;
  }
}

class Nodes {
  public int origin;
  public Node[int] nodes;

  this(int size, int origin = 1) {
    this.origin = origin;
    size.iota.each!((i) {
      auto id = origin + i;
      this.nodes[id] = new Node(id);
    });
  }

  void setPath(int from, int to) {
    this.nodes[from].subNodes ~= this.nodes[to];
    this.nodes[to].from = this.nodes[from];
  }

  Node root() {
    return this.nodes[origin];
  }

  void apply(int id, void delegate(Node) d) {
    d(this.nodes[id]);
  }

  void applyAllFromRoot(void delegate(Node) d) {
    auto cursors = [this.root()];
    while(!cursors.empty) {
      foreach(node; cursors) d(node);
      cursors = cursors.map!(node => node.subNodes).joiner.filter!(node => node !is null).array;
    }
  }
}

void main() {
  int N, Q; readf("%d %d\n", &N, &Q);

  auto nodes = new Nodes(N);
  foreach(fromTo; (N-1).iota.map!(i => readln.split.to!(int[])))
    nodes.setPath(fromTo[0], fromTo[1]);
  
  foreach(counter; Q.iota.map!(i => readln.split.to!(int[])))
    nodes.apply(counter[0], (node){ node.count += counter[1]; });

  int[] totals = new int[N+1];
  nodes.applyAllFromRoot((node) {
    totals[node.id] += node.count;
    if (node.from) totals[node.id] += totals[node.from.id];
  });

  totals.popFront();
  totals.to!(string[]).join(" ").writeln;
}
