#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimization("unroll-loops")
long long md = 1000000007;
using namespace std;
template <typename T>
T pw(T a, T b) {
  T c = 1, m = a;
  while (b) {
    if (b & 1) c = (c * m);
    m = (m * m), b /= 2;
  }
  return c;
}
template <typename T>
T ceel(T a, T b) {
  if (a % b == 0)
    return a / b;
  else
    return a / b + 1;
}
template <typename T>
T my_log(T n, T b) {
  T i = 1, ans = 0;
  while (1) {
    if (i > n) {
      ans--;
      break;
    }
    if (i == n) break;
    i *= b, ans++;
  }
  return ans;
}
template <typename T>
T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long pwmd(long long a, long long b) {
  long long c = 1, m = a;
  while (b) {
    if (b & 1) c = (c * m) % md;
    m = (m * m) % md;
    b /= 2;
  }
  return c;
}
long long modinv(long long n) { return pwmd(n, md - 2); }
long long inverse(long long i) {
  if (i == 1) return 1;
  return (md - ((md / i) * inverse(md % i)) % md + md) % md;
}
bool sortbysec(const pair<long long, long long> &a,
               const pair<long long, long long> &b) {
  return (a.second < b.second);
}
long long n;
vector<long long> dp(100001);
vector<long long> ad[10005], del[10005];
long long MOD = 1000000007;
void add(long long x) {
  for (long long i = n - x; i >= 0; i--) dp[i + x] = (dp[i + x] + dp[i]) % MOD;
}
void delet(long long x) {
  for (long long i = x; i < n + 1; i++)
    dp[i] = (dp[i] - dp[i - x] + 2 * MOD) % MOD;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long l, r, x, y, q;
  cin >> n >> q;
  for (long long i = 0; i < q; i++) {
    cin >> l >> r >> x;
    l--, r--;
    ad[l].push_back(x), del[r + 1].push_back(x);
  }
  dp[0] = 1;
  vector<long long> vis(n + 1);
  for (long long i = 0; i < n; i++) {
    for (auto e : ad[i]) add(e);
    for (auto e : del[i]) delet(e);
    for (long long j = 1; j < n + 1; j++)
      if (dp[j]) vis[j] = 1;
  }
  vector<long long> ans;
  for (long long i = 1; i < n + 1; i++)
    if (vis[i]) ans.push_back(i);
  cout << ans.size() << "\n";
  for (auto e : ans) cout << e << " ";
}
