stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <vector>

#include <iostream>

using namespace std;

vector<int> graph[200010];

vector<int> ans(200010, 0);



void dfs(int v, int p=-1) {

  for(int u: graph[v]) {

    if(u == p) continue;

    else ans[u] += ans[v];

    dfs(u, v);

  }

}



int main() {

  int N, Q; cin >> N >> Q;

  for(int i = 0; i < N-1; ++i) {

    int a, b; cin >> a >> b; a--, b--;

    graph[a].push_back(b);

    graph[b].push_back(a);

  }



  for(int i = 0; i < Q; i++) {

    int p, x; cin >> p >> x; p--;

    ans[p] += x;

  }



  dfs(0);



  for(int i = 0; i < N; i++) {

    cout << ans[i];

    if(i != N-1) cout << " ";

    else cout << endl;

  }

  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 7.368567960496757x):
#include <iostream>

#include <iomanip>

#include <algorithm>

#include <vector>

#include <queue>

#include <cmath>

#include <map>

#include <set>

#include <deque>

#define rep(i, n) for(int i = 0; i < (n); i++)

using namespace std;

typedef long long ll;

const int mod = 1e9+7;

const int inf = 1<<30;

typedef pair<int, int> P;

vector<vector<int>> to;

vector<int> ans;



void dfs(int v, int p = -1) {

  for(int u: to[v]) {

    if(u == p) continue;

    ans[u] += ans[v];

    dfs(u, v);

  }

}



int main() {

  int N, Q; cin >> N >> Q;

  to.resize(N);

  rep(i, N-1) {

    int a, b; cin >> a >> b; a--, b--;

    to[a].push_back(b);

    to[b].push_back(a);

  }



  ans.resize(N);



  rep(i, Q) {

    int p, x; cin >> p >> x;

    p--;

    ans[p] += x;

  }



  dfs(0);



  rep(i, N) {

    if(i) cout << " ";

    cout << ans[i];

  }

  cout << endl;



  return 0;

}
// Slower C++ solution:
#include <iostream>

#include <iomanip>

#include <algorithm>

#include <vector>

#include <queue>

#include <cmath>

#include <map>

#include <set>

#include <deque>

#define rep(i, n) for(int i = 0; i < (n); i++)

using namespace std;

typedef long long ll;



vector<int> to[200010];

vector<int> ans;



void dfs(int v, int p=-1) {

  for(int u: to[v]) {

    if(u == p) continue;

    ans[u] += ans[v];

    dfs(u, v);

  }

}



int main() {

  int n, q; cin >> n >> q;

  rep(i, n-1) {

    int a, b; cin >> a >> b;

    --a, --b;

    to[a].push_back(b);

    to[b].push_back(a);

  }

  ans.resize(n);

  rep(i, q) {

    int p, x; cin >> p >> x;

    p--;

    ans[p] += x;

  }



  dfs(0);



  rep(i, n) {

    if(i) cout << " ";

    cout << ans[i];

  }

  cout << endl;



  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 6.443031846586367x):
#include <iostream>

#include <iomanip>

#include <algorithm>

#include <vector>

#include <queue>

#include <cmath>

#include <map>

#include <set>

#include <deque>

#define rep(i, n) for(int i = 0; i < (n); i++)

using namespace std;

typedef long long ll;

const int mod = 1e9+7;

const int inf = 1<<30;

typedef pair<int, int> P;

vector<vector<int>> to;

vector<int> ans;



void dfs(int v, int p = -1) {

  for(int u: to[v]) {

    if(u == p) continue;

    ans[u] += ans[v];

    dfs(u, v);

  }

}



int main() {

  int N, Q; cin >> N >> Q;

  to.resize(N);

  rep(i, N-1) {

    int a, b; cin >> a >> b; a--, b--;

    to[a].push_back(b);

    to[b].push_back(a);

  }



  ans.resize(N);



  rep(i, Q) {

    int p, x; cin >> p >> x;

    p--;

    ans[p] += x;

  }



  dfs(0);



  rep(i, N) {

    if(i) cout << " ";

    cout << ans[i];

  }

  cout << endl;



  return 0;

}
// Slower C++ solution:
#include <cstdio>

#include <stack>

#include <vector>

using namespace std;



using i64 = long long;



#define REP(i, stop) for (register int i = 1; i <= stop; ++i)



const int is = 1 << 17;

char ib[is], *ip = ib + is, it;

inline char getc() {

	if (ip == ib + is) { fread_unlocked(ib, 1, is, stdin); ip = ib; }

	return *ip++;

}

inline int read() {

	int r = 0;

	if (ip + 16 > ib + is) while ((it = getc()) & 16) r = r * 10 + it - '0';

	else while ((it = *ip++) & 16) r = r * 10 + it - '0';

	return r;

}



const int os = 1 << 17;

char ob[os], *op = ob, ot;

inline void putc(const char c) {

	*op++ = c;

	if (op == ob + os) { fwrite_unlocked(ob, 1, os, stdout); op = ob; }

}

// x shoud be greater than or equal to zero

inline void write(int x) {

	char d[6];

	int i = 0;

	while (true) {

		d[i] = x % 10 + 48;

		x /= 10;

		++i;

		if (x <= 0) break;

	}

	while (i--) {

		putc(d[i]);

	}

	putc(' ');

}



i64 cnt[200001];

bool used[200001];

vector<vector<i64>> G(200001);

void dfs(i64 a) {

  used[a] = true;

  for (i64 b : G[a]) {

    if (!used[b]) {

      cnt[b] += cnt[a];

      dfs(b);

    }

  }

}

signed main() {

  i64 N = read(), Q = read();

  REP(_, N - 1) {

    i64 a = read(), b = read();

    G[a].push_back(b);

    G[b].push_back(a);

  }

  REP(_, Q) {

    i64 p = read(), x = read();

    cnt[p] += x;

  }

  dfs(1);

  REP(i, N) {

    printf("%d ", cnt[i]);

//    write(cnt[i]);

  }

//  fwrite_unlocked(ob, 1, op - ob, stdout);

}


// Faster C++ solution for the same problem (measured speedup: 6.957111394424093x):
#include <cstdio>

#include <stack>

#include <vector>

using namespace std;



using i64 = long long;



#define REP(i, stop) for (register int i = 1; i <= stop; ++i)



const int is = 1 << 17;

char ib[is], *ip = ib + is, it;

inline char getc() {

	if (ip == ib + is) { fread_unlocked(ib, 1, is, stdin); ip = ib; }

	return *ip++;

}

inline int read() {

	int r = 0;

	if (ip + 16 > ib + is) while ((it = getc()) & 16) r = r * 10 + it - '0';

	else while ((it = *ip++) & 16) r = r * 10 + it - '0';

	return r;

}



const int os = 1 << 17;

char ob[os], *op = ob, ot;

inline void putc(const char c) {

	*op++ = c;

	if (op == ob + os) { fwrite_unlocked(ob, 1, os, stdout); op = ob; }

}

// x shoud be greater than or equal to zero

inline void write(i64 x) {

	char d[20];

	int i = 0;

	while (true) {

		d[i] = x % 10 + 48;

		x /= 10;

		++i;

		if (x <= 0) break;

	}

	while (i--) {

		putc(d[i]);

	}

	putc(' ');

}



i64 cnt[200001];

bool used[200001];

signed main() {

  i64 N = read(), Q = read();

  vector<vector<i64>> G(N + 1);

  REP(_, N - 1) {

    i64 a = read(), b = read();

    G[a].push_back(b);

    G[b].push_back(a);

  }

  REP(_, Q) {

    i64 p = read(), x = read();

    cnt[p] += x;

  }

  stack<i64> st;

  st.push(1);

  while (st.size()) {

    i64 a = st.top();

    st.pop();

    used[a] = true;

    for (i64 b : G[a]) {

      if (!used[b]) {

        cnt[b] += cnt[a];

        st.push(b);

      }

    }

  }

  REP(i, N) {

//    printf("%d ", cnt[i]);

    write(cnt[i]);

  }

  fwrite_unlocked(ob, 1, op - ob, stdout);

}
// Slower C++ solution:
#include <cstdio>

#include <stack>

#include <vector>

using namespace std;



using i64 = long long;



#define REP(i, stop) for (register int i = 1; i <= stop; ++i)



const int is = 1 << 17;

char ib[is], *ip = ib + is, it;

inline char getc() {

	if (ip == ib + is) { fread_unlocked(ib, 1, is, stdin); ip = ib; }

	return *ip++;

}

inline int read() {

	int r = 0;

	if (ip + 16 > ib + is) while ((it = getc()) & 16) r = r * 10 + it - '0';

	else while ((it = *ip++) & 16) r = r * 10 + it - '0';

	return r;

}



const int os = 1 << 17;

char ob[os], *op = ob, ot;

inline void putc(const char c) {

	*op++ = c;

	if (op == ob + os) { fwrite_unlocked(ob, 1, os, stdout); op = ob; }

}

// x shoud be greater than or equal to zero

inline void write(int x) {

	char d[6];

	int i = 0;

	while (true) {

		d[i] = x % 10 + 48;

		x /= 10;

		++i;

		if (x <= 0) break;

	}

	while (i--) {

		putc(d[i]);

	}

	putc(' ');

}



i64 cnt[200001];

bool used[200001];

vector<vector<i64>> G(200001);

void dfs(i64 a) {

  used[a] = true;

  for (i64 b : G[a]) {

    if (!used[b]) {

      cnt[b] += cnt[a];

      dfs(b);

    }

  }

}

signed main() {

  i64 N = read(), Q = read();

  REP(_, N - 1) {

    i64 a = read(), b = read();

    G[a].push_back(b);

    G[b].push_back(a);

  }

  REP(_, Q) {

    i64 p = read(), x = read();

    cnt[p] += x;

  }

  dfs(1);

  REP(i, N) {

    printf("%d ", cnt[i]);

//    write(cnt[i]);

  }

//  fwrite_unlocked(ob, 1, op - ob, stdout);

}


// Faster C++ solution for the same problem (measured speedup: 7.022903035749303x):
#include <cstdio>

#include <stack>

#include <vector>

using namespace std;



using i64 = long long;



#define REP(i, stop) for (register int i = 1; i <= stop; ++i)



const int is = 1 << 17;

char ib[is], *ip = ib + is, it;

inline char getc() {

	if (ip == ib + is) { fread_unlocked(ib, 1, is, stdin); ip = ib; }

	return *ip++;

}

inline int read() {

	int r = 0;

	if (ip + 16 > ib + is) while ((it = getc()) & 16) r = r * 10 + it - '0';

	else while ((it = *ip++) & 16) r = r * 10 + it - '0';

	return r;

}



const int os = 1 << 17;

char ob[os], *op = ob, ot;

inline void putc(const char c) {

	*op++ = c;

	if (op == ob + os) { fwrite_unlocked(ob, 1, os, stdout); op = ob; }

}

// x shoud be greater than or equal to zero

inline void write(i64 x) {

	char d[20];

	int i = 0;

	while (true) {

		d[i] = x % 10 + 48;

		x /= 10;

		++i;

		if (x <= 0) break;

	}

	while (i--) {

		putc(d[i]);

	}

	putc(' ');

}



i64 cnt[200001];

bool used[200001];

i64 st[200001], *tp;

signed main() {

  i64 N = read(), Q = read();

  vector<vector<i64>> G(N + 1);

  REP(_, N - 1) {

    i64 a = read(), b = read();

    G[a].push_back(b);

    if (a != 1) G[b].push_back(a);

  }

  REP(_, Q) {

    i64 p = read(), x = read();

    cnt[p] += x;

  }

  tp = st;

  ++tp;

  *tp = 1;

  while (*tp) {

    i64 a = *tp;

    --tp;

    used[a] = true;

    for (i64 b : G[a]) {

      if (!used[b]) {

        cnt[b] += cnt[a];

        ++tp;

        *tp = b;

      }

    }

  }

  REP(i, N) {

    write(cnt[i]);

  }

  fwrite_unlocked(ob, 1, op - ob, stdout);

}
// Slower C++ solution:
#include <cstdio>

#include <stack>

#include <vector>

using namespace std;



using i64 = long long;



#define REP(i, stop) for (register int i = 1; i <= stop; ++i)



const int is = 1 << 17;

char ib[is], *ip = ib + is, it;

inline char getc() {

	if (ip == ib + is) { fread_unlocked(ib, 1, is, stdin); ip = ib; }

	return *ip++;

}

inline int read() {

	int r = 0;

	if (ip + 16 > ib + is) while ((it = getc()) & 16) r = r * 10 + it - '0';

	else while ((it = *ip++) & 16) r = r * 10 + it - '0';

	return r;

}



const int os = 1 << 17;

char ob[os], *op = ob, ot;

inline void putc(const char c) {

	*op++ = c;

	if (op == ob + os) { fwrite_unlocked(ob, 1, os, stdout); op = ob; }

}

// x shoud be greater than or equal to zero

inline void write(int x) {

	char d[6];

	int i = 0;

	while (true) {

		d[i] = x % 10 + 48;

		x /= 10;

		++i;

		if (x <= 0) break;

	}

	while (i--) {

		putc(d[i]);

	}

	putc(' ');

}



i64 cnt[200001];

bool used[200001];

vector<vector<i64>> G(200001);

void dfs(i64 a) {

  used[a] = true;

  for (i64 b : G[a]) {

    if (!used[b]) {

      cnt[b] += cnt[a];

      dfs(b);

    }

  }

}

signed main() {

  i64 N = read(), Q = read();

  REP(_, N - 1) {

    i64 a = read(), b = read();

    G[a].push_back(b);

    G[b].push_back(a);

  }

  REP(_, Q) {

    i64 p = read(), x = read();

    cnt[p] += x;

  }

  dfs(1);

  REP(i, N) {

    printf("%d ", cnt[i]);

//    write(cnt[i]);

  }

//  fwrite_unlocked(ob, 1, op - ob, stdout);

}


// Faster C++ solution for the same problem (measured speedup: 7.022046809102306x):
#include <cstdio>

#include <stack>

#include <vector>

using namespace std;



using i64 = long long;



#define REP(i, stop) for (register int i = 1; i <= stop; ++i)



const int is = 1 << 17;

char ib[is], *ip = ib + is, it;

inline char getc() {

	if (ip == ib + is) { fread_unlocked(ib, 1, is, stdin); ip = ib; }

	return *ip++;

}

inline int read() {

	int r = 0;

	if (ip + 16 > ib + is) while ((it = getc()) & 16) r = r * 10 + it - '0';

	else while ((it = *ip++) & 16) r = r * 10 + it - '0';

	return r;

}



const int os = 1 << 22;

char ob[os], *op = ob, ot;

inline void putc(const char c) {

	*op++ = c;

//	if (op == ob + os) { fwrite_unlocked(ob, 1, os, stdout); op = ob; }

}

// x shoud be greater than or equal to zero

inline void write(i64 x) {

	char d[20];

	int i = 0;

	while (true) {

		d[i] = x % 10 + 48;

		x /= 10;

		++i;

		if (x <= 0) break;

	}

	while (i--) {

		putc(d[i]);

	}

	putc(' ');

}



i64 cnt[200001];

bool used[200001];

i64 st[200001], *tp;

signed main() {

  i64 N = read(), Q = read();

  vector<vector<i64>> G(N + 1);

  REP(_, N - 1) {

    i64 a = read(), b = read();

    G[a].push_back(b);

    G[b].push_back(a);

  }

  REP(_, Q) {

    i64 p = read(), x = read();

    cnt[p] += x;

  }

  tp = st;

  ++tp;

  *tp = 1;

  while (*tp) {

    i64 a = *tp;

    --tp;

    used[a] = true;

    for (i64 b : G[a]) {

      if (!used[b]) {

        cnt[b] += cnt[a];

        ++tp;

        *tp = b;

      }

    }

  }

  REP(i, N) {

    write(cnt[i]);

  }

  fwrite_unlocked(ob, 1, op - ob, stdout);

}
// Slower C++ solution:
#include <iostream>

#include <vector>

using namespace std;

vector<int> v[200000];

int cnt[200000];

void cal(int x, int y){

    for(int i=0;i<v[x].size();i++){

        int z = v[x][i];

        if(z != y){

            cnt[z] += cnt[x];

            cal(z, x);

        }

    }

}

int main(void){

    int n, q;

    cin >> n >> q;

    for(int i=0;i<n-1;i++){

        int a, b;

        cin >> a >> b;

        a--;

        b--;

        v[a].push_back(b);

        v[b].push_back(a);

    }

    fill(cnt, cnt+n, 0);

    for(int i=0;i<q;i++){

        int p, x;

        cin >> p >> x;

        cnt[--p] += x;

    }

    cal(0, -1);

    for(int i=0;i<n;i++){

        cout << cnt[i] << " ";

    }

    cout << endl;

}


// Faster C++ solution for the same problem (measured speedup: 6.391773552053872x):
#include <iostream>

#include <vector>

using namespace std;

int n, k;

vector< vector<int> > edg;

vector<int> cnt;

void cal(int v, int c, int p){

    cnt[v] += c;

    for(int i=0;i<edg[v].size();i++){

        int w = edg[v][i];

        if(w == p)continue;

        cal(w, cnt[v], v);

    }

}

int main(void){

    cin >> n >> k;

    edg.assign(n, vector<int>());

    cnt.assign(n, 0);

    for(int i=0;i<n-1;i++){

        int a, b;

        cin >> a >> b;

        a--;

        b--;

        edg[a].push_back(b);

        edg[b].push_back(a);

    }

    for(int i=0;i<k;i++){

        int p, x;

        cin >> p >> x;

        cnt[--p] += x;

    }

    cal(0, 0, -1);

    for(int i=0;i<n;i++){

        cout << cnt[i] << " ";

        

    }

    cout << endl;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define pb push_back

#define mp make_pair

#define Would

#define you

#define please



int N;

int C[200001];

int X[200001];

vector<int> E[200001];

void dfs(int p, int prev, int c) {

	int k = c + X[p];

	C[p] = k;

	for (int to : E[p]) {

		if (to != prev) dfs(to, p, k);

	}

}





int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);





	int N, Q;

	cin >> N >> Q;

	rep(i, N - 1) {

		int a, b;

		cin >> a >> b;

		E[a].pb(b);

		E[b].pb(a);

	}

	rep(i, Q) {

		int p, x;

		cin >> p >> x;

		X[p] += x;

	}

	dfs(1, 0, 0);



	rep1(i, N) cosp(C[i]);



	Would you please return 0;

}

// Faster C++ solution for the same problem (measured speedup: 34.9467445243967x):
//#include<bits/stdc++.h>

#include<cstdio>



using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define pb push_back

#define mp make_pair

#define Would

#define you

#define please



//有向気味でもなぜかよさそうと解説放送で聞いたけど



int N;

int C[200001];

int E[200001];

int next[200001];

int H[200001];

void dfs(int p, int c) {

	C[p] = c + C[p];

	for (int i = H[p]; i; i = next[i]) {

		dfs(E[i], C[p]);

	}

}



const int cm = 1 << 17;

char cn[cm], * ci = cn + cm, ct;

inline char getcha() {

	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }

	return *ci++;

}

inline int getint() {

	int A = 0;

	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';

	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';

	return A;

}



const int dm = 1 << 21;

char dn[dm], * di = dn;

inline void putint(int X) {

	if (X == 0) {

		*di++ = '0';

		*di++ = ' ';

		return;

	}

	int keta = 0;

	char C[10];

	while (X) {

		*(C + keta) = '0' + X % 10;

		X /= 10;

		keta++;

	}

	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));

	*di++ = ' ';

}



int main() {

	//cin.tie(0);

	//ios::sync_with_stdio(false);





	int N = getint(), Q = getint();

	int k = 1;

	rep(i, N - 1) {

		int a = getint(), b = getint();

		E[k] = b;

		next[k] = H[a];

		H[a] = k++;

	}

	rep(i, Q) {

		int p = getint(), x = getint();

		C[p] += x;

	}

	dfs(1, 0);



	rep1(i, N) putint(C[i]);



	fwrite(dn, 1, di - dn, stdout);



	Would you please return 0;

}
// Slower C++ solution:
#include <iostream>

#include <vector>



using namespace std;

vector<int> G[200005];

int seen[200005] = {0};

int ans[200005] = {0};



void dfs(int s) {

    seen[s] = 1;

    for (int i = 0; i < G[s].size(); i++) {

        int n = G[s][i];



        if (seen[n] == 1)

            continue;



        ans[n] += ans[s];

        dfs(n);

    }

}



int main() {

    int n, q;  cin >> n >> q;



    for (int i = 0; i < n-1; i++) {

        int a, b;   cin >> a >> b;

        G[a-1].push_back(b-1);

        G[b-1].push_back(a-1);

    }



    for (int i = 0; i < q; i++) {

        int p, x;   cin >> p >> x;

        ans[p-1] += x;

    }



    dfs(0);



    for (int i = 0; i < n; i++)

        cout << ans[i] << " ";



    cout << endl;



    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 6.388761168929627x):
#include <iostream>

#include <vector>



using namespace std;



int seen[200005] = {0};

int ans[200005] = {0};



void dfs(vector<vector<int> > &G, int s) {

    seen[s] = 1;

    for (int i = 0; i < G[s].size(); i++) {

        int n = G[s][i];



        if (seen[n] == 1)

            continue;



        ans[n] += ans[s];

        dfs(G, n);

    }

}



int main() {

    int n, q;  cin >> n >> q;

    vector<vector<int> > G(n);



    for (int i = 0; i < n-1; i++) {

        int a, b;   cin >> a >> b;

        G[a-1].push_back(b-1);

        G[b-1].push_back(a-1);

    }



    for (int i = 0; i < q; i++) {

        int p, x;   cin >> p >> x;

        ans[p-1] += x;

    }



    dfs(G, 0);



    for (int i = 0; i < n; i++)

        cout << ans[i] << " ";



    cout << endl;



    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <vector>



using namespace std;

vector<int> G[200005];

int seen[200005] = {0};

int ans[200005] = {0};



void dfs(int s) {

    seen[s] = 1;

    for (int i = 0; i < G[s].size(); i++) {

        int n = G[s][i];



        if (seen[n] == 1)

            continue;



        ans[n] += ans[s];

        dfs(n);

    }

}



int main() {

    int n, q;  cin >> n >> q;



    for (int i = 0; i < n-1; i++) {

        int a, b;   cin >> a >> b;

        G[a-1].push_back(b-1);

        G[b-1].push_back(a-1);

    }



    for (int i = 0; i < q; i++) {

        int p, x;   cin >> p >> x;

        ans[p-1] += x;

    }



    dfs(0);



    for (int i = 0; i < n; i++)

        cout << ans[i] << " ";



    cout << endl;



    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 6.38562213035146x):
#include <iostream>

#include <vector>



using namespace std;



typedef long long ll;



void dfs(int s, vector<vector<int> > &G, ll *tmp, int *seen) {

    seen[s] = 1;

    for (int i = 0; i < (int)G[s].size(); i++) {

        int v = G[s][i];

        if (seen[v])

            continue;

        tmp[v] += tmp[s];

        dfs(v, G, tmp, seen);

    }

}



int main() {

    int N, Q;

    cin >> N >> Q;

    vector<vector<int> > G(N);

    for (int i = 0; i < N-1; i++) {

        int a, b;   cin >> a >> b;

        G[a-1].push_back(b-1);

        G[b-1].push_back(a-1);

    }



    ll *tmp = new ll[N];

    int *seen = new int[N];

    for (int i = 0; i < N; i++)

        tmp[i] = 0, seen[i] = 0;



    for (int i = 0; i < Q; i++) {

        int x, p;  cin >> p >> x;

        tmp[p-1] += x;

    }



    dfs(0, G, tmp, seen);



    for (int i = 0; i < N; i++)

        cout << tmp[i] << " ";

    cout << endl;



    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



long long n, q;



const long long N = 200010;

vector<long long> G[N];

vector<long long> Count(N, 0);

vector<bool> seen(N);



void dfs(long long now, long long cnt){

    seen[now] = true;

    for(long long i = 0; i < G[now].size(); i++){

        long long to = G[now][i];

        if(seen[to]) continue;

        dfs(to, cnt + Count[now]);

    }

    Count[now] += cnt;

    return;

}



int main(){

    cin.tie(nullptr);

    ios::sync_with_stdio(false);



    cin >> n >> q;

    for(long long i = 0; i < n - 1; i++){

        long long a, b;

        cin >> a >> b;

        a--; b--;

        G[a].push_back(b);

        G[b].push_back(a);

    }



    while(q--){

        long long p, x;

        cin >> p >> x;

        p--;

        Count[p] += x;

    }



    dfs(0, 0);



    for(long long i = 0; i < n; i++){

        cout << Count[i] << ' ';

    }

    cout << endl;



    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.1292710055369595x):
#include <bits/stdc++.h>

using namespace std;



const int N = 200010;

vector<int> G[N];

vector<int> Count(N);

int n, q;



void dfs(int now, int pre){

    for(int i = 0; i < G[now].size(); i++){

        int to = G[now][i];

        if(to == pre) continue;

        Count[to] += Count[now];

        dfs(to, now);

    }

}



int main(){

    cin.tie(nullptr);

    ios::sync_with_stdio(false);



    cin >> n >> q;

    

    for(int i = 0; i < n - 1; i++){

        int a, b;

        cin >> a >> b;

        a--; b--;

        G[a].push_back(b);

        G[b].push_back(a);

    }



    for(int i = 0; i < q; i++){

        int p, x;

        cin >> p >> x;

        p--;

        Count[p] += x;

    }



    dfs(0, -1);



    for(int i = 0; i < n; i++){

        cout << Count[i] << ' ';

    }

    cout << endl;



    return 0;

}