Public Judge

pjudge

时间限制: 2 s 内存限制: 1024 MB 总分: 100
统计

There are $n$ chickens standing in a row, where the $i$-th chicken can eat at most $a_i$ grains.

There are $m$ porters. The $j$-th porter can feed grains to chickens $l_j, l_j+1, \dots, r_j$, and carries $c_j$ grains. A porter does not need to feed all the grains they carry; they only need to ensure that the total amount of grains fed does not exceed $c_j$.

For each $i$, calculate the maximum total amount of grains that can be fed if only the porters satisfying $l_j \le i \le r_j$ are kept.

Input

The first line of each test case contains a positive integer $T$, representing the number of test cases. The format for each test case is as follows:

The first line contains two positive integers $n$ and $m$, representing the number of chickens and porters, respectively.

The second line contains $n$ non-negative integers $a_1, a_2, \dots, a_n$, representing the amount of grains each chicken can eat.

The next $m$ lines each contain three integers $l_j, r_j, c_j$, describing the $j$-th porter.

Output

For each test case, output a single line containing $n$ non-negative integers, representing the answers.

Examples

Input 1

1
4 3
3 3 2 2
1 2 2
3 3 3
2 2 4

Output 1

2 5 2 0

Input 2

See ex_2.in/ex_2.ans in the provided files.

Constraints

This problem uses subtask-based testing.

For all data, it is guaranteed that $1 \le T \le 10^4$, $1 \le \sum n, \sum m \le 10^5$, $0 \le a_i \le 10^9$, $1 \le l_j \le r_j \le n$, and $0 \le c_j \le 10^9$.

Subtask ID $\sum n, \sum m \le$ Special Properties Score
$1$ $300$ $15$
$2$ $2000$ $15$
$3$ $10^5$ $l_j=1, r_j \le r_{j+1}$ $20$
$4$ $10^5$ $l_j \le l_{j+1}, r_j \le r_{j+1}$ $25$
$5$ $10^5$ $25$

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.