#include <bits/stdc++.h>
using namespace std;
int n, q, x, y, val;
unsigned long long dp[10005];
bool obt[10005];
vector<int> vdel[10005], vadd[10005];
vector<int> ans;
void updp(int now, int mul) {
  if (mul > 0) {
    for (int i : vadd[now]) {
      for (int j = n; j >= i; j--) {
        dp[j] += dp[j - i];
        if (dp[j] || dp[j - i]) obt[j] = 1;
      }
    }
  } else {
    for (int i : vdel[now]) {
      for (int j = i; j <= n; j++) {
        dp[j] -= dp[j - i];
      }
    }
  }
}
int main() {
  dp[0] = 1;
  scanf("%d %d", &n, &q);
  for (int i = 1; i <= q; i++) {
    scanf("%d %d %d", &x, &y, &val);
    vadd[x].push_back(val);
    vdel[y + 1].push_back(val);
  }
  for (int i = 1; i <= n; i++) {
    updp(i, -1);
    updp(i, 1);
  }
  for (int i = 1; i <= n; i++) {
    if (obt[i]) ans.push_back(i);
  }
  sort(ans.begin(), ans.end());
  printf("%d\n", (int)ans.size());
  for (int i : ans) printf("%d ", i);
}
