module app;

import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

struct Node
{
	uint counter;
	uint counterTotal;
	uint parentIndex; // 0-origin, uintにしたせいで根を表現できないのは処理でごまかす
	bool parentFixed;
	uint[] neighborhoods;
}

void main()
{
	auto input = parseInput();
	Node[] nodes; // 0-origin
	nodes.length = input.n;
	
	foreach (operation; input.operations)
	{
		nodes[operation.p - 1].counter += operation.x;
	}
	nodes[0].counterTotal = nodes[0].counter;

	foreach (edge; input.edges)
	{
		nodes[edge.a - 1].neighborhoods ~= edge.b - 1;
		nodes[edge.b - 1].neighborhoods ~= edge.a - 1;
	}
	
	nodes[0].parentFixed = true;
	
	uint[] queue;
	queue ~= 0;
	
	while (queue.length > 0)
	{
		auto target = queue[0];
		queue = queue[1..$];
		foreach (childIndex; nodes[target].neighborhoods)
		{
			if (nodes[childIndex].parentFixed)
			{ }
			else
			{
				nodes[childIndex].parentIndex = target;
				nodes[childIndex].parentFixed = true;
				nodes[childIndex].counterTotal = nodes[target].counterTotal + nodes[childIndex].counter;
				queue ~= childIndex;
			}
		}
	}
	
	foreach (i, ref node; nodes)
	{
		if (i == 0)
		{
			writef("%d", node.counterTotal);
		}
		else
		{
			writef(" %d", node.counterTotal);
		}
	}
}

struct Input
{
	uint n;
	uint q;
	Edge[] edges;
	Operation[] operations;
}

struct Edge
{
	uint a;
	uint b;
}

struct Operation
{
	uint p;
	uint x;
}

Input parseInput()
{
	Input input;
	auto nq = readln().strip().split();
	input.n = nq[0].to!uint;
	input.q = nq[1].to!uint;
	input.edges.length = input.n - 1;
	for (int i = 0; i < input.n - 1; i++)
	{
		auto ab = readln().strip().split();
		input.edges[i].a = ab[0].to!uint;
		input.edges[i].b = ab[1].to!uint;
	}
	input.operations.length = input.q;
	for (int i = 0; i < input.q; i++)
	{
		auto px = readln().strip().split();
		input.operations[i].p = px[0].to!uint;
		input.operations[i].x = px[1].to!uint;
	}
	return input;
}
