#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
   ll n,q1;
   cin>>n>>q1;
   vector<vector<ll>>adj(n+1);
   for(ll i=1;i<n;i++)
   {
       ll a,b;
       cin>>a>>b;
       adj[a].pb(b);
       adj[b].pb(a);
   }
   vector<ll>vv(n+1,0),v1(n+1,0);
   for(ll i=0;i<q1;i++)
   {
       ll x,y;
       cin>>x>>y;
       vv[x]+=y;
   }
   ll z=0;
   bool vis[n+1]={0};
   queue<ll>q;
   q.push(1);
   vis[1]=1;
   while(!q.empty())
   {
       ll p=q.front();
       q.pop();
       //z=vv[p];
       //v1[p]+=vv[p];
       //z+=v1[p];
       for(ll i=0;i<adj[p].size();i++)
       {
           if(!vis[adj[p][i]])
           {
               q.push(adj[p][i]);
               vv[adj[p][i]]+=vv[p];
               vis[adj[p][i]]=1;
           }
       }
   }
   for(ll i=1;i<=n;i++)
   cout<<vv[i]<<" ";

}
