#include <bits/stdc++.h>
using namespace std;
const int N = 2e4;
bitset<10001> bs[N], ans;
int lf[N], ri[N], totnod, n, q;
vector<int> val[N];
void Build(int o, int L, int R) {
  bs[o].flip(0);
  if (L == R) return;
  lf[o] = ++totnod;
  ri[o] = ++totnod;
  Build(lf[o], L, (((L) + (R)) >> 1));
  Build(ri[o], (((L) + (R)) >> 1) + 1, R);
}
void Tag_on(int o, int L, int R, int l, int r, int x) {
  if (R < l || r < L) return;
  if (l <= L && R <= r) {
    val[o].push_back(x);
    return;
  }
  Tag_on(lf[o], L, (((L) + (R)) >> 1), l, r, x);
  Tag_on(ri[o], (((L) + (R)) >> 1) + 1, R, l, r, x);
}
void dfs(int o, int L, int R) {
  for (auto v : val[o]) bs[o] |= bs[o] << v;
  if (L == R)
    ans |= bs[o];
  else {
    bs[lf[o]] = bs[ri[o]] = bs[o];
    dfs(lf[o], L, (((L) + (R)) >> 1));
    dfs(ri[o], (((L) + (R)) >> 1) + 1, R);
  }
}
int main() {
  scanf("%d%d", &n, &q);
  totnod = 1;
  Build(1, 1, n);
  for (int i = 0, l, r, x; i < q; ++i) {
    scanf("%d%d%d", &l, &r, &x);
    Tag_on(1, 1, n, l, r, x);
  }
  dfs(1, 1, n);
  int cnt = 0;
  for (int i = 1; i <= n; ++i) cnt += ans.test(i);
  printf("%d\n", cnt);
  for (int i = 1; i <= n; ++i)
    if (ans.test(i)) printf("%d ", i);
  return 0;
}
