#include <bits/stdc++.h>
const int MAXN = 1e4 + 10;
using namespace std;
vector<int> vec[MAXN << 2];
int vul, n, q;
void update(int rt, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr) {
    vec[rt].push_back(vul);
    return;
  }
  int mid = (l + r) >> 1;
  if (ql <= mid) update(rt << 1, l, mid, ql, qr);
  if (qr > mid) update(rt << 1 | 1, mid + 1, r, ql, qr);
}
bitset<MAXN> ans;
bitset<MAXN> sum;
void querty(int rt, int l, int r, bitset<MAXN> num) {
  for (int i = 0; i < vec[rt].size(); i++) num |= (num << vec[rt][i]);
  if (l == r) {
    ans |= num;
    return;
  }
  int mid = (l + r) >> 1;
  querty(rt << 1, l, mid, num);
  querty(rt << 1 | 1, mid + 1, r, num);
}
int main() {
  n, q;
  scanf("%d%d", &n, &q);
  int l, r;
  for (int i = 1; i <= q; i++) {
    scanf("%d%d%d", &l, &r, &vul);
    update(1, 1, n, l, r);
  }
  sum[0] = 1;
  querty(1, 1, n, sum);
  int cnt = 0;
  for (int i = 1; i <= n; i++)
    if (ans[i]) cnt++;
  printf("%d\n", cnt);
  for (int i = 1; i <= n; i++) {
    if (ans[i]) printf("%d ", i);
  }
  puts("");
  return 0;
}
