#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)1 << 62;
const long long MOD = 1e9 + 7;
const int iINF = 1 << 30;
const double PI = 3.14159265359;
struct intv {
  int i, tmx, tpe;
};
bool cmp(intv a, intv b) {
  if (a.tmx == b.tmx) {
    if (a.tpe == b.tpe) return a.i < b.i;
    return a.tpe < b.tpe;
  }
  return a.tmx < b.tmx;
}
void solve() {
  int n, m;
  cin >> n >> m;
  vector<intv> a;
  for (int i = 0; i < m; i++) {
    int x, l, r;
    cin >> x >> l >> r;
    a.push_back(intv{x - 1, l, 0});
    a.push_back(intv{x - 1, r, 1});
  }
  sort(a.begin(), a.end(), cmp);
  vector<vector<int> > adj(n);
  map<int, int> active;
  for (int i = 0; i < (int)a.size(); i++) {
    if (a[i].tpe == 0) {
      if (active.find(a[i].i) == active.end()) active[a[i].i] = 0;
      active[a[i].i]++;
      auto it = active.lower_bound(a[i].i);
      it++;
      if (it != active.end()) adj[a[i].i].push_back(it->first);
      it--;
      if (it != active.begin()) {
        it--;
        adj[it->first].push_back(a[i].i);
      }
    } else {
      if (active[a[i].i] == 1) {
        auto it = active.lower_bound(a[i].i);
        it++;
        int u = -1, v = -1;
        if (it != active.end()) v = it->first;
        it--;
        if (it != active.begin()) {
          it--;
          u = it->first;
        }
        if (u != -1 && v != -1) adj[u].push_back(v);
      }
      active[a[i].i]--;
      if (active[a[i].i] == 0) active.erase(active.find(a[i].i));
    }
  }
  vector<int> dp(n, 1);
  int strt = 0;
  for (int u = n - 1; u >= 0; u--) {
    for (int v : adj[u]) dp[u] = max(dp[u], dp[v] + 1);
    if (dp[u] > dp[strt]) strt = u;
  }
  set<int> taken;
  int curr = strt;
  taken.insert(curr);
  while ((int)taken.size() != dp[strt]) {
    int maxi = adj[curr][0];
    for (int v : adj[curr])
      if (dp[v] > dp[maxi]) maxi = v;
    curr = maxi;
    taken.insert(curr);
  }
  cout << n - taken.size() << "\n";
  for (int i = 0; i < n; i++) {
    if (taken.find(i) == taken.end()) cout << i + 1 << " ";
  }
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
