#include <bits/stdc++.h>
using namespace std;
int N, Q;
int dp[10005];
vector<int> Adj0[10005], Adj1[10005];
bool ans[10005];
void printDP() {
  cout << "%%%%%%% coutDP" << endl;
  for (int i = 1; i <= N; i++) cout << dp[i] << " ";
  cout << endl;
}
int main() {
  cin >> N >> Q;
  int l, r, x;
  for (int i = 1; i <= Q; i++) {
    cin >> l >> r >> x;
    Adj0[l].push_back(x);
    Adj1[r + 1].push_back(x);
  }
  dp[0] = 1;
  for (int i = 1; i <= N; i++) {
    for (int k = 0; k < Adj1[i].size(); k++) {
      x = Adj1[i][k];
      for (int j = 1; j <= N; j++) {
        if (x <= j) dp[j] -= dp[j - x];
      }
    }
    for (int k = 0; k < Adj0[i].size(); k++) {
      x = Adj0[i][k];
      for (int j = N; j >= 1; j--) {
        if (x <= j) dp[j] += dp[j - x];
        ans[j] |= dp[j];
      }
    }
  }
  int cnt = 0;
  for (int i = 1; i <= N; i++) {
    if (ans[i]) cnt++;
  }
  cout << cnt << endl;
  for (int i = 1; i <= N; i++) {
    if (ans[i]) cout << i << " ";
  }
  return 0;
}
