#include <bits/stdc++.h>
using namespace std;
template <class U, class T>
void Max(U &first, T second) {
  if (first < second) first = second;
}
template <class U, class T>
void Min(U &first, T second) {
  if (first > second) first = second;
}
template <class T>
void add(int &a, T b) {
  a = (a + b) % 1000000007;
}
int pow(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = 1LL * ans * a % 1000000007;
    a = 1LL * a * a % 1000000007;
    b >>= 1;
  }
  return ans;
}
int pow(int a, int b, int c) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = 1LL * ans * a % c;
    a = 1LL * a * a % c;
    b >>= 1;
  }
  return ans;
}
bitset<10002> all;
vector<int> t[10010 << 2];
void add(int p, int l, int r, int first, int second, int v) {
  if (l >= first && r <= second) {
    t[p].push_back(v);
    return;
  }
  int m = (l + r) >> 1;
  if (first <= m) add(p << 1, l, m, first, second, v);
  if (second > m) add(p << 1 | 1, m + 1, r, first, second, v);
}
void solve(int p, int l, int r, bitset<10002> &cur) {
  bitset<10002> tmp = cur;
  for (auto &first : t[p]) {
    cur |= cur << first;
  }
  all |= cur;
  if (l < r) {
    int m = (l + r) >> 1;
    solve(p << 1, l, m, cur);
    solve(p << 1 | 1, m + 1, r, cur);
  }
  cur = tmp;
}
int main() {
  int T, ca = 0, m = 0, k, i, j, n, K;
  scanf("%d%d", &n, &m);
  while (m--) {
    scanf("%d%d%d", &i, &j, &k);
    i--, j--;
    add(1, 0, n - 1, i, j, k);
  }
  bitset<10002> cur;
  cur[0] = 1;
  solve(1, 0, n - 1, cur);
  int ans = 0;
  for (int i = 1; i < n + 1; i++)
    if (all.test(i)) ans++;
  printf("%d\n", ans);
  for (int i = 1; i < n + 1; i++)
    if (all.test(i)) printf("%d ", i);
  puts("");
}
