#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "-funroll-loops", "-fdelete-null-pointer-checks")
#pragma GCC target("ssse3", "sse3", "sse2", "sse", "avx2", "avx")
using namespace std;
char buf[(1 << 21) + 5], *p1 = buf, *p2 = buf;
inline int qread() {
  register char c =
      (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)
           ? EOF
           : *p1++);
  register int x = 0, f = 1;
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)
             ? EOF
             : *p1++);
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)
             ? EOF
             : *p1++);
  }
  return x * f;
}
inline int Abs(const int &x) { return (x > 0 ? x : -x); }
inline int Max(const int &x, const int &y) { return (x > y ? x : y); }
inline int Min(const int &x, const int &y) { return (x < y ? x : y); }
const long long mod = 998244353;
long long dp[10005], n, q;
bool ans[10005];
vector<int> vca[10005], vcd[10005];
inline void Read() {
  n = qread();
  q = qread();
  for (register int i = 1; i <= q; i++) {
    register int l = qread(), r = qread(), k = qread();
    vca[l].push_back(k);
    vcd[r].push_back(k);
  }
}
inline void Addx(int x) {
  for (register int i = n; i >= x; i--) dp[i] = (dp[i - x] + dp[i]) % mod;
}
inline void Delx(int x) {
  for (register int i = x; i <= n; i++) dp[i] = (dp[i] - dp[i - x] + mod) % mod;
}
inline void Solve() {
  dp[0] = 1;
  for (register int i = 1; i <= n; i++) {
    register int siz = vca[i].size();
    for (register int j = 0; j < siz; j++) Addx(vca[i][j]);
    for (register int j = 1; j <= n; j++) {
      if (dp[j]) ans[j] = 1;
    }
    siz = vcd[i].size();
    for (register int j = 0; j < siz; j++) Delx(vcd[i][j]);
  }
  register int res = 0;
  for (register int i = 1; i <= n; i++) res += ans[i];
  printf("%d\n", res);
  for (register int i = 1; i <= n; i++) {
    if (ans[i]) printf("%d ", i);
  }
}
int main() {
  Read();
  Solve();
  return 0;
}
