eolymp
bolt
Try our new interface for solving problems
Problems

Containers and compartments

Containers and compartments

You are the main developer in the foreign company Nurlash and KO inc. Company needs your help to write a new feature for a sorting robot. The robot controls n compartments sequentially numbered from 1 to n, and can perform two types of operations:

  1. Add a container with number C to each compartment from the L-th to R-th;

  2. Remove the last container from each compartment from L-th to R-th;

Container number is a positive integer not exceeding 109. You are given operations in the order in which they were performed by the robot. Determine, for each compartment, the number of container that is the last one on it after performing all the operations.

Input

First line contains two numbers n and m (1n, m105) - the number of compartments and the number of operations, respectively. Each of the next m lines contains three numbers L, R and C (1LR105, 0C109) - the description of operations. If C = 0, its operation of the second type, otherwise - of the first type.

All numbers are integers, separated with one space. It is guaranteed that there will be no operations that allow removal from empty compartments.

Output

Print in a single line n numbers, separated by space. The first number is the number of the last container in the first compartment, the second number is the number of the last container in the second compartment, and so on. If the compartment is empty, output 0.

Time limit 1 second
Memory limit 128 MiB
Input example #1
5 3
1 5 1
2 4 0
4 5 10
Output example #1
1 0 0 10 10
Source 2015 Kazakhstan, 4-th stage of Republican Informatics Olympiad, Uralsk, March 13-18, Problem А