# 描述

Grisha come to a contest and faced the following problem.

You are given an array of size $n$, initially consisting of zeros. The elements of the array are enumerated from $1$ to $n$. You perform $q$ operations on the array. The $i$-th operation is described with three integers $l_i$, $r_i$ and $x_i$ ($1≤l_i≤r_i≤n$, $1≤x_i≤n$) and means that you should add $x_i$ to each of the elements with indices $l_i,l_{i+1},…,r_i$. After all operations you should find the maximum in the array.

Grisha is clever, so he solved the problem quickly.

However something went wrong inside his head and now he thinks of the following question: “consider we applied some subset of the operations to the array. What are the possible values of the maximum in the array?”

Help Grisha, find all integers $y$ between $1$ and $n$ such that if you apply some subset (possibly empty) of the operations, then the maximum in the array becomes equal to $y$.

## Input

The first line contains two integers $n$ and $q$ ($1≤n,q≤10^4$) — the length of the array and the number of queries in the initial problem.

The following $q$ lines contain queries, one per line. The $i$-th of these lines contains three integers $l_i, r_i and x_i$ ($1≤l_i≤r_i≤n$, $1≤x_i≤n$), denoting a query of adding $x_i$ to the segment from $l_i$-th to $r_i$-th elements of the array, inclusive.

## Output

In the first line print the only integer $k$, denoting the number of integers from $1$ to $n$, inclusive, that can be equal to the maximum in the array after applying some subset (possibly empty) of the given operations.

In the next line print these $k$ integers from $1$ to $n$ — the possible values of the maximum. Print these integers in increasing order.

Input Output

# 思路

• 区间更新，我们可以想到用线段树来打懒惰标记。但是这题要求的是可以达到的最大值。
• 容易想到，根据懒惰标记的深度来选择更新的集合可以得到不同的最大值。
• 于是我们把标记全部存下来后进行DP。$dp[i][j]$表示线段树深度为$i$的结点能否得到$j$的答案。
• std::bitset大力干就好了。

0%