#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n, q;
  cin >> n >> q;
  ll am = 0;
  vector<ll> parent(n, -1);
  vector<ll> cnts(n, 0);
  vector<pair<ll, ll>> depth(n);
  depth[0] = {0, 0};
  for (int i = 0; i < n; i++) {
    ll a, b;
    cin >> a >> b;
    parent[b - 1] = a - 1;
    parent[a - 1] = b - 1;
    depth[b - 1] = {(depth[a - 1].first + 1LL), b - 1};
  }
  for (ll i = 0; i < q; i++) {
    ll a, b;
    cin >> a >> b;
    cnts[a - 1] += b;
  }
  sort(depth.begin(), depth.end());
  for (ll i = 1; i < n; i++) {
    cnts[depth[i].second] += cnts[parent[i]];
  }
  for (int i = 0; i < n; i++) {
    cout << cnts[i] << endl;
  }
}
