#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
vector<pair<long long, long long> > q;
long long n, qc;
long long cnt[10005];
bool can[10005];
signed main() {
  ios::sync_with_stdio(false);
  cin >> n >> qc;
  for (long long i = 1; i <= qc; i++) {
    long long l, r, v;
    cin >> l >> r >> v;
    q.push_back({l, v});
    q.push_back({r + 1, -v});
  }
  sort(q.begin(), q.end());
  {
    for (long long iz = 0; iz < q.size(); iz++) {
      if (q[iz].second > 0) {
        long long cac = q[iz].second;
        can[cac] = true;
        for (long long i = n - cac; i >= 1; i--) {
          if (cnt[i] >= 1) {
            cnt[i + cac] += cnt[i];
            cnt[i + cac] += mod;
            cnt[i + cac] %= mod;
            can[i + cac] = true;
          }
        }
        cnt[cac]++;
      } else {
        long long cac = -q[iz].second;
        cnt[cac]--;
        for (long long i = 1; i <= n - cac; i++) {
          if (cnt[i] >= 1) {
            cnt[i + cac] -= cnt[i];
            cnt[i + cac] += mod;
            cnt[i + cac] %= mod;
          }
        }
      }
    }
  }
  long long hv = 0;
  queue<long long> ans;
  for (long long i = 1; i <= n; i++) {
    if (can[i]) {
      hv++;
      ans.push(i);
    }
  }
  cout << hv << endl;
  while (ans.size()) {
    cout << ans.front() << " ";
    ans.pop();
  }
}
