#include <bits/stdc++.h>
using namespace std;
int n, q;
int a[10001];
bitset<10001> t[10001];
bitset<10001> res, cur;
vector<int> adds[1000];
const int BLOCK = 100;
void build() {
  for (int i = 0; i < n; ++i) {
    t[i][0] = 1;
  }
}
void update(int l, int r, int value) {
  int block_l = l / BLOCK;
  int block_r = r / BLOCK;
  if (block_l == block_r) {
    for (int i = l; i <= r; ++i) {
      t[i] |= (t[i] << value);
    }
    return;
  }
  int end_block_l = (block_l + 1) * 100;
  int start_block_r = block_r * 100;
  for (int i = l; i < end_block_l; ++i) {
    t[i] |= (t[i] << value);
  }
  for (int i = start_block_r; i <= r; ++i) {
    t[i] |= (t[i] << value);
  }
  for (int i = block_l + 1; i < block_r; ++i) {
    adds[i].push_back(value);
  }
}
int main() {
  scanf("%d%d", &n, &q);
  build();
  for (int i = 0; i < q; ++i) {
    int l, r, x;
    scanf("%d%d%d", &l, &r, &x);
    --l;
    --r;
    update(l, r, x);
  }
  for (int i = 0; i < (n + BLOCK - 1) / BLOCK; ++i) {
    cur.reset();
    for (int j = i * BLOCK; j < (i + 1) * BLOCK; ++j) {
      cur |= t[j];
    }
    for (int x : adds[i]) {
      cur |= (cur << x);
    }
    res |= cur;
  }
  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    if (res[i]) {
      ++cnt;
    }
  }
  printf("%d\n", cnt);
  for (int i = 1; i <= n; ++i) {
    if (res[i]) {
      printf("%d ", i);
    }
  }
  printf("\n");
  return 0;
}
