#include <bits/stdc++.h>
const int B = 2 << 20;
struct streambufcin {
  std::streambuf *in;
  char buf[B], *bg, *ed, ch;
  streambufcin() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    in = std::cin.rdbuf();
    bg = ed = NULL;
  }
  char getchar() {
    return (bg == ed) && (ed = (bg = buf) + in->sgetn(buf, B), bg == ed)
               ? -1
               : *bg++;
  }
  streambufcin &operator>>(char &c) {
    for (c = getchar(); isspace(c); c = getchar())
      ;
    return *this;
  }
  template <class T>
  streambufcin &operator>>(T &x) {
    bool neg = false;
    for (ch = getchar(); !isdigit(ch); ch = getchar())
      ;
    if (ch == '-') neg = true;
    for (x = 0; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    if (neg) x = -x;
    return *this;
  }
} cin;
struct streambufcout {
  std::streambuf *out;
  char buf[B], *optr;
  streambufcout() {
    out = std::cout.rdbuf();
    optr = buf;
  }
  ~streambufcout() { flush(); }
  void flush() {
    out->sputn(buf, optr - buf);
    optr = buf;
  }
  void pc(char c) {
    if (optr == buf + B) flush();
    *optr++ = c;
  }
  template <class T>
  streambufcout &operator<<(T x) {
    static int st[233], top;
    if (x < 0) {
      pc('-');
      x = -x;
    }
    do {
      st[++top] = x % 10;
      x /= 10;
    } while (x);
    while (top) pc(st[top--] ^ 48);
    return *this;
  }
  streambufcout &operator<<(char c) {
    pc(c);
    return *this;
  }
} cout;
const int maxn = 1e4 + 1;
std::vector<int> s[maxn << 2];
void update(int ql, int qr, int l, int r, int p, int k) {
  if (ql <= l && r <= qr) {
    s[p].push_back(k);
    return;
  }
  int mid = l + r >> 1;
  if (ql <= mid) update(ql, qr, l, mid, p << 1, k);
  if (qr > mid) update(ql, qr, mid + 1, r, p << 1 | 1, k);
}
std::bitset<maxn> answer, initial;
void solve(std::bitset<maxn> bt, int l, int r, int p) {
  std::bitset<maxn> now = bt;
  for (auto i : s[p]) {
    now |= now << i;
  }
  if (l == r) {
    answer |= now;
  } else {
    int mid = l + r >> 1;
    solve(now, l, mid, p << 1);
    solve(now, mid + 1, r, p << 1 | 1);
  }
}
int main() {
  int n, q;
  cin >> n >> q;
  while (q--) {
    int l, r, k;
    cin >> l >> r >> k;
    update(l, r, 1, n, 1, k);
  }
  initial.set(0);
  solve(initial, 1, n, 1);
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (answer[i]) {
      ++cnt;
    }
  }
  cout << cnt << '\n';
  for (int i = 1; i <= n; i++) {
    if (answer[i]) {
      cout << i << ' ';
    }
  }
  cout << '\n';
  return 0;
}
