#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10005;
vector<int> add[MAXN], rem[MAXN];
bool ans[MAXN];
long long can[MAXN];
long long modmul(long long a, long long b, long long mod) {
  if (!b) return 0;
  if (b & 1) return (a + modmul(a, b - 1, mod)) % mod;
  long long v = modmul(a, b / 2, mod);
  return (v + v) % mod;
}
long long modex2(long long a, long long p, long long mod) {
  if (!p) return 1;
  if (p & 1) return modmul(a, modex2(a, p - 1, mod), mod);
  long long v = modex2(a, p / 2, mod);
  return modmul(v, v, mod);
}
mt19937_64 rng;
bool miller(long long d, long long n) {
  long long a = 1 + (rng() % (n - 1));
  long long x = modex2(a, d, n);
  if (x == 1 || x == n - 1) return true;
  while (d < n - 1) {
    x = modmul(x, x, n);
    d *= 2;
    if (x == n - 1) return true;
  }
  return false;
}
bool isPrime(long long n) {
  if (n <= 1) return false;
  if (n == 2) return true;
  if (n % 2 == 0) return false;
  long long d = n - 1;
  while (d % 2 == 0) d /= 2;
  for (int i = 0; i < 20; ++i)
    if (!miller(d, n)) return false;
  return true;
}
int main() {
  const long long BIG = 1LL << 58;
  mt19937_64 rng(
      chrono::high_resolution_clock::now().time_since_epoch().count());
  long long mod = BIG + (rng() % BIG);
  while (!isPrime(mod)) ++mod;
  long long mod2 = BIG + (rng() % BIG);
  while (!isPrime(mod2)) ++mod2;
  int N, Q;
  scanf("%d%d", &N, &Q);
  while (Q--) {
    int l, r, x;
    scanf("%d%d%d", &l, &r, &x);
    add[l].push_back(x);
    rem[r + 1].push_back(x);
  }
  can[0] = 1;
  for (int i = 1; i <= N; ++i) {
    for (int a : add[i]) {
      for (int j = N; j >= a; --j) {
        can[j] += can[j - a];
        if (can[j] >= mod) can[j] -= mod;
      }
    }
    for (int a : rem[i]) {
      for (int j = a; j <= N; ++j) {
        can[j] -= can[j - a];
        if (can[j] < 0) can[j] += mod;
      }
    }
    for (int j = 1; j <= N; ++j) {
      if (can[j]) ans[j] = true;
    }
  }
  int cnt = 0;
  for (int j = 1; j <= N; ++j)
    if (ans[j]) ++cnt;
  printf("%d\n", cnt);
  for (int j = 1; j <= N; ++j)
    if (ans[j]) printf("%d ", j);
}
