#include <bits/stdc++.h>
using namespace std;
vector<int> it[10101 * 4];
int n, q;
void add(int v, int ql, int qr, int i = 1, int l = 1, int r = n) {
  if (l > r or l > qr or ql > r) return;
  if (ql <= l and r <= qr) {
    it[i].push_back(v);
    return;
  }
  int mid = (l + r) / 2;
  add(v, ql, qr, i << 1, l, mid);
  add(v, ql, qr, i << 1 | 1, mid + 1, r);
}
bitset<10101> ans;
vector<bitset<10101> > bsst;
void getans(int i = 1, int l = 1, int r = n) {
  if (l > r) return;
  bitset<10101> bs = bsst.back();
  for (auto f : it[i]) {
    bs |= bs << f;
  }
  if (l == r) {
    ans = ans | bs;
    return;
  }
  bsst.push_back(bs);
  int mid = (l + r) / 2;
  getans(i << 1, l, mid);
  getans(i << 1 | 1, mid + 1, r);
  bsst.pop_back();
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  for (int i = -1; ++i < q;) {
    int l, r, u;
    cin >> l >> r >> u;
    add(u, l, r);
  }
  bsst.push_back(bitset<10101>());
  bsst[0][0] = 1;
  getans();
  vector<int> res;
  for (int i = 0; i++ < n;)
    if (ans[i]) res.push_back(i);
  cout << ((int)res.size()) << '\n';
  for (auto i : res) cout << i << ' ';
  return 0;
}
