#include <bits/stdc++.h>
using namespace std;
const int N = 12345;
bitset<N> cur, tmp[N * 4], ans;
vector<int> vec[N * 4];
int n, q;
void update(int o, int l, int r, int ql, int qr, int val) {
  if (l == ql && r == qr)
    vec[o].push_back(val);
  else {
    int mid = l + (r - l) / 2;
    if (qr <= mid)
      update(o * 2, l, mid, ql, qr, val);
    else if (ql > mid)
      update(o * 2 + 1, mid + 1, r, ql, qr, val);
    else {
      update(o * 2, l, mid, ql, mid, val);
      update(o * 2 + 1, mid + 1, r, mid + 1, qr, val);
    }
  }
}
void solve(int o, int l, int r) {
  tmp[o] = cur;
  for (int v : vec[o]) cur |= (cur << v);
  if (l == r)
    ans |= cur;
  else {
    int mid = l + (r - l) / 2;
    solve(o * 2, l, mid);
    solve(o * 2 + 1, mid + 1, r);
  }
  cur = tmp[o];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> q;
  for (int i = 0; i < q; i++) {
    int l, r, v;
    cin >> l >> r >> v;
    update(1, 1, n, l, r, v);
  }
  cur[0] = true;
  solve(1, 1, n);
  int tot = 0;
  for (int i = 1; i <= n; i++)
    if (ans[i]) tot++;
  cout << tot << '\n';
  for (int i = 1; i <= n; i++)
    if (ans[i]) cout << i << ' ';
  cout << '\n';
  return 0;
}
