#include <bits/stdc++.h>
using namespace std;
const int NR = 1e4;
const int PR = 19260817;
int n, q;
vector<int> adj1[NR + 1], adj2[NR + 1];
long long dp[NR + 1];
bool flag[NR + 1];
int main() {
  scanf("%d%d", &n, &q);
  int x, y, z;
  for (int i = 1; i <= q; i++) {
    scanf("%d%d%d", &x, &y, &z);
    adj1[x].push_back(z);
    adj2[y].push_back(z);
  }
  dp[0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < adj1[i].size(); j++) {
      for (int k = n; k >= adj1[i][j]; k--)
        dp[k] = (dp[k] + dp[k - adj1[i][j]]) % PR;
    }
    for (int j = 1; j <= n; j++) {
      if (dp[j] > 0) flag[j] = true;
    }
    for (int j = 0; j < adj2[i].size(); j++) {
      for (int k = adj2[i][j]; k <= n; k++)
        dp[k] = (dp[k] - dp[k - adj2[i][j]] + PR) % PR;
    }
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (flag[i]) cnt++;
  }
  printf("%d\n", cnt);
  for (int i = 1; i <= n; i++) {
    if (flag[i]) printf("%d ", i);
  }
  puts("");
  return 0;
}
