Fault

Given diagonal fault shifts with surface erosion, report the original depth of the layer exposed at each unit of the surface.

Hard8Segment treeGeometryNo attempts yetTime limit2sMemory limit256 MB

Problem

Long ago the IOI civilisation flourished, then a volcanic eruption destroyed it. The civilisation grew along a straight river, and when it fell its ground surface was perfectly flat.

Treat the ruins as a coordinate plane. The xx axis is the ground surface and the yy axis is the height direction. The line y=0y = 0 is the surface, the region y>0y > 0 is above ground, and the region y<0y < 0 is underground. Measured from the moment the civilisation fell, the layer deposited aa years earlier (a0a \ge 0) lay on the line y=ay = -a.

After the fall, QQ crustal movements happened at the ruins. The iith movement (1iQ1 \le i \le Q) is described by a position XiX_i, a direction DiD_i, and an amount LiL_i, where DiD_i is 1 or 2. The iith movement happens in this order.

  1. The strata move.
    • If Di=1D_i = 1, a fault forms along the line of slope 11 through the point (Xi,0)(X_i, 0), and the strata in the region above that line move along the line by a height of LiL_i. That is, a point (x,y)(x, y) above the line moves to (x+Li, y+Li)(x + L_i,\ y + L_i).
    • If Di=2D_i = 2, a fault forms along the line of slope 1-1 through the point (Xi,0)(X_i, 0), and the strata in the region above that line move along the line by a height of LiL_i. That is, a point (x,y)(x, y) above the line moves to (xLi, y+Li)(x - L_i,\ y + L_i).
  2. Immediately afterwards, every stratum lying in the region y>0y > 0 is worn away and disappears.

In the present day the archaeologist Dr. JOI excavates the ruins of the IOI civilisation. He knows every crustal movement that happened, and he wants to know how many years before the fall of the civilisation each exposed layer was deposited.

Given the crustal movements, for each integer ii with 1iN1 \le i \le N, find how many years before the fall of the civilisation the layer exposed at the surface between the point (i1,0)(i - 1, 0) and the point (i,0)(i, 0) was deposited.

Input

The first line contains two integers NN and QQ separated by a space. There are NN layers whose ages you must report, and QQ crustal movements.

Each of the next QQ lines contains three integers. The iith of them (1iQ1 \le i \le Q) contains XiX_i, DiD_i, and LiL_i separated by spaces, meaning that the iith crustal movement had position XiX_i, direction DiD_i, and amount LiL_i.

Output

Print NN lines.

The iith line (1iN1 \le i \le N) contains one integer, the number of years before the fall of the civilisation at which the layer exposed at the surface between the point (i1,0)(i - 1, 0) and the point (i,0)(i, 0) was deposited.

Constraints

  • 1N2000001 \le N \le 200000
  • 1Q2000001 \le Q \le 200000
  • 1000000000Xi1000000000-1000000000 \le X_i \le 1000000000 (1iQ1 \le i \le Q)
  • 1Di21 \le D_i \le 2 (1iQ1 \le i \le Q)
  • 1Li10000000001 \le L_i \le 1000000000 (1iQ1 \le i \le Q)