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