#include <bits/stdc++.h>
using namespace std;
void to_pray() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cerr << "Ready\n";
}
const int N = 4e6 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const long long LLINF = 1e12 + 7;
const long long P = 53;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);
int a[N], sum[N];
vector<int> g[N];
void dfs(int v, int cur, int pr) {
  a[v] = cur + sum[v];
  for (auto to : g[v]) {
    if (to == pr) continue;
    dfs(to, cur + sum[v], v);
  }
  cur -= sum[v];
}
int main() {
  to_pray();
  int n, q;
  cin >> n >> q;
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    g[x].emplace_back(y);
    g[y].emplace_back(x);
  }
  while (q--) {
    int x, y;
    cin >> x >> y;
    sum[x] += y;
  }
  dfs(1, 0, -1);
  for (int i = 1; i <= n; ++i) cout << a[i] << " ";
  cout << '\n';
  return 0;
}
