#include <bits/stdc++.h>
using namespace std;
int const maxn = 1e4 + 10;
int n, Q;
vector<int> tree[maxn << 2];
bitset<maxn> vis, ans, tmp[maxn << 2];
void up(int x, int l, int r, int ul, int ur, int w) {
  if (ul <= l && ur >= r) {
    tree[x].push_back(w);
    return;
  }
  int mid = l + r >> 1, rson = x << 1 | 1, lson = x << 1;
  if (ul <= mid) up(lson, l, mid, ul, ur, w);
  if (ur > mid) up(rson, mid + 1, r, ul, ur, w);
}
void q(int x, int l, int r) {
  tmp[x] = vis;
  for (auto l : tree[x]) vis |= vis << l;
  if (l == r) {
    ans |= vis;
    vis = tmp[x];
    return;
  }
  int mid = l + r >> 1, rson = x << 1 | 1, lson = x << 1;
  q(lson, l, mid);
  q(rson, mid + 1, r);
  vis = tmp[x];
}
int main() {
  scanf("%d%d", &n, &Q);
  for (int i = 1; i <= Q; i++) {
    int l, r, w;
    scanf("%d%d%d", &l, &r, &w);
    up(1, 1, n, l, r, w);
  }
  vis[0] = 1;
  q(1, 1, n);
  int sum = 0;
  for (int i = 1; i <= n; i++)
    if (ans[i]) sum++;
  printf("%d\n", sum);
  for (int i = 1; i <= n; i++)
    if (ans[i]) printf("%d ", i);
  printf("\n");
}
