#include <bits/stdc++.h>
using namespace std;
const int N_MAX = 10005;
const int Q_MAX = 10005;
struct query {
  int a, b, x;
};
int N, Q;
query queries[Q_MAX];
bitset<N_MAX> answer;
void solve(int start, int end, bitset<N_MAX> sums, bitset<Q_MAX> done) {
  for (int q = 0; q < Q; q++) {
    if (!done[q] && queries[q].a <= start && end <= queries[q].b) {
      sums |= sums << queries[q].x;
      done[q] = 1;
    }
  }
  if (start + 1 >= end) {
    answer |= sums;
    return;
  }
  int mid = (start + end) / 2;
  solve(start, mid, sums, done);
  solve(mid, end, sums, done);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N >> Q;
  for (int i = 0; i < Q; i++) {
    int a, b, x;
    cin >> a >> b >> x;
    queries[i] = (query){a - 1, b, x};
  }
  bitset<N_MAX> sums;
  sums[0] = 1;
  bitset<Q_MAX> done;
  solve(0, N, sums, done);
  vector<int> output;
  for (int i = 1; i <= N; i++) {
    if (answer[i]) output.push_back(i);
  }
  int count = output.size();
  cout << count << '\n';
  for (int i = 0; i < count; i++) {
    cout << output[i] << (i < count - 1 ? ' ' : '\n');
  }
  return 0;
}
