#include <bits/stdc++.h>
using namespace std;
vector<int> vec[10010 << 2];
void Change(int k, int l, int r, int x, int y, int z) {
  if (x <= l && r <= y) {
    vec[k].push_back(z);
    return;
  }
  int mid = l + r >> 1;
  if (x <= mid) Change(k << 1, l, mid, x, y, z);
  if (mid < y) Change(k << 1 | 1, mid + 1, r, x, y, z);
}
bitset<10010> now, ans;
void Down(int k, int l, int r) {
  bitset<10010> tmp;
  tmp = now;
  int t = vec[k].size();
  for (int i = 0; i < t; ++i) now |= (now << vec[k][i]);
  if (l == r) {
    ans |= now;
    now = tmp;
    return;
  }
  int mid = l + r >> 1;
  Down(k << 1, l, mid);
  Down(k << 1 | 1, mid + 1, r);
  now = tmp;
}
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  while (q--) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    Change(1, 1, n, x, y, z);
  }
  now = 1;
  Down(1, 1, n);
  for (int i = 1; i <= n; ++i)
    if (ans[i]) vec[0].push_back(i);
  int t = vec[0].size();
  printf("%d\n", t);
  for (int i = 0; i < t; ++i) printf("%d ", vec[0][i]);
}
