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

    #include<stdio.h>

    //#include <bits/stdc++.h>

    #include<vector>

    #include<float.h>

    #include<iomanip>

    #include<algorithm>

    #include<string>

    #include<cstring>

    #include<math.h>

    #include<cmath>

    #include<sstream>

    #include<set>

    #include<map>

    #include<queue>

    #include <cassert>

    #include <cmath>



    #define INF 1e9

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

    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)

    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;

    #define vec(type,n) vector<type>(n)

    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))



    using namespace std;

    using ll = long long;

    using Graph = vector<vector<int>>;

    using P = pair<int,int>;





    vector<int> ans;

    vector<int> to[200005];

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

        for(auto nv : to[v]){

            if(nv == p)continue;

            ans[nv] += ans[v];

            dfs(nv,v);

        }

    }

    

    int main(){

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

        ans.resize(n);

        rep(i,n-1){

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

            a--;b--;

            to[a].push_back(b);

            to[b].push_back(a);

        }

        rep(i,q){

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

            p--;

            ans[p] += x;

        }

        //rep(i,n)c[i] = mp[0];

        dfs(0);

        rep(i,n)cout<<ans[i]<<" ";

    }

    


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

#include<stdio.h>

//#include <bits/stdc++.h>

#include<vector>

#include<float.h>

#include<iomanip>

#include<algorithm>

#include<string>

#include<cstring>

#include<math.h>

#include<cmath>

#include<sstream>

#include<set>

#include<map>

#include<queue>

#include <cassert>

#include <cmath>

#include<cstdint>



#define INF 1e9

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

#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)

#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;

#define vec(type,n) vector<type>(n)

#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

#define ALL(a)  (a).begin(),(a).end()



using namespace std;

using ll = long long;

using Graph = vector<vector<int>>;

using P = pair<int,int>;



int n,q;

vector<bool>seen(n);

void dfs(const Graph &G,int v,vector<int>&cnt,int p = -1){

    seen[v] = true;

    for(auto nv : G[v]){

        if(nv==p)continue;

        if(seen[nv])continue;

        cnt[nv] += cnt[v];

        dfs(G,nv,cnt,v);

    }

}



int main(){

    cin>>n>>q;

    Graph G(n);

    rep(i,n-1){

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

        a--;b--;

        G[a].push_back(b);

        G[b].push_back(a);

    }

    vector<int>cnt(n,0);

    rep(i,q){

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

        p--;

        cnt[p] += x;

    }

    seen.assign(n,false);

    dfs(G,0,cnt);

  rep(i,n)cout<<cnt[i]<<" ";

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

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

using namespace std;



using ll = long long;



bool done[200000];

int cnt[200000];

vector<int> edge[200000];



void dfs(int v) {

    done[v] = true;

    rep(i, edge[v].size()) {

        int j = edge[v][i];

        if (done[j]) continue;

        cnt[j] += cnt[v];

        dfs(j);

    }

    return;

}



int main() {

    rep(i, 200000) done[i] = false;

    rep(i, 200000) cnt[i] = 0;

    int N, Q, a, b, p, x;

    cin >> N >> Q;

    rep(i, N - 1) {

        cin >> a >> b;

        a--;

        b--;

        edge[a].push_back(b);

        edge[b].push_back(a);

    }

    rep(i, Q) {

        cin >> p >> x;

        cnt[p - 1] += x;

    }

    dfs(0);

    rep(i, N) cout << cnt[i] << " ";

    cout << endl;

}

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

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

using namespace std;

 

typedef long long ll;



int main() {

    int N, Q, a, b, p, x;

    cin >> N >> Q;

    vector<vector<int>> edge(N, vector<int>(0));

    rep(i, N - 1) {

        cin >> a >> b;

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

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

    }

    vector<int> px(N, 0), ans(N, 0);

    rep(i, Q) {

        cin >> p >> x;

        px[p - 1] += x;

    }

    queue<pair<int, int>> q;

    q.push(make_pair(0, px[0]));

    vector<bool> done(N, false);

    while (q.size() > 0) {

        auto c = q.front();

        q.pop();

        ans[c.first] = c.second;

        done[c.first] = true;

        rep(i, edge[c.first].size()) {

            int d = edge[c.first][i];

            if (done[d]) continue;

            q.push(make_pair(d, c.second + px[d]));

        }

    }

    rep(i, N) {

        cout << ans[i];

        if (i == N - 1) cout << endl;

        else cout << " ";

    }

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

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

using namespace std;

typedef long long ll;



vector<int> to[200005];

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 != n-1) cout << ans[i] << " ";

        else cout << ans[i] << endl;

    }

    return 0;

}

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

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

using namespace std;

typedef long long ll;



vector<vector<int>> graph;

vector<int> values;



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

    for (int v : graph[x]) {

        if (v == p) continue;

        values[v] += values[x];

        dfs(v,x);

    }

}



int main() {

    int n, q;

    cin >> n >> q;

    graph.resize(n);

    values.resize(n);

    rep(i,n-1) {

        int a, b;

        cin >> a >> b;

        --a; --b;

        graph[a].push_back(b);

        graph[b].push_back(a);

    }

    rep(i,q) {

        int p, x;

        cin >> p >> x;

        --p;

        values[p] += x;

    }

    dfs(0);

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

        if (i != n-1) printf("%d ", values[i]);

        else printf("%d\n",values[i]);

    }

    return 0;

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

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

using namespace std;

typedef long long ll;



vector<int> to[200005];

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 != n-1) printf("%d ", ans[i]);

        else printf("%d\n", ans[i]);

    }

    return 0;

}

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

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

using namespace std;

typedef long long ll;



vector<vector<int>> graph;

vector<int> values;



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

    for (int v : graph[x]) {

        if (v == p) continue;

        values[v] += values[x];

        dfs(v,x);

    }

}



int main() {

    int n, q;

    cin >> n >> q;

    graph.resize(n);

    values.resize(n);

    rep(i,n-1) {

        int a, b;

        cin >> a >> b;

        --a; --b;

        graph[a].push_back(b);

        graph[b].push_back(a);

    }

    rep(i,q) {

        int p, x;

        cin >> p >> x;

        --p;

        values[p] += x;

    }

    dfs(0);

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

        if (i != n-1) printf("%d ", values[i]);

        else printf("%d\n",values[i]);

    }

    return 0;

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

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

using namespace std;

typedef long long ll;



vector<int> to[200005];

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 != n-1) cout << ans[i] << " ";

        else cout << ans[i] << endl;

    }

    return 0;

}

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

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

using namespace std;

typedef long long ll;



vector<vector<int>> to;

vector<int> ans;

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

    for (int u : to[x]) {

        if (u == p) continue;

        ans[u] += ans[x];

        dfs(u,x);

    }

}



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 != n-1) cout << ans[i] << " ";

        else cout << ans[i] << endl;

    }

    return 0;

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

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

using namespace std;

typedef long long ll;



vector<int> to[200005];

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 != n-1) printf("%d ", ans[i]);

        else printf("%d\n", ans[i]);

    }

    return 0;

}

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

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

using namespace std;

typedef long long ll;



vector<vector<int>> to;

vector<int> ans;

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

    for (int u : to[x]) {

        if (u == p) continue;

        ans[u] += ans[x];

        dfs(u,x);

    }

}



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 != n-1) cout << ans[i] << " ";

        else cout << ans[i] << endl;

    }

    return 0;

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

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

using namespace std;

typedef long long ll;



vector<int> to[200005];

vector<int> ans;

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

    for (int u : to[x]) {

        if (u == p) continue;

        ans[u] += ans[x];

        dfs(u,x);

    }

}



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 != n-1) cout << ans[i] << " ";

        else cout << ans[i] << endl;

    }

    return 0;

}

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

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

using namespace std;

typedef long long ll;



vector<vector<int>> to;

vector<int> ans;

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

    for (int u : to[x]) {

        if (u == p) continue;

        ans[u] += ans[x];

        dfs(u,x);

    }

}



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 != n-1) cout << ans[i] << " ";

        else cout << ans[i] << endl;

    }

    return 0;

}
// Slower C++ solution:
/*

    Problem 26

    https://atcoder.jp/contests/abc138/tasks/abc138_d

*/

#include <iostream>

#include <cstdio>

#include <vector>

#include <algorithm>

#include <map>

#include <numeric>

#include <string>

#include <cmath>

#include <iomanip>

#include <queue>

#include <list>

#include <set>

#include <stack>

#include <cctype>

#include <cmath>

#include <bitset>



using namespace std;

/* typedef */

typedef long long ll;

/* constant */

const int MAX = (2e+5) + 1;

/* global variables */

vector< vector<int> > G(MAX, vector<int>());

vector<int> visited(MAX), counter(MAX);

/* function */

void dfs() {

    stack<int> S;

    S.push(0);

    visited[0] = 1;

    while (!S.empty()) {

        int v = S.top();

        S.pop();

        for (int u : G[v]) {

            if (visited[u]) continue;

            visited[u] = 1;

            counter[u] += counter[v];

            S.push(u);

        }

    }

}

/* main */

int main(){

    int N, Q, a, b, p, x;

    cin >> N >> Q;

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

        cin >> a >> b;

        a--; b--;

        G[a].push_back(b);

        G[b].push_back(a);

    }

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

        cin >> p >> x;

        p--;

        counter[p] += x;

    }

    dfs();

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

        if (i) cout << ' ';

        cout << counter[i];

    }

    cout << '\n';

}

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

using namespace std;

/* typedef */

typedef long long ll;

typedef pair<int, int> pii;

/* constant */

const int INF = 1 << 30;

const int MAX = 200005;

/* global variables */

vector<vector<int> > G(MAX, vector<int>());

vector<int> counter;

int N;

/* function */

void bfs() {

    vector<int> visited(N, 0);

    queue<int> q;

    q.push(0);

    visited[0] = 1;

    while (!q.empty()) {

        int from = q.front(); q.pop();

        for (int to : G[from]) {

            if (visited[to]) continue;

            counter[to] += counter[from];

            visited[to] = 1;

            q.push(to);

        }

    }

}



/* main */

int main(){

    int Q, a, b, p, x;

    cin >> N >> Q;

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

        cin >> a >> b;

        a--; b--;

        G[a].push_back(b);

        G[b].push_back(a);

    }

    counter.assign(N, 0);

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

        cin >> p >> x;

        p--;

        counter[p] += x;

    }

    bfs();

    for (int c : counter) cout << c << ' ';

    cout << '\n';

}
// Slower C++ solution:
/*

    Problem 26

    https://atcoder.jp/contests/abc138/tasks/abc138_d

*/

#include <iostream>

#include <cstdio>

#include <vector>

#include <algorithm>

#include <map>

#include <numeric>

#include <string>

#include <cmath>

#include <iomanip>

#include <queue>

#include <list>

#include <set>

#include <stack>

#include <cctype>

#include <cmath>

#include <bitset>



using namespace std;

/* typedef */

typedef long long ll;

/* constant */

const int MAX = (2e+5) + 1;

/* global variables */

vector< vector<int> > G(MAX, vector<int>());

vector<int> visited(MAX), counter(MAX);

/* function */

void dfs() {

    stack<int> S;

    S.push(0);

    visited[0] = 1;

    while (!S.empty()) {

        int v = S.top();

        S.pop();

        for (int u : G[v]) {

            if (visited[u]) continue;

            visited[u] = 1;

            counter[u] += counter[v];

            S.push(u);

        }

    }

}

/* main */

int main(){

    int N, Q, a, b, p, x;

    cin >> N >> Q;

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

        cin >> a >> b;

        a--; b--;

        G[a].push_back(b);

        G[b].push_back(a);

    }

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

        cin >> p >> x;

        p--;

        counter[p] += x;

    }

    dfs();

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

        if (i) cout << ' ';

        cout << counter[i];

    }

    cout << '\n';

}

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

using namespace std;

/* typedef */

typedef long long ll;

typedef pair<int, int> pii;

/* constant */

const int INF = 1 << 30;

const int MAX = 200005;

/* global variables */

vector<vector<int> > G(MAX, vector<int>());

vector<int> counter;

int N;

/* function */

void bfs() {

    vector<int> visited(N, 0);

    stack<int> q;

    q.push(0);

    visited[0] = 1;

    while (!q.empty()) {

        int from = q.top(); q.pop();

        for (int to : G[from]) {

            if (visited[to]) continue;

            counter[to] += counter[from];

            visited[to] = 1;

            q.push(to);

        }

    }

}



/* main */

int main(){

    int Q, a, b, p, x;

    cin >> N >> Q;

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

        cin >> a >> b;

        a--; b--;

        G[a].push_back(b);

        G[b].push_back(a);

    }

    counter.assign(N, 0);

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

        cin >> p >> x;

        p--;

        counter[p] += x;

    }

    bfs();

    for (int c : counter) cout << c << ' ';

    cout << '\n';

}
// Slower C++ solution:
/*

    Problem 26

    https://atcoder.jp/contests/abc138/tasks/abc138_d

*/

#include <iostream>

#include <cstdio>

#include <vector>

#include <algorithm>

#include <map>

#include <numeric>

#include <string>

#include <cmath>

#include <iomanip>

#include <queue>

#include <list>

#include <set>

#include <stack>

#include <cctype>

#include <cmath>

#include <bitset>



using namespace std;

/* typedef */

typedef long long ll;

/* constant */

const int MAX = (2e+5) + 1;

/* global variables */

vector< vector<int> > G(MAX, vector<int>());

vector<int> visited(MAX), counter(MAX);

/* function */

void dfs() {

    stack<int> S;

    S.push(0);

    visited[0] = 1;

    while (!S.empty()) {

        int v = S.top();

        S.pop();

        for (int u : G[v]) {

            if (visited[u]) continue;

            visited[u] = 1;

            counter[u] += counter[v];

            S.push(u);

        }

    }

}

/* main */

int main(){

    int N, Q, a, b, p, x;

    cin >> N >> Q;

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

        cin >> a >> b;

        a--; b--;

        G[a].push_back(b);

        G[b].push_back(a);

    }

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

        cin >> p >> x;

        p--;

        counter[p] += x;

    }

    dfs();

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

        if (i) cout << ' ';

        cout << counter[i];

    }

    cout << '\n';

}

// Faster C++ solution for the same problem (measured speedup: 1.1219595848725126x):
/*

    Problem 26

    https://atcoder.jp/contests/abc138/tasks/abc138_d

*/

#include <bits/stdc++.h>

using namespace std;

/* typedef */

typedef long long ll;

typedef pair<int, int> pii;

/* constant */

const int INF = 1 << 30;

const ll LINF = 1LL << 50;

const int NIL = -1;

const int MAX = 200005;

const int mod = 1000000007;

const double pi = 3.141592653589;

/* global variables */

vector<vector<int>> G(MAX, vector<int>());

vector<bool> visited(MAX);

vector<int> counter(MAX, 0);

/* function */

void bfs(int st) {

    queue<int> q;

    q.push(st);

    visited[st] = true;

    while (!q.empty()) {

        int from = q.front();

        q.pop();

        for (int to : G[from]) {

            if (visited[to]) continue;

            visited[to] = true;

            counter[to] += counter[from];

            q.push(to);

        }

    }

}

/* main */

int main(){

    int N, Q;

    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 a, c;

        cin >> a >> c;

        a--;

        counter[a] += c;

    }

    bfs(0);



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

        cout << counter[i] << (i == N-1 ? '\n' : ' ');

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



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

#define repr(i, n) for (int i = (n)-1; i >= 0; i--)

using namespace std;

typedef long long ll;



const int N = 2 * 1e5 + 5;

int n, q, a, b;

vector<int> r[N], ans(N);



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

  for (int u : r[v]) {

    if (u == p) continue;

    ans[u] += ans[v];

    dfs(u, v);

  }

  return;

}



int main() {

  cin >> n >> q;

  int p, x;

  rep(i, n - 1) cin >> a >> b, a--, b--, r[a].push_back(b), r[b].push_back(a);

  rep(i, q) {

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

    ans[p] += x;

  }

  dfs(0);



  rep(i, n) cout << ans[i] << " ";

  cout << endl;

  return 0;

}


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



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

#define repr(i, n) for (int i = (n)-1; i >= 0; i--)

using namespace std;

typedef long long ll;



const int N = 2 * 1e5 + 5;

int n, q, a, b;

vector<vector<int>> r;

vector<int> ans;



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

  for (int u : r[v]) {

    if (u == p) continue;

    ans[u] += ans[v];

    dfs(u, v);

  }

}



int main() {

  cin >> n >> q;

  int p, x;

  r.resize(n);

  ans.resize(n);

  rep(i, n - 1) cin >> a >> b, a--, b--, r[a].push_back(b), r[b].push_back(a);

  rep(i, q) cin >> p >> x, p--, ans[p] += x;

  dfs(0);

  rep(i, n) cout << ans[i] << " ";

  cout << endl;

  return 0;

}