Bessie is going on a hiking excursion! The trail that she is currently traversing consists of N checkpoints labeled 1…N (1≤N≤105).
There are K (1≤K≤105) tickets available for purchase. The i-th ticket can be purchased at checkpoint c_i (1≤c_i≤N) for price p_i (1≤p_i≤109) and provides access to all of checkpoints \[a_i,b_i] (1≤a_i≤b_i≤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], output the minimum total price required to purchase access to both checkpoints 1 and N if Bessie initially has access to only checkpoint i. If it is impossible to do so, print −1 instead.
The first line contains N and K.
Each of the next K lines contains four integers c_i, p_i, a_i, and b_i for each 1≤i≤K.
N lines, one for each checkpoint.