#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
vector<bool> seen;
void dfs(const Graph &G, const Graph &Q, int v, int gool, int cnt) {
  seen[v] = true;
  for (auto next_v : Q[v]) {
    cnt += next_v;
  }
  if (v == gool) {
    cout << cnt << " ";
    return;
  }
  for (auto next_v : G[v]) {
    if (seen[next_v]) continue;
    dfs(G, Q, next_v, gool, cnt);
  }
}
int main() {
  int N, M;
  cin >> N >> M;
  Graph G(N);
  Graph Q(10e+5);
  for (int i = 0; i < N - 1; ++i) {
    int a, b;
    cin >> a >> b;
    G[a - 1].push_back(b - 1);
    G[b - 1].push_back(a - 1);
  }
  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    Q[a - 1].push_back(b);
  }
  for (int i = 0; i < N; i++) {
    seen.assign(N, false);
    dfs(G, Q, 0, i, 0);
  }
}
