#include <bits/stdc++.h>
using namespace std;
vector<int> v[200005];
int n, q, val[200005];
vector<int> sons[200005];
inline void dfs(int x, int par) {
  for (int it : v[x]) {
    if (it != par) {
      sons[x].push_back(it);
      dfs(it, x);
    }
  }
}
inline void gt(int x, int y) { val[x] += y; }
inline void push(int x, int ad) {
  val[x] += ad;
  for (int it : sons[x]) push(it, val[x]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> q;
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(1, 0);
  for (; q--;) {
    int x, y;
    cin >> x >> y;
    gt(x, y);
  }
  push(1, 0);
  for (int i = 1; i <= n; ++i) cout << val[i] << ' ';
  cout << endl;
}
