#include <bits/stdc++.h>
using namespace std;
const int limit = 10005;
const int primero = 1 << 14;
const int tope = 1 << 15;
bitset<limit> v[tope];
vector<int> lista[tope];
void insert(int pos, int l, int r, int L, int R, int x) {
  if (r < L or R - 1 < l) return;
  if (l <= L and R - 1 <= r) {
    lista[pos].push_back(x);
    return;
  }
  int med = (L + R) / 2;
  insert(2 * pos, l, r, L, med, x);
  insert(2 * pos + 1, l, r, med, R, x);
}
void insert(int l, int r, int x) { insert(1, l, r, 0, primero, x); }
int n, cases;
int main() {
  cin >> n >> cases;
  for (int cas = 0; cas < cases; cas++) {
    int l, r, x;
    cin >> l >> r >> x;
    insert(l, r, x);
  }
  for (int i = tope - 1; i >= 1; i--) {
    if (i < primero)
      v[i] = v[2 * i] | v[2 * i + 1];
    else
      v[i][0] = 1;
    vector<int> &lis = lista[i];
    for (int j = 0; j < int(lis.size()); j++) {
      int x = lis[j];
      v[i] |= v[i] << x;
    }
  }
  bitset<limit> m = v[1];
  vector<int> sol;
  for (int i = 1; i <= n; i++)
    if (m[i]) sol.push_back(i);
  cout << int(sol.size()) << endl;
  for (int i = 0; i < int(sol.size()); i++) {
    if (i > 0) cout << " ";
    cout << sol[i];
  }
  cout << endl;
}
