
var children = [];
var values = [];
function add(idx, value) {
	var lists = [];
	var list = [idx];
	while(list.length + lists.length != 0) {
		if(list.length == 0) list = lists.pop();
		var i = list.pop();
		if(children[i].length != 0) lists.push(children[i]);
		values[i] += value;
	}
}
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	var count = input[0].split(" ");
	var nodeCount = count[0]-0;
	var dataCount = count[1]-0;
	var i;
	for(i = 0; i < nodeCount; i++) { children[i] = []; values[i] = 0; }
	for(i = 1; i < nodeCount; i++) {
		var data = input[i].split(" ");
		children[data[0]-1].push(data[1]-1);
	}
	for(i = nodeCount; i < nodeCount + dataCount; i++) {
		var data = input[i].split(" ");
		add(data[0]-1, data[1]-0);
	}
	
	var ret = "" + values[0];
	for(var i = 1; i < nodeCount; i++) ret += " " + values[i];
	console.log(ret);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));