#include <bits/stdc++.h>
using namespace std;
const int N = 10005, p1 = 998244353, p2 = 1000000009;
vector<int> s1[N], s2[N];
int f1[N], f2[N];
bool ans[N];
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= q; i++) {
    int l, r, v;
    scanf("%d%d%d", &l, &r, &v);
    s1[l].push_back(v);
    s2[r].push_back(v);
  }
  f1[0] = f2[0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < s1[i].size(); j++) {
      int x = s1[i][j];
      for (int k = n; k >= x; k--)
        f1[k] = (f1[k] + f1[k - x]) % p1, f2[k] = (f2[k] + f2[k - x]) % p2;
    }
    for (int j = 1; j <= n; j++) ans[j] |= f1[j] != 0 && f2[j] != 0;
    for (int j = 0; j < s2[i].size(); j++) {
      int x = s2[i][j];
      for (int k = x; k <= n; k++)
        f1[k] = (f1[k] - f1[k - x] + p1) % p1,
        f2[k] = (f2[k] - f2[k - x] + p2) % p2;
    }
  }
  int m = 0;
  for (int i = 1; i <= n; i++)
    if (ans[i]) m++;
  printf("%d\n", m);
  for (int i = 1; i <= n; i++)
    if (ans[i]) printf("%d ", i);
}
