#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 2e9;
const long long LINF = 4e18;
const int N = 1e4 + 20;
bitset<N> seg[4 * N], ans;
vector<int> seg1[4 * N], t;
int n, q;
void insert(int x, int y, int val, int id = 1, int l = 0, int r = n) {
  if (y <= l || r <= x) return;
  if (x <= l && r <= y) {
    seg1[id].push_back(val);
    return;
  }
  int mid = (l + r) / 2;
  insert(x, y, val, 2 * id, l, mid);
  insert(x, y, val, 2 * id + 1, mid, r);
}
void goDown(int id = 1, int l = 0, int r = n, int p = 0) {
  seg[id] = seg[p];
  seg[id].set(0);
  for (int x : seg1[id]) seg[id] |= seg[id] << x;
  if (r - l < 2) {
    ans |= seg[id];
    return;
  }
  int mid = (l + r) / 2;
  goDown(2 * id, l, mid, id);
  goDown(2 * id + 1, mid, r, id);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  for (int i = 0, l, r, x; i < q; i++) {
    cin >> l >> r >> x;
    insert(l - 1, r, x);
  }
  goDown();
  for (int i = 1; i <= n; i++)
    if (ans[i]) t.push_back(i);
  cout << t.size() << endl;
  for (int x : t) cout << x << ' ';
  cout << endl;
}
