#include <bits/stdc++.h>
using namespace std;
vector<int> e[10010], a[10010];
const long long MOD = 804212830686677669;
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 0; i < q; i++) {
    int l, r, x;
    scanf("%d%d%d", &l, &r, &x);
    a[l - 1].push_back(x);
    e[r].push_back(x);
  }
  vector<long long> w(n + 1);
  vector<int> ans(n + 1);
  int c = 0;
  for (int i = 0; i < n; i++) {
    for (int x : e[i]) {
      w[x]--;
      if (w[x] < 0) w[x] += MOD;
      for (int j = x + 1; j <= n; j++) {
        w[j] -= w[j - x];
        if (w[j] < 0) w[j] += MOD;
      }
    }
    for (int x : a[i]) {
      for (int j = n; j > x; j--) {
        w[j] += w[j - x];
        if (w[j] >= MOD) w[j] -= MOD;
      }
      w[x]++;
    }
    for (int i = 1; i <= n; i++) {
      if (w[i] && !ans[i]) ans[i] = 1, c++;
    }
    if (c == n) break;
  }
  cout << c << endl;
  bool f = 1;
  for (int i = 1; i <= n; i++) {
    if (ans[i]) {
      if (!f)
        printf(" ");
      else
        f = 0;
      printf("%d", i);
    }
  }
  puts("");
}
