#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#define N 2000005
#define F(i,a,b) for(int i=a;i<=b;++i)

using namespace std;

struct Tree{
    int deep;
    int father;
    int son;
    int tot; 
}tree[N];
struct Edge{
    int to;
    int next;
}e[N*2];
struct Segtree{
    int l;
    int r;
    int size;
    int val;
    int lazytag;
}segtree[N*4+1];
int head[N],num[N];
int top[N],new_tree[N];
int n,m,r,t;
int cnt;
int idx[N];

inline void add (int x,int y){
    e[++t].to=y;
    e[t].next=head[x];
    head[x]=t;
    return ;
}
int dfs1(int root,int father,int deep){
    tree[root].deep=deep;
    tree[root].father=father;
    tree[root].tot=1;
    int maxson=-1;
    for(int i=head[root];i;i=e[i].next){
        if(e[i].to==father) continue;
        tree[root].tot+=dfs1(e[i].to,root,deep+1);
        if(tree[e[i].to].tot>maxson) {
        	maxson=tree[e[i].to].tot;
        	tree[root].son=e[i].to;
        }
    }
    return tree[root].tot;
}
inline void dfs2(int x,int topf){
    idx[x]=++cnt;
    new_tree[cnt]=num[x];
    top[x]=topf;
    if(!tree[x].son)return;
    dfs2(tree[x].son,topf);
    for(int i=head[x];i;i=e[i].next){
        int y=e[i].to;
        if(y==tree[x].father||y==tree[x].son)continue;
        dfs2(y,y);
    }
}
inline void Build (int root,int start,int end){
    segtree[root].l=start;
    segtree[root].r=end;
    segtree[root].size=end-start+1;
    if (start==end){
        segtree[root].val=new_tree[start];
        return;
    }
    int mid=((start+end)>>1);
    Build (root*2,start,mid);
    Build (root*2+1,mid+1,end);
    segtree[root].val=segtree[root*2].val+segtree[root*2+1].val;
    return;
} 
void pushdown (int root,int start,int end){
    if (segtree[root].lazytag!=0){
        segtree[root*2].lazytag=(segtree[root*2].lazytag+segtree[root].lazytag);
        segtree[root*2+1].lazytag=(segtree[root*2+1].lazytag+segtree[root].lazytag);
        segtree[root*2].val=(segtree[root*2].val+segtree[root].lazytag*segtree[root*2].size);
        segtree[root*2+1].val=(segtree[root*2+1].val+segtree[root].lazytag*segtree[root*2+1].size);
        segtree[root].lazytag=0;
    }
    return;
}
inline void updata (int root,int nstart,int nend,int qstart,int qend,int addval){
    if (qend<nstart||qstart>nend) return;
    if (qend>=nend&&qstart<=nstart) {
        segtree[root].val+=segtree[root].size*addval;
        segtree[root].lazytag+=addval;
        return;
    }
    pushdown(root,nstart,nend);
    int mid=((nstart+nend)>>1);
    if (qstart<=mid) updata (root*2,nstart,mid,qstart,qend,addval);
    if (qend>=mid) updata (root*2+1,mid+1,nend,qstart,qend,addval);
    segtree[root].val=(segtree[root*2].val+segtree[root*2+1].val);
    return ;
}
inline int check (int root,int qstart,int qend){
    if (qend<segtree[root].l||qstart>segtree[root].r) return 0;
    if (qend>=segtree[root].r&&qstart<=segtree[root].l) return segtree[root].val;
    pushdown(root,segtree[root].l,segtree[root].r);
    return (check(root*2,qstart,qend)+check(root*2+1,qstart,qend));
}
void tree_sum(int x,int y){
    int ans=0;
    while (top[x]!=top[y]){
        if(tree[top[x]].deep<tree[top[y]].deep) swap(x,y);
        ans=(ans+check(1,idx[top[x]],idx[x]));
        x=tree[top[x]].father;
    }
    if (tree[x].deep>tree[y].deep) swap(x,y);
        ans=(ans+check(1,idx[x],idx[y]));
    printf ("%d\n",ans);
    return;
}
void tree_add(int x,int y,int addval){
    while (top[x]!=top[y]){
        if (tree[top[x]].deep<tree[top[y]].deep) swap(x,y);
        updata(1,1,n,idx[top[x]],idx[x],addval);
        x=tree[top[x]].father;
    }
    if (tree[x].deep>tree[y].deep) swap(x,y);
    updata(1,1,n,idx[x],idx[y],addval);
    return;
}

int main(){
    scanf ("%d%d",&n,&m);
    F(i,1,n-1){
        int x,y;
        scanf ("%d%d",&x,&y);
        add (x,y);
        add (y,x);
    } 
    dfs1(1,0,1);
    dfs2(1,1);
    Build (1,1,n);
    F(i,1,m){
    	int x,y;
        scanf ("%d%d",&x,&y);
        updata (1,1,n,idx[x],idx[x]+tree[x].tot-1,y);
    }
    F(i,1,n)
    	printf("%d ",check(1,idx[i],idx[i]));
    return 0;
}

Measured memory_bytes: 67200