#include <bits/stdc++.h>
using namespace std;
long long modpow(long long b, long long e, long long mod) {
  long long ans = 1;
  for (; e; b = b * b % mod, e /= 2) {
    if (e & 1) ans = ans * b % mod;
  }
  return ans;
}
bitset<10001> ans;
template <class T>
struct dcq {
  bitset<10001> atual;
  vector<vector<T>> st;
  int n;
  dcq(int nn) : st(2 * nn, vector<T>()), n(nn) {}
  void upd(int x, int y, T q) {
    for (x += n, y += n + 1; x < y; x /= 2, y /= 2) {
      if (x & 1) st[x++].push_back(q);
      if (y & 1) st[--y].push_back(q);
    }
    return;
  }
  void solve(int curr = 1) {
    bitset<10001> rb = atual;
    for (auto w : st[curr]) {
      atual = (atual) | (atual << w);
      atual[w] = true;
    }
    if (curr >= n) {
      ans |= atual;
    } else {
      solve(2 * curr);
      solve(2 * curr + 1);
    }
    atual = rb;
    return;
  }
};
int32_t main() {
  int n, q;
  cin >> n >> q;
  dcq<int> seg(n + 1);
  for (int i = 0; i < q; i++) {
    int l, r, x;
    cin >> l >> r >> x;
    seg.upd(l, r, x);
  }
  seg.solve();
  int cz = 0;
  for (int i = 1; i < (n + 1); ++i) cz += ans[i];
  cout << cz << endl;
  for (int i = 1; i < (n + 1); ++i) {
    if (ans[i]) cout << i << " ";
  }
  cout << endl;
}
