Under construction

Still being built. Things may change

Art Class

Interview

Time limit0.5sMemory limit512 MB

Summary
Given N cells and Q range queries that paint only still-uncolored cells, print the final color of each cell.
Level

Medium4 of 10

Topics
Union-find, Array
Solved
No attempts yet

Problem

Minkyu suddenly wanted to draw one day. Nearby, Jeonghwan, who has mastered both art and competitive programming, was solving a problem. Minkyu asked Jeonghwan how to draw well, and Jeonghwan handed him a long rectangular sheet of uncolored paper with NN cells. He said that a beautiful picture would be finished if Minkyu followed these instructions:

  • a b x: paint every uncolored cell from the aa-th to the bb-th cell with color xx.

However, Minkyu finds this process too tedious and wants someone else to do it. Let's complete Minkyu's drawing for him.

Input

The first line contains the number of cells NN and the number of queries QQ, separated by a space (1≤N≤1051 \le N \le 10^5, 1≤Q≤1051 \le Q \le 10^5). Each of the next QQ lines contains one query (1≤a≤b≤N1 \le a \le b \le N, 1≤x≤1091 \le x \le 10^9).

Output

After all queries are performed, print the color of each cell on one line, separated by spaces. Cells that were never painted are printed as 00.

Examples1

  1. Example 1

    Input
    6 2
    4 4 3
    1 5 1
    
    Expected output
    1 1 1 3 1 0