#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 5;
bitset<N> ans;
struct Seg {
  bitset<N> tree[N * 4];
  vector<int> lazy[N * 4];
  void init() {
    for (int i = 1; i < 4 * N; i++) tree[i] = 1;
  }
  void update(int p, int l, int r, int x, int y, int v) {
    if (x <= l && y >= r) {
      lazy[p].push_back(v);
      return;
    }
    int mid = l + r >> 1;
    if (x <= mid) update(p << 1, l, mid, x, y, v);
    if (y > mid) update(p << 1 | 1, mid + 1, r, x, y, v);
  }
  void pushdown(int p) {
    tree[p << 1] |= tree[p];
    tree[p << 1 | 1] |= tree[p];
  }
  void build(int p, int l, int r) {
    for (auto x : lazy[p]) {
      tree[p] |= (tree[p] << x);
    }
    if (l == r) {
      ans |= tree[p];
      return;
    }
    pushdown(p);
    int mid = l + r >> 1;
    build(p << 1, l, mid);
    build(p << 1 | 1, mid + 1, r);
  }
} seg;
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  seg.init();
  for (int i = 1; i <= q; i++) {
    int l, r, x;
    scanf("%d%d%d", &l, &r, &x);
    seg.update(1, 1, n, l, r, x);
  }
  seg.build(1, 1, n);
  int cnt = 0;
  for (int i = 1; i <= n; i++)
    if (ans.test(i)) cnt++;
  printf("%d\n", cnt);
  for (int i = 1; i <= n; i++)
    if (ans.test(i)) printf("%d ", i);
  return 0;
}
