#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
  x = 0;
  char c;
  for (c = getchar(); !isdigit(c); c = getchar())
    ;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
}
const int N = 1e4 + 50;
int n, q, m;
vector<int> tr[N << 2];
bitset<N> ans, stk[50];
void update(int v, int l, int r, int s, int t, int x) {
  if (r < s || l > t)
    ;
  else if (s <= l && r <= t) {
    tr[v].push_back(x);
  } else {
    int mid = (l + r) >> 1;
    update(v << 1, l, mid, s, t, x);
    update(v << 1 ^ 1, mid + 1, r, s, t, x);
  }
}
void query(int v, int l, int r, int d) {
  stk[d] = stk[d - 1];
  for (int x : tr[v]) {
    stk[d] |= stk[d] << x;
  }
  if (l == r) {
    ans |= stk[d];
  } else {
    int mid = (l + r) >> 1;
    query(v << 1, l, mid, d + 1);
    query(v << 1 ^ 1, mid + 1, r, d + 1);
  }
}
int main(int argc, char *argv[]) {
  scanf("%d%d", &n, &q);
  for (int k = 1; k <= (q); ++k) {
    int l, r, x;
    scanf("%d%d%d", &l, &r, &x);
    update(1, 1, n, l, r, x);
  }
  stk[0][0] = 1;
  query(1, 1, n, 1);
  for (int i = 1; i <= (n); ++i)
    if (ans[i] == 1) ++m;
  printf("%d\n", m);
  for (int i = 1; i <= (n); ++i)
    if (ans[i] == 1) printf("%d ", i);
  puts("");
  return 0;
}
