아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Easy Problem

면접 대비

시간 제한3초메모리 제한1024 MB

요약
각 닭 i를 포함하는 급식기를 남기고, 어느 닭도 한계를 넘지 않도록 배분할 수 있는 최대 곡물 합을 i마다 구한다.
난이도

보통10점 중 5점

유형
구간, 누적 합, 그리디
정답자
아직 제출이 없습니다

문제

Askhat is a prospective businessman. He quickly figured that programming is an unprofitable business, so he decided to open a chicken farm.

His farm consists of nn chickens ordered in a row. The ii-th chicken can eat at most a_ia\_i grains. There are mm feeders, each described by integers l_jl\_j, r_jr\_j, c_jc\_j. The jj-th feeder can feed the ii-th chicken if l_j≤i≤r_jl\_j \le i \le r\_j, and there are c_jc\_j grains in this feeder.

Turns out that every business has its own pitfalls, in this case it has the face of chicken feeding control, represented by Ildar. He claims that every respectable chicken farm must have a chicken representative. That is, there must exist a chicken ii such that l_j≤i≤r_jl\_j \le i \le r\_j holds for every feeder jj. All feeders that don't obey this rule must be exterminated.

Now Askhat asks you to find, for each ii, what is the maximum number of grains that can be fed to chickens if we leave only feeders that can feed chicken ii.

입력

The first line contains a single integer tt (1≤t≤1041 \leq t \leq 10^4) --- the number of test cases. Description of test cases follows.

The first line of each test case contains two integers nn, mm (1≤n,m≤1051 \le n, m \le 10^5) --- the number of chickens and the number of feeders respectively.

The next line contains nn integers a_1,a_2,…,a_na\_1, a\_2, \ldots, a\_n (0≤a_i≤1090 \le a\_i \le 10^9) --- the number of grains that chickens can eat.

Each of the next mm lines contains three integers l_jl\_j, r_jr\_j, c_jc\_j (1≤l_j≤r_j≤n1 \le l\_j \le r\_j \le n, 0≤c_j≤1090 \le c\_j \le 10^9) --- description of the jj-th feeder.

It is guaranteed that both the sum of nn and the sum of mm for all test cases do not exceed 10510^5.

출력

For each test case, print nn integers --- the answer to the problem.

예제1

  1. 예제 1

    입력
    1
    4 3
    3 3 2 2
    1 2 2
    3 3 3
    2 2 4
    
    예상 출력
    2 5 2 0