#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chkmin(T &x, T y) {
  return y < x ? x = y, 1 : 0;
}
template <class T>
inline bool chkmax(T &x, T y) {
  return x < y ? x = y, 1 : 0;
}
inline long long Max(long long x, long long y) { return x > y ? x : y; }
inline long long Min(long long x, long long y) { return x < y ? x : y; }
int n, m;
struct ask {
  int l, r, x;
  bool operator<(const ask &_) const { return l < _.l; }
} Q[10002];
struct node {
  int r;
  bool f;
} dp[10002];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (1), i_end_ = (m); i <= i_end_; i++)
    scanf("%d%d%d", &Q[i].l, &Q[i].r, &Q[i].x);
  sort(Q + 1, Q + 1 + m);
  for (int i = (1), i_end_ = (n); i <= i_end_; i++) dp[i] = (node){0, 0};
  dp[0] = (node){n, 1};
  for (int i = (1), i_end_ = (m); i <= i_end_; i++) {
    for (int j = (n), j_end_ = (Q[i].x); j >= j_end_; j--) {
      int dx = j - Q[i].x;
      if (!dp[dx].f) continue;
      if (dp[dx].r >= Q[i].l)
        dp[j] = (node){max(dp[j].r, min(dp[dx].r, Q[i].r)), 1};
    }
  }
  int ans = 0;
  for (int i = (1), i_end_ = (n); i <= i_end_; i++) ans += dp[i].f;
  printf("%d\n", ans);
  for (int i = (1), i_end_ = (n); i <= i_end_; i++)
    if (dp[i].f) printf("%d%c", i, i < n ? ' ' : '\n');
  return 0;
}
