#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#define graph_from1 true
#define graph_tree true
#define graph_weight false
typedef long long ll;
using namespace std;

class Graph_func
{
public:
	int Vnum;
	int ENum;
	int Qnum;
	vector<pair<int, int> > edgelist;
	vector<ll> edgeweight;
	vector<int> plist;
	vector<ll> xlist;
	vector<vector<int> > adjlist;
	vector<vector<ll> > adjlistweight;
	vector<int> adjnum;

	vector<ll> xdist;
	vector<ll> ans;

	vector<bool> x_visited;
	vector<int> x_prqarr;
	vector<bool> x_filled;

	void read_edge();
	void adjini();
	void visited_ini();
	void adjsort();
	vector<bool> graph_num_sbrt(int x, vector<bool> filled);
	int graph_num();
	void graph_BFS(ll BFS_ini);
	void graph_DFS(ll DFS_ini);
	void xydist_fill(int x, ll dist_tmp);
	void xydist_tree(int x, ll dist_tmp);   // ex. xydist_tree(3, 0)
	void xydist(int x);   // ex. xydist(3, 0)

	void anslist(int x, int x_prev);

	ll diameter();
	int leaves_num();

	bool xydist_def = false;
};

void Graph_func::read_edge()
{
	cin >> Vnum >> Qnum;
	if (graph_tree)
		ENum = Vnum - 1;// graph
	else
		cin >> ENum;
	edgelist.resize(ENum);
	edgeweight.resize(ENum);
	adjnum.resize(Vnum);
	xdist.resize(Vnum);
	adjlist.resize(Vnum);
	ans.resize(Vnum);
	plist.resize(Qnum);
	xlist.resize(Qnum);
	if (graph_weight)
		adjlistweight.resize(Vnum);
	for (int i = 0; i < Vnum; i++)
	{
		ans[i] = 0;
	}
	for (int i = 0; i < ENum; i++)
	{
		if (graph_weight)
			cin >> edgelist[i].first >> edgelist[i].second >> edgeweight[i];
		else
			cin >> edgelist[i].first >> edgelist[i].second;
		if (graph_from1)
		{
			edgelist[i].first--;
			edgelist[i].second--;
		}
	}
	for (int i = 0; i < Qnum; i++)
	{
		cin >> plist[i] >> xlist[i];
	}
	return;
}

void Graph_func::adjini()
{
	for (int i = 0; i < Qnum; i++)
		ans[plist[i] - 1] += xlist[i];
	for (int i = 0; i < Vnum; i++)
		adjnum[i] = 0;
	for (int i = 0; i < ENum; i++)
	{
		int x = edgelist[i].first;
		int y = edgelist[i].second;
		adjlist[x].push_back(y);
		adjlist[y].push_back(x);
		if (graph_weight)
		{
			ll xyweight = edgeweight[i];
			adjlistweight[x].push_back(xyweight);
			adjlistweight[y].push_back(xyweight);
		}
		adjnum[x]++;
		adjnum[y]++;
	}
	x_visited.resize(Vnum);
	for (int i = 0; i < Vnum; i++)
		x_visited[i] = false;

	return;
}

void Graph_func::visited_ini()
{
	for (int i = 0; i < Vnum; i++)
		x_visited[i] = false;
}

void Graph_func::adjsort()
{
	for (int i = 0; i < Vnum; i++)
		sort(adjlist[i].begin(), adjlist[i].end(), less<int>());
	return;
}

void Graph_func::anslist(int x, int x_prev)
{
	int adjnumtmp = adjnum[x];
	for (int i = 0; i < adjnumtmp; i++)
	{
		int x_next = adjlist[x][i];
		if (x_next != x_prev)
		{
			anslist(x_next, x);
			ans[x] += ans[x_next];
		}
	}
}

void Graph_func::graph_DFS(ll DFS_ini)
{
	x_prqarr.push_back(DFS_ini);
	x_visited[DFS_ini] = true;
	xdist[DFS_ini] = 0;

	while (!x_prqarr.empty())
	{
		int Ntmp = x_prqarr.size();
		for (int a = 0; a < Ntmp; a++)
		{
			int x = x_prqarr[x_prqarr.size() - 1];
			x_prqarr.pop_back();
			for (int i = 0; i < adjnum[x]; i++)
			{
				int x_new = adjlist[x][i];
				if (!x_visited[x_new])
				{
					ans[x_new] += ans[x];
					xdist[x_new] = xdist[x] + 1;
					x_prqarr.push_back(x_new);
					x_visited[x_new] = true;
				}
			}
		}
	}
	return;
}

int main(void)
{
	Graph_func graph;
	graph.read_edge();
	graph.adjini();
	graph.graph_DFS(0);
	for (int i = 0; i < graph.Vnum; i++)
		cout << graph.ans[i] << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 24308