#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 10;
const int MOD0 = 1e9 + 7;
const int MOD1 = 1e9 + 9;
int n, q, l[N], r, x[N], dp[N][2];
vector<int> vec[N];
bool ok[N];
inline void fix(int &x, int mod) {
  if (x >= mod) x -= mod;
  if (x < 0) x += mod;
}
inline void add(int ind, int val, bool b) {
  dp[ind][b] += val;
  fix(dp[ind][0], MOD0);
  fix(dp[ind][1], MOD1);
}
int save[N][2];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  dp[0][0] = dp[0][1] = 1;
  for (int i = 0; i < q; i++) {
    cin >> l[i] >> r >> x[i];
    vec[--l[i]].push_back(i);
    vec[r].push_back(i);
  }
  for (int i = 0; i < n; i++)
    for (auto &ind : vec[i]) {
      if (l[ind] == i)
        for (int j = n; j >= x[ind]; j--) {
          int val1 = dp[j - x[ind]][0];
          int val2 = dp[j - x[ind]][1];
          add(j, val1, 0);
          add(j, val2, 1);
          if (dp[j][0] > 0 || dp[j][1] > 0) ok[j] = 1;
        }
      if (l[ind] != i)
        for (int j = x[ind]; j <= n; j++) {
          int val1 = -dp[j - x[ind]][0];
          int val2 = -dp[j - x[ind]][1];
          add(j, val1, 0);
          add(j, val2, 1);
        }
    }
  int res = 0;
  for (int i = 1; i <= n; i++) res += ok[i];
  cout << res << "\n";
  for (int i = 1; i <= n; i++)
    if (ok[i]) cout << i << " ";
  return 0;
}
