403541: GYM101192 C A lost array

Memory Limit:64 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

C. A lost arraytime limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard output

Fortune smiled upon little Lyosha: he managed to get a very rare and unique array A, which consists of n integers. Having obtained such a precious object, the boy immediately brought it to his underground laboratory so as to fathom the mystery of the array's structure. As an experienced researcher, Lyosha decided not to hurry with performing all the horrible experiments with the poor array, but to observe it at first. On a piece of paper he made some notes on m observations of the array. Each observation is described by 3 numbers li, ri and si, which mean, that the sum of elements modulo 2 on the subsegment [li, ri] of the array equals si. Lyosha has prepared everything required for the (m + 1)-th observation, but at that point he heard his mother calling him for dinner. Once the boy returned to his lab after the dinner, he shuddered with horror: the array was gone. At all. All the hopes of the little boy of getting the Nobel Prize in the field of array research have vanished in no time. However Lyosha remembered, that he still had some information left about the array. Based on the facts he had previously written down, he decided to build a virtual prototype of the array and conduct experiments with it. Of course, the little boy realized there was no way he could restore an identical copy of the lost array, because there are infinitely many arrays which comply with his previously written down observations. Certainly, all of us know, that operations with huge numbers take huge amount of time, and things get even worse when it comes to negative ones. In order to make his computer prototype as fast as possible, little Lyosha decided to build an array that complies with his notes, its elements are all non-negative and their sum is as small as possible. Help him to do it!

Input

The first line of the input contains two integers n and m — the size of the lost array and the number of observations, which little boy made about it. Then m lines follow. The i-th line contains three integers li, ri and si - description of the i-th observation.

1 ≤ n ≤ 40
0 ≤ m ≤ 100
1 ≤ li ≤ ri ≤ n
0 ≤ si ≤ 1
0 ≤ ai ≤ 109
Output

Print n integers ai - elements of the brand new array. If there are several possible arrays, print lexicographically minimal of them. Formally, an array X is lexicographically less then array Y if there is such number k ≤ |X|, that for all i < k Xi = Yi and Xk < Yk.

ExampleInput
3 3
2 2 1
3 3 0
2 3 1
Output
0 1 0

加入题单

算法标签: