#include<iostream>
#include<vector>
using namespace std;

int mark[200004], cnt[200004];
vector<int>adj[200004];

void solve(int u, int p, int d)
{
	d += mark[u];
	cnt[u] = d;
	for (int v : adj[u])if (v != p)solve(v, u, d);
}

int main()
{
	int n, m, x, y;
	cin >> n >> m;
	for (int i = 0; i < n - 1; i++)
	{
		cin >> x >> y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	for (int i = 0; i < m; i++)
	{
		cin >> x >> y;
		mark[x] += y;
	}
	solve(1, -1, 0);
	for (int i = 1; i <= n; i++)cout << cnt[i] << " ";
	cout << endl;

	return 0;

}