"use strict"

const arg_str = require('fs').readFileSync('/dev/stdin', 'UTF-8')
const args_lines = arg_str.split('\n')

const line_1 = args_lines[0].split(' ')
const n = line_1[0]
const q = line_1[1]

let tree = [{id: 1, cnt: 0, child: []}]

for(let i=1;i<parseInt(n);i++){
    const a_b = args_lines[i].split(' ')
    const a = a_b[0]
    const b = a_b[1]

    addChild(tree, a, b)
}

function addChild(tree, a, b){
    tree.map(x=>{
        if(x.id==a){
            x.child.push({id: b, cnt: 0, child: []})
        }else{
            if(x.child.length <= 0){
                return
            }else{
                addChild(x.child, a, b)
            }
        }
    })
}

const q_array = args_lines.slice(-parseInt(q))

q_array.map(x=>{
    const x_array = x.split(' ')
    const root = x_array[0]
    const add_num = x_array[1]
    addValue(tree, root, add_num, false)
})

function addValue(tree, root, add_num, is_root){
    tree.map(x=>{
        if(x.id==root || is_root){
            x.cnt += parseInt(add_num)
            addValue(x.child, root, add_num, true)
        }else{
            if(x.child.length <= 0){
                return
            }else{
                addValue(x.child, root, add_num, false)
            }
        }
    })
}

let result_array = []
pickItem(tree)
function pickItem(tree){
    tree.map(x=>{
        result_array.push(x)
        if(x.child.length > 0){
          pickItem(x.child)
        }
    })
}

const result_array_sort = result_array.sort((a,b)=>a.id-b.id)
const result = result_array_sort.map(x=>x.cnt)
console.log(result.join(' '))