#include <bits/stdc++.h>
using namespace std;
const int BASE = 1e9 + 7;
int N, Q, X[20010], cnt[20010], M;
pair<int, pair<int, int> > A[20020];
bool shouldClear[10010][10010];
bool res[20000];
void read() {
  cin >> N >> Q;
  for (int i = 1; i <= Q; i++) {
    int l, r;
    cin >> l >> r >> X[i];
    A[++M] = make_pair(l, make_pair(1, i));
    A[++M] = make_pair(r, make_pair(2, i));
  }
}
void solve() {
  sort(1 + A, 1 + M + A);
  memset(cnt, 0, sizeof(cnt));
  cnt[0] = 1;
  for (int i = 1; i <= M; i++) {
    int x = A[i].first, t = A[i].second.first, id = A[i].second.second;
    if (t == 1) {
      for (int k = N - X[id]; k >= 0; k--) {
        cnt[k + X[id]] = (cnt[k + X[id]] + cnt[k]) % BASE;
        if (cnt[k + X[id]] > 0) {
          res[k + X[id]] = true;
        }
      }
    } else {
      for (int k = X[id]; k <= N; k++) {
        cnt[k] = (cnt[k] + BASE - cnt[k - X[id]]) % BASE;
      }
    }
  }
  int result = 0;
  for (int i = 1; i <= N; i++) {
    if (res[i]) {
      result++;
    }
  }
  cout << result << endl;
  for (int i = 1; i <= N; i++) {
    if (res[i]) {
      cout << i << " ";
    }
  }
  cout << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  read();
  solve();
  return 0;
}
