Tickets

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

Bessie is going on a hiking excursion! The trail that she is currently traversing consists of NN checkpoints labeled 1N1\ldots N (1N1051\le N\le 10^5).

There are KK (1K1051\le K\le 10^5) tickets available for purchase. The ii-th ticket can be purchased at checkpoint c_ic\_i (1c_iN1\le c\_i\le N) for price p_ip\_i (1p_i1091\le p\_i\le 10^9) and provides access to all of checkpoints \[a_i,b_i]\[a\_i,b\_i] (1a_ib_iN1\le a\_i\le b\_i\le N). Before entering any checkpoint, Bessie must have purchased a ticket that allows access to that checkpoint. Once Bessie has access to a checkpoint, she may return to it at any point in the future. She may travel between two checkpoints to which she has access, regardless of whether their labels differ by 1 or not.

For each of i\[1,N]i\in \[1,N], output the minimum total price required to purchase access to both checkpoints 11 and NN if Bessie initially has access to only checkpoint ii. If it is impossible to do so, print 1-1 instead.

입력

The first line contains NN and KK.

Each of the next KK lines contains four integers c_ic\_i, p_ip\_i, a_ia\_i, and b_ib\_i for each 1iK1\le i\le K.

출력

NN lines, one for each checkpoint.