#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
template <class T>
inline void gn(T &x) {
  char c, sg = 0;
  while (c = getchar(), (c > '9' || c < '0') && c != '-')
    ;
  for ((c == '-' ? sg = 1, c = getchar() : 0), x = 0; c >= '0' && c <= '9';
       c = getchar())
    x = (x << 1) + (x << 3) + c - '0';
  if (sg) x = -x;
}
template <class T>
inline void print(T x) {
  if (x < 0) {
    putchar('-');
    return print(-x);
  }
  if (x < 10) {
    putchar('0' + x);
    return;
  }
  print(x / 10);
  putchar(x % 10 + '0');
}
template <class T, class T1>
inline void gn(T &x, T1 &y) {
  gn(x);
  gn(y);
}
template <class T, class T1, class T2>
inline void gn(T &x, T1 &y, T2 &z) {
  gn(x);
  gn(y);
  gn(z);
}
template <class T>
inline void println(T x) {
  print(x);
  putchar('\n');
}
template <class T>
inline void printsp(T x) {
  print(x);
  putchar(' ');
}
template <class T1, class T2>
inline void print(T1 x1, T2 x2) {
  printsp(x1), println(x2);
}
template <class T1, class T2, class T3>
inline void print(T1 x1, T2 x2, T3 x3) {
  printsp(x1), printsp(x2), println(x3);
}
template <class T1, class T2, class T3, class T4>
inline void print(T1 x1, T2 x2, T3 x3, T4 x4) {
  printsp(x1), printsp(x2), printsp(x3), println(x4);
}
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
int dp[10111];
struct segment {
  int l, r, x;
  segment(int l = 0, int r = 0, int x = 0) : l(l), r(r), x(x) {}
  void input() { gn(l, r, x); }
  bool operator<(const segment &u) const {
    if (r == u.r) return l < u.l;
    return r < u.r;
  }
} sg[10111];
vector<int> ans;
int main() {
  int n, q;
  gn(n, q);
  for (int i = 0; i < q; i++) sg[i].input();
  sort(sg, sg + q);
  for (int i = 0; i < q; i++) {
    for (int j = n; j >= 1; j--) {
      if (dp[j] >= sg[i].l and j + sg[i].x <= n) smax(dp[j + sg[i].x], dp[j]);
    }
    smax(dp[sg[i].x], sg[i].r);
  }
  for (int i = 1; i <= n; i++)
    if (dp[i]) ans.push_back(i);
  cout << ((int)ans.size()) << endl;
  for (int i = 0; i < ((int)ans.size()); i++) printsp(ans[i]);
  puts("");
  return 0;
}
