#include <bits/stdc++.h>
using namespace std;
vector<int> node[10000 + 7 << 2];
bitset<20000 + 7> ans;
int n, k;
void insert(int now, int C, int L, int R, int ll, int rr) {
  if (L >= ll && R <= rr) {
    node[now].push_back(C);
    return;
  }
  int mid = (L + R) >> 1;
  if (mid >= ll) insert(now << 1, C, L, mid, ll, rr);
  if (mid < rr) insert(now << 1 | 1, C, mid + 1, R, ll, rr);
}
void update(int L, int R, int now, bitset<20000 + 7> b) {
  for (int i = 0; i < node[now].size(); i++) {
    b |= (b << node[now][i]);
  }
  if (L == R) {
    ans |= b;
    return;
  }
  int mid = (L + R) >> 1;
  update(L, mid, now << 1, b);
  update(mid + 1, R, (now << 1) | 1, b);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> k;
  int l, r, x;
  for (int i = 0; i < k; i++) {
    cin >> l >> r >> x;
    insert(1, x, 1, n, l, r);
  }
  update(1, n, 1, 1);
  int cnt = 0;
  vector<int> Q;
  for (int i = 1; i <= n; i++) {
    if (ans[i] == 1) {
      cnt++;
      Q.push_back(i);
    }
  }
  cout << cnt << endl;
  for (int i = 0; i < Q.size(); i++) cout << Q[i] << ' ';
}
