#include<bits/stdc++.h>
#define int long long
using namespace std;
int s[222222] = {};
vector<int> e[222222];
bool used[222222] = {};
void dfs(int now){
  used[now] = true;
  for(auto&& i: e[now])
    if(!used[i])
      s[i] += s[now], dfs(i);
}
signed main(){
  int n, m, a, b;
  cin>>n>>m;
  for(int i = 0; i < n - 1; i++)
    cin>>a>>b,
    a--, b--,
    e[a].push_back(b),
    e[b].push_back(a);
  while(m--)
    cin>>a>>b,
    a--,
    s[a] += b;
  dfs(0);
  cout<<s[0];
  for(int i = 1; i < n; i++)
    cout<<' '<<s[i];
  cout<<endl;
}
