#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 50;
bitset<10005> bit[40005];
int n, q;
struct segment_tree {
  vector<int> lazy[maxn << 2];
  struct node {
    int l, r;
  } tree[maxn << 2];
  void build(int p, int l, int r) {
    tree[p].l = l, tree[p].r = r;
    if (l == r) {
      bit[p][0] = 1;
      return;
    }
    int mid = (l + r) >> 1;
    build(p << 1, l, mid);
    build(p << 1 | 1, mid + 1, r);
  }
  void update(int p, int l, int r, int ql, int qr, int v) {
    if (ql <= l && r <= qr) {
      lazy[p].push_back(v);
      return;
    }
    int mid = (l + r) >> 1;
    if (qr <= mid)
      update(p << 1, l, mid, ql, qr, v);
    else if (mid < ql)
      update(p << 1 | 1, mid + 1, r, ql, qr, v);
    else {
      update(p << 1, l, mid, ql, qr, v);
      update(p << 1 | 1, mid + 1, r, ql, qr, v);
    }
  }
  void query(int p, int l, int r) {
    if (tree[p].l == tree[p].r) {
      for (int i = 0; i < lazy[p].size(); i++) {
        int v = lazy[p][i];
        bit[p] |= (bit[p] << v);
      }
      return;
    }
    int mid = (l + r) >> 1;
    query(p << 1, l, mid);
    query(p << 1 | 1, mid + 1, r);
    bit[p] |= bit[p << 1], bit[p] |= bit[p << 1 | 1];
    for (int i = 0; i < lazy[p].size(); i++) {
      int v = lazy[p][i];
      bit[p] |= (bit[p] << v);
    }
  }
} T;
int main() {
  scanf("%d%d", &n, &q);
  T.build(1, 1, n);
  for (int i = 1; i <= q; i++) {
    int l, r, c;
    scanf("%d%d%d", &l, &r, &c);
    T.update(1, 1, n, l, r, c);
  }
  T.query(1, 1, n);
  int ans = 0;
  for (int i = 1; i <= n; i++)
    if (bit[1][i]) ans++;
  printf("%d\n", ans);
  for (int i = 1; i <= n; i++)
    if (bit[1][i]) printf("%d ", i);
  puts("");
  return 0;
}
