#include <bits/stdc++.h>
using namespace std;
struct query {
  int l, r, v;
};
int menor(query a, query b) {
  if (a.l != b.l) return a.l < b.l;
  if (a.r != b.r) return a.r < b.r;
  return a.v < b.v;
}
const int MAX = 1e4 + 10;
int R[MAX];
query Q[MAX];
set<int> S;
int main() {
  int n, q;
  scanf("%d %d", &n, &q);
  for (int i = 0; i < q; i++) {
    scanf("%d %d %d", &Q[i].l, &Q[i].r, &Q[i].v);
  }
  sort(Q, Q + q, menor);
  R[0] = 1e6;
  for (int i = 0; i < q; i++) {
    for (int j = n - Q[i].v; j >= 0; j--) {
      if (R[j] < Q[i].l) continue;
      R[Q[i].v + j] = max(R[Q[i].v + j], min(R[j], Q[i].r));
    }
  }
  int res = 0;
  for (int i = 1; i <= n; i++) {
    if (R[i]) res++;
  }
  printf("%d\n", res);
  for (int i = 1; i <= n; i++) {
    if (R[i]) printf("%d ", i);
  }
  printf("\n");
}
