#include <bits/stdc++.h>
const int N = 10007, inf = 0x3f3f3f3f;
using namespace std;
struct evt {
  int p, x, id;
};
evt eventos[N + N];
unsigned char ans[N];
int cmp(evt a, evt b) {
  if (a.p == b.p) {
    if (a.x < 0 and b.x > 0) return 1;
    if (b.x < 0 and a.x > 0) return 1;
    return 0;
  }
  return a.p < b.p;
}
long long can[N];
int n, m;
void add(int x) {
  for (int i = n; i >= x; --i) {
    can[i] += can[i - x];
    if (can[i]) ans[i] = 1;
  }
}
void rem(int x) {
  for (int i = x; i <= n; ++i) {
    can[i] -= can[i - x];
  }
}
int main() {
  int l, r, x, p;
  evt e;
  scanf("%d %d", &n, &m);
  int ptr = 0;
  for (int i = 0; i < m; ++i) {
    scanf("%d %d %d", &l, &r, &x);
    eventos[ptr++] = {l, x, i};
    eventos[ptr++] = {r + 1, -x, i};
  }
  sort(eventos, eventos + ptr, cmp);
  can[0] = 1;
  for (int i = 0; i < ptr; ++i) {
    e = eventos[i];
    if (e.x > 0)
      add(e.x);
    else
      rem(-e.x);
  }
  int tot = 0;
  for (int i = 1; i <= n; ++i) {
    tot += ans[i] > 0;
  }
  printf("%d\n", tot);
  for (int i = 1; i <= n; ++i) {
    if (ans[i]) printf("%d ", i);
  }
  printf("\n");
}
