#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 1;
int dp[N] = {1}, n, Q, last;
bool ans[N];
struct lol {
  int id, val;
  bool what;
  lol(int a = 0, int b = 0, bool c = 0) {
    id = a;
    val = b;
    what = c;
  }
  bool operator<(const lol& a) const {
    if (id != a.id) return id < a.id;
    return what < a.what;
  }
} q[2 * N];
void add(int val) {
  for (int i = n; i >= val; i--) {
    dp[i] += dp[i - val];
    if (dp[i]) ans[i] = 1;
  }
}
void rem(int val) {
  for (int i = val; i <= n; i++) dp[i] -= dp[i - val];
}
int main() {
  scanf("%d%d", &n, &Q);
  for (int i = 0, l, r, x; i < Q; i++) {
    scanf("%d%d%d", &l, &r, &x);
    q[last++] = lol(l, x, 0);
    q[last++] = lol(r, x, 1);
  }
  sort(q, q + last);
  for (int i = 0; i < last; i++)
    if (!q[i].what)
      add(q[i].val);
    else
      rem(q[i].val);
  Q = 0;
  for (int i = 1; i <= n; i++) Q += ans[i];
  printf("%d\n", Q);
  for (int i = 1; i <= n; i++)
    if (ans[i]) printf("%d ", i);
}
