#include <bits/stdc++.h>
using namespace std;
long long int powmod(long long int a, long long int e) {
  if (e == 0) return 1;
  long long int x = powmod(a * a % 1000000007, e >> 1);
  return e & 1 ? x * a % 1000000007 : x;
}
bitset<10001> ans, o;
vector<long long int> seg[50001];
void go(int low, int high, int index, int l, int h, int x) {
  if (low > h or l > high) return;
  if (low >= l and high <= h) {
    seg[index].push_back(x);
    return;
  }
  int mid = (low + high) / 2;
  go(low, mid, index * 2 + 1, l, h, x);
  go(mid + 1, high, index * 2 + 2, l, h, x);
}
void work(int low, int high, int index, bitset<10001> b) {
  for (long long int i = 0; i < seg[index].size(); i++) {
    b = b | (b << seg[index][i]);
  }
  if (low == high) {
    ans |= b;
    return;
  }
  int mid = (low + high) / 2;
  work(low, mid, index + index + 1, b);
  work(mid + 1, high, index + index + 2, b);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, q;
  cin >> n >> q;
  for (long long int i = 0; i < q; i++) {
    int l, r, x;
    cin >> l >> r >> x;
    go(1, n, 1, l, r, x);
  }
  o[0] = 1;
  int m = 0;
  work(1, n, 1, o);
  for (int i = 1; i <= n; i++) m += ans[i];
  cout << m << "\n";
  for (int i = 1; i <= n; i++)
    if (ans[i]) cout << i << " ";
}
