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 MBLong 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 x axis is the ground surface and the y axis is the height direction. The line y=0 is the surface, the region y>0 is above ground, and the region y<0 is underground. Measured from the moment the civilisation fell, the layer deposited a years earlier (a≥0) lay on the line y=−a.
After the fall, Q crustal movements happened at the ruins. The ith movement (1≤i≤Q) is described by a position Xi, a direction Di, and an amount Li, where Di is 1 or 2. The ith movement happens in this order.
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 i with 1≤i≤N, find how many years before the fall of the civilisation the layer exposed at the surface between the point (i−1,0) and the point (i,0) was deposited.
The first line contains two integers N and Q separated by a space. There are N layers whose ages you must report, and Q crustal movements.
Each of the next Q lines contains three integers. The ith of them (1≤i≤Q) contains Xi, Di, and Li separated by spaces, meaning that the ith crustal movement had position Xi, direction Di, and amount Li.
Print N lines.
The ith line (1≤i≤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 (i−1,0) and the point (i,0) was deposited.