#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e4 + 10;
long long rd() {
  long long x = 0, first = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') first = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * first;
}
bitset<10002> tmp[N * 4], cur, ret;
vector<int> nd[N * 4];
void modify(int p, int l, int r, int tl, int tr, int v) {
  if (tl == l && tr == r)
    nd[p].push_back(v);
  else {
    int md = (l + r) >> 1;
    if (tr <= md)
      modify(p + p, l, md, tl, tr, v);
    else if (tl > md)
      modify(p + p + 1, md + 1, r, tl, tr, v);
    else
      modify(p + p, l, md, tl, md, v),
          modify(p + p + 1, md + 1, r, md + 1, tr, v);
  }
}
void solve(int p, int l, int r) {
  tmp[p] = cur;
  for (auto l : nd[p]) cur |= cur << l;
  if (l == r) {
    ret |= cur;
  } else {
    int md = (l + r) >> 1;
    solve(p + p, l, md);
    solve(p + p + 1, md + 1, r);
  }
  cur = tmp[p];
}
int main() {
  int n = rd(), q = rd();
  for (int i = 1; i <= q; i++) {
    int l = rd(), r = rd(), c = rd();
    modify(1, 1, n, l, r, c);
  }
  cur[0] = 1;
  solve(1, 1, n);
  int ans = 0;
  for (int i = 1; i <= n; i++)
    if (ret[i]) ans++;
  printf("%d\n", ans);
  for (int i = 1; i <= n; i++)
    if (ret[i]) printf("%d ", i);
}
