#include <bits/stdc++.h>
using namespace std;
pair<int, int> operator+(const pair<int, int> &a, const pair<int, int> &b) {
  pair<int, int> re = {a.first + b.first, a.second + b.second};
  if (re.first >= 1000000021) re.first -= 1000000021;
  if (re.second >= 1000000033) re.second -= 1000000033;
  return re;
}
pair<int, int> operator-(const pair<int, int> &a, const pair<int, int> &b) {
  pair<int, int> re = {a.first + 1000000021 - b.first,
                       a.second + 1000000033 - b.second};
  if (re.first >= 1000000021) re.first -= 1000000021;
  if (re.second >= 1000000033) re.second -= 1000000033;
  return re;
}
int n, q, ta, tb, tc;
bool hv[10005];
vector<int> ans;
vector<int> add[10005];
vector<int> sub[10005];
pair<int, int> dp[10005];
int main() {
  scanf("%d%d", &n, &q);
  while (q--) {
    scanf("%d%d%d", &ta, &tb, &tc);
    add[ta - 1].push_back(tc);
    sub[tb].push_back(tc);
  }
  dp[0] = {1, 1};
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < add[i].size(); j++)
      for (int k = n; k >= add[i][j]; k--) dp[k] = dp[k] + dp[k - add[i][j]];
    for (int j = 0; j < sub[i].size(); j++)
      for (int k = sub[i][j]; k <= n; k++) dp[k] = dp[k] - dp[k - sub[i][j]];
    for (int j = 1; j <= n; j++)
      if (dp[j].first || dp[j].second) hv[j] = 1;
  }
  for (int i = 1; i <= n; i++)
    if (hv[i]) ans.push_back(i);
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++)
    printf("%d%c", ans[i], i == ans.size() - 1 ? '\n' : ' ');
  return 0;
}
