#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int MAXN = 1e4 + 1;
int n, q;
vector<int> w[4 * MAXN];
bitset<MAXN> res;
void setquery(int v, int l, int r, int L, int R, int x) {
  if (r < L || R < l || R < L) return;
  if (L <= l && r <= R) {
    w[v].push_back(x);
    return;
  }
  int m = (l + r) / 2;
  setquery(2 * v, l, m, L, R, x);
  setquery(2 * v + 1, m + 1, r, L, R, x);
}
void solve(int v, int l, int r, bitset<MAXN> b) {
  for (auto x : w[v]) {
    b |= b << x;
  }
  if (l == r) {
    res |= b;
  } else {
    int m = (l + r) / 2;
    solve(2 * v, l, m, b);
    solve(2 * v + 1, m + 1, r, b);
  }
}
int32_t main() {
  scanf("%d%d", &n, &q);
  for (int i = 0; i < q; i++) {
    int l, r, x;
    scanf("%d%d%d", &l, &r, &x);
    setquery(1, 1, n, l, r, x);
  }
  bitset<MAXN> b;
  b[0] = 1;
  solve(1, 1, n, b);
  vector<int> ans;
  for (int i = 1; i <= n; i++) {
    if (res[i]) ans.push_back(i);
  }
  cout << ans.size() << "\n";
  for (auto x : ans) {
    cout << x << ' ';
  }
}
