#include <bits/stdc++.h>
const int m1 = 514514527, m2 = 527527514;
const int sz = 10010;
int dp[sz][2];
struct ele {
  long long x, y, c;
} a[sz];
bool ok[sz];
bool cmp(ele p, ele q) { return p.x < q.x; }
std::vector<long long> del[sz];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int k = 1; k <= m; k++) {
    scanf("%lld%lld%lld", &a[k].x, &a[k].y, &a[k].c);
  }
  std::sort(a + 1, a + m + 1, cmp);
  int in = 1;
  dp[0][0] = dp[0][1] = 1;
  for (int k = 1; k <= n; k++) {
    for (int i = in; i <= m; i++) {
      if (a[i].x > k) {
        break;
      }
      in++;
      long long c = a[i].c;
      for (int i = n; i >= c; i--) {
        dp[i][0] += dp[i - c][0];
        dp[i][0] %= m1;
        dp[i][1] += dp[i - c][1];
        dp[i][1] %= m2;
      }
      del[a[i].y + 1].push_back(c);
    }
    for (int i = 0; i < del[k].size(); i++) {
      long long c = del[k][i];
      for (int i = c; i <= n; i++) {
        dp[i][0] -= dp[i - c][0];
        dp[i][0] %= m1;
        dp[i][1] -= dp[i - c][1];
        dp[i][1] %= m2;
      }
    }
    for (int i = 1; i <= n; i++) {
      if (dp[i][0] != 0 || dp[i][1] != 0) ok[i] = true;
    }
  }
  int ans = 0;
  for (int k = 1; k <= n; k++)
    if (ok[k]) ans++;
  printf("%d\n", ans);
  for (int k = 1; k <= n; k++) {
    if (ok[k]) printf("%d ", k);
  }
}
