#include <bits/stdc++.h>
using namespace std;
const int N = 10005;
struct Q {
  int l, r, x;
  bool operator<(const Q &rhs) const { return r < rhs.r; }
} qs[N];
int n, q, dp[N];
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 0; i < q; i++) scanf("%d%d%d", &qs[i].l, &qs[i].r, &qs[i].x);
  sort(qs, qs + q);
  for (int i = 0; i < q; i++) {
    int l = qs[i].l, r = qs[i].r, v = qs[i].x;
    for (int j = n - v; j >= 1; j--) {
      if (dp[j] >= l) dp[j + v] = max(dp[j], dp[j + v]);
    }
    dp[v] = r;
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++)
    if (dp[i] > 0) ++cnt;
  printf("%d\n", cnt);
  for (int i = 1; i <= n; i++)
    if (dp[i] > 0) printf("%d ", i);
  puts("");
}
