#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e4 + 5;
struct seg {
  vector<int> E[MAXN << 2];
  void update(int L, int R, int val, int l, int r, int rt) {
    if (L <= l && r <= R) {
      E[rt].push_back(val);
      return;
    }
    int mid = (l + r) >> 1;
    if (L <= mid) update(L, R, val, l, mid, rt << 1);
    if (mid < R) update(L, R, val, mid + 1, r, rt << 1 | 1);
  }
} se;
bitset<MAXN> book[MAXN << 2], cur, ans;
void dfs(int l, int r, int now) {
  book[now] = cur;
  for (auto i : se.E[now]) cur |= (cur << i);
  ans |= cur;
  if (l == r) return;
  int mid = (l + r) >> 1;
  dfs(l, mid, now << 1);
  dfs(mid + 1, r, now << 1 | 1);
  cur = book[now];
}
vector<int> res;
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= q; i++) {
    int l, r, x;
    scanf("%d%d%d", &l, &r, &x);
    se.update(l, r, x, 1, n, 1);
  }
  cur = 1;
  dfs(1, n, 1);
  for (int i = 1; i <= n; i++)
    if (ans[i]) res.push_back(i);
  printf("%d\n", int(res.size()));
  for (auto i : res) printf("%d ", i);
  printf("\n");
  return 0;
}
