#include <bits/stdc++.h>
using namespace std;
struct otr {
  int l;
  int r;
  int v;
};
bool operator<(otr a, otr b) { return (a.l < b.l); }
bool operator>(otr a, otr b) { return (a.l > b.l); }
otr a[10007];
int f[10007];
bool u[10007];
vector<int> p;
int main() {
  int n, q;
  cin >> n >> q;
  for (int i = 0; i < q; i++) {
    cin >> a[i].l >> a[i].r >> a[i].v;
    a[i].l--;
    a[i].r--;
  }
  int y = 1;
  sort(a, a + q);
  f[0] = 1000000;
  for (int i = 0; i < q; i++) {
    y = n - a[i].v;
    for (int j = y; j >= 0; j--) {
      if (f[j] > a[i].l) {
        u[j + a[i].v] = true;
        f[j + a[i].v] = max(f[j + a[i].v], min(a[i].r + 1, f[j]));
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (u[i]) {
      p.push_back(i);
    }
  }
  cout << p.size() << endl;
  for (int i = 0; i < p.size(); i++) {
    cout << p[i] << " ";
  }
  return 0;
}
