#K8181. Compute Net Balances

    ID: 35836 Type: Default 1000ms 256MiB

Compute Net Balances

Compute Net Balances

You are given n persons and m transactions between them. Each transaction is represented by three integers u, v, and w, which indicate that person u transferred w units of money to person v. Your task is to compute the net balance for each person after all the transactions.

The net balance is calculated as:

\( \text{balance}[i] = \text{total received} - \text{total paid} \)

for each person i (using 1-indexed notation). A negative balance indicates an overall loss.

Read the input from standard input and write the result to standard output.

inputFormat

The first line of input contains two integers n and m (\(1 \leq n \leq 10^5\), \(0 \leq m \leq 10^5\)).

Each of the next m lines contains three integers u, v, and w (\(1 \leq u,v \leq n\) and \(1 \leq w \leq 10^9\)) describing a transaction where person u pays person v an amount w.

outputFormat

Output a single line containing n integers separated by a space. The i-th integer should be the net balance of person i after all transactions.

## sample
4 3
1 2 10
2 3 5
3 4 2
-10 5 3 2

</p>