#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1 << 14;
int m;
vector<int> v[2 * MAX_N - 1];
void init(int m_) {
  m = 1;
  while (m < m_) m *= 2;
}
void update(int a, int b, int k, int l, int r, int x) {
  if (r <= a || b <= l) return;
  if (a <= l && r <= b) {
    v[k].push_back(x);
  } else {
    update(a, b, k * 2 + 1, l, (l + r) / 2, x);
    update(a, b, k * 2 + 2, (l + r) / 2, r, x);
  }
}
bitset<10001> solve(int k) {
  if (k >= m - 1) {
    bitset<10001> bs;
    bs[0] = 1;
    for (auto x : v[k]) bs = bs | (bs << x);
    return bs;
  }
  bitset<10001> bs = solve(2 * k + 1) | solve(2 * k + 2);
  for (auto x : v[k]) bs = bs | (bs << x);
  return bs;
}
int main() {
  int n, q;
  scanf("%d %d", &n, &q);
  init(n);
  for (int i = 0; i < q; i++) {
    int l, r, x;
    scanf("%d %d %d", &l, &r, &x);
    l--;
    update(l, r, 0, 0, m, x);
  }
  bitset<10001> bans = solve(0);
  vector<int> ans;
  for (int i = 1; i <= n; i++) {
    if (bans[i]) ans.push_back(i);
  }
  printf("%d\n", ans.size());
  for (auto x : ans) printf("%d ", x);
  printf("\n");
  return 0;
}
