#include <bits/stdc++.h>
template <typename T>
T gcd(T a, T b) {
  T m;
  while (b != T(0)) {
    m = a % b;
    a = b;
    b = m;
  }
  return a;
}
template <typename T>
T lcm(T a, T b) {
  return a == 0 && b == 0 ? 0 : (a / gcd(a, b)) * b;
}
int const MAXN = 10004;
int const MOD = 1000000000 + 7;
int N, Q;
bool ans[MAXN];
int dp[MAXN * 3];
std::vector<int> add[MAXN], rem[MAXN];
static int solve() {
  scanf("%d%d", &N, &Q);
  for (int i = 0; i < Q; ++i) {
    int l, r, x;
    scanf("%d%d%d", &l, &r, &x);
    add[l].push_back(x);
    rem[r + 1].push_back(x);
  }
  dp[0] = 1;
  for (int i = 1; i <= N; ++i) {
    for (int x : add[i]) {
      for (int j = N; j >= 0; --j) dp[j + x] = (dp[j + x] + dp[j]) % MOD;
    }
    for (int x : rem[i]) {
      for (int j = 0; j <= N; ++j) {
        dp[j + x] = (dp[j + x] - dp[j] + MOD) % MOD;
      }
    }
    for (int j = 1; j <= N; ++j) {
      if (dp[j]) ans[j] = true;
    }
  }
  int na = 0;
  for (int i = 1; i <= N; ++i) na += ans[i];
  printf("%d\n", na);
  for (int i = 1; i <= N; ++i)
    if (ans[i]) printf("%d ", i);
  return 0;
}
int main(int argc, char* argv[]) {
  solve();
  return 0;
}
