#include <bits/stdc++.h>
using namespace std;
bool apare[100010];
int r[100010];
int n, q;
void add(int& a, int b) {
  a += b;
  if (a >= 1000000009) a -= 1000000009;
}
void rem(int& a, int b) {
  a -= b;
  if (a < 0) a += 1000000009;
}
void ins(int x) {
  for (int i(n); i >= 0; i--) {
    add(r[i + x], r[i]);
    if (r[i + x]) apare[i + x] = 1;
  }
}
void rem(int x) {
  for (int i(0); i <= n; i++) rem(r[i + x], r[i]);
}
vector<int> added[100010];
vector<int> removed[100010];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> q;
  for (int i(1); i <= q; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    added[a].push_back(c);
    removed[b].push_back(c);
  }
  r[0] = 1;
  for (int i(1); i <= n; i++) {
    for (auto j : added[i]) ins(j);
    for (auto j : removed[i]) rem(j);
  }
  vector<int> ans;
  for (int i(1); i <= n; i++)
    if (apare[i]) ans.push_back(i);
  cout << ans.size() << '\n';
  for (auto i : ans) cout << i << ' ';
  cout << '\n';
  return 0;
}
