struct Vertex: Hashable {
    
    let id: Int
}

class AdjacencyList {

    private var adjacencies: [Vertex: [Vertex]] = [:]

    init() {
    }

    @discardableResult
    func createVertex(id: Int) -> Vertex {

        let vertex = Vertex(id: id)
        adjacencies[vertex] = []
        return vertex
    }

    func addNeighbor(from source: Vertex, to destination: Vertex) {
        adjacencies[source]?.append(destination)
    }

    func neighbors(from source: Vertex) -> [Vertex] {
        adjacencies[source] ?? []
    }
}

extension AdjacencyList {

    func dfsRecursively(from start: Vertex) -> [Vertex] {

        var marks: Set<Vertex> = []
        var visited: [Vertex] = []
        
        dfs(from: start,
            marks: &marks,
            visited: &visited)

        return visited
    }
    
    func dfs(from source: Vertex,
             marks: inout Set<Vertex>,
             visited: inout [Vertex]) {

        marks.insert(source)
        visited.append(source)
        
        for neighbor in neighbors(from: source) {
            
            if !marks.contains(neighbor) {
                dfs(from: neighbor,
                    marks: &marks,
                    visited: &visited)
            }
        }
    }
}

func solve(_ graph: AdjacencyList, _ operations: [(vertex: Vertex, increment: Int)]) -> String {

    let reduecedOperations = operations
        .reduce(into: [Vertex: Int]()) { $0[$1.vertex] = ($0[$1.vertex] ?? 0) + $1.increment}

    var countersByVertex = [Vertex: Int]()

    reduecedOperations.forEach() { vertex, increment in

        let vertices = graph.dfsRecursively(from: vertex)

        vertices.forEach() { vertex in

            let counter = countersByVertex[vertex] ?? 0
            countersByVertex[vertex] = counter + increment
        }
    }

    return countersByVertex
        .sorted() { $0.0.id < $1.0.id }
        .reduce(into: [String]()) { $0.append(String($1.value)) }
        .joined(separator: " ")
}



let n_q = *readInts()

var rows = [[Int]]()
while let row = readInts() {
    rows.append(row)
}

let adjacencies = rows.dropLast(n_q.1)
let operations = rows.suffix(n_q.1).map() { (Vertex(id: $0[0]), $0[1]) }

let graph = AdjacencyList()
for id in 1...n_q.0 {
    graph.createVertex(id: id)
}

for adjacency in adjacencies {
    graph.addNeighbor(from: Vertex(id: adjacency[0]), to: Vertex(id: adjacency[1]))
}

let answer = solve(graph, operations)
print(answer)



func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}
func readInts() -> [Int]? {
    let ints = readLine()!.split(separator: " ").map { Int($0)! }
    return ints.isEmpty ? .none : ints
}
prefix operator *
prefix func * <T> (a: [T]) -> (T, T) { return (a[0], a[1]) }
