#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
const int inf = INT_MAX;
const long long inff = 1e18;
const int mod = 1e9 + 123;
int n, q, l, r, x;
int dp[10007], ans[10007];
vector<int> v[10007];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  dp[0] = 1;
  cin >> n >> q;
  for (int i = 1; i <= q; i++) {
    cin >> l >> r >> x;
    v[l].push_back(x);
    v[r + 1].push_back(-x);
  }
  for (int i = 1; i <= n; i++) {
    for (int j : v[i]) {
      if (j > 0) {
        for (int k = n; k >= 0; k--) {
          if (k >= j) dp[k] = (dp[k] + dp[k - j]) % mod;
        }
      } else {
        for (int k = 0; k <= n; k++) {
          if (k >= -j) dp[k] = (dp[k] + mod - dp[k + j]) % mod;
        }
      }
    }
    for (int j = 0; j <= n; j++)
      if (dp[j] > 0) ans[j] = 1;
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++) cnt += ans[i];
  cout << cnt << '\n';
  for (int i = 1; i <= n; i++)
    if (ans[i] > 0) cout << i << ' ';
}
