#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
const double pi =
    3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int MR = 1e4 + 10;
const int MOD = 1e9 + 9;
bool res[MR];
vector<int> poczatki[MR], konce[MR];
int dp[MR];
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 0; i < (q); ++i) {
    int l, r, x;
    scanf("%d%d%d", &l, &r, &x);
    poczatki[l].push_back(x);
    konce[r].push_back(x);
  }
  dp[0] = 1;
  for (int i = (1); i <= (n); ++i) {
    for (int x : poczatki[i])
      for (int j = (n - x + 1) - 1; j >= (0); --j) {
        dp[j + x] = (dp[j + x] + dp[j]) % MOD;
        if (dp[j + x]) res[j + x] = 1;
      }
    for (int x : konce[i])
      for (int j = (x); j <= (n + 1); ++j)
        if (dp[j]) dp[j] = (dp[j] - dp[j - x] + MOD) % MOD;
  }
  int ile = 0;
  for (int i = (1); i <= (n); ++i) ile += res[i];
  printf("%d\n", ile);
  for (int i = (1); i <= (n); ++i)
    if (res[i]) printf("%d ", i);
  printf("\n");
  return 0;
}
