#include <bits/stdc++.h>
using std::vector;
struct op {
  int val;
  int pos;
  op() { val = pos = 0; }
};
op max(op u, op v) {
  if (u.val > v.val)
    return u;
  else
    return v;
}
struct SegmentT {
  int l, r;
  op d;
  op c;
};
SegmentT t[4000005];
struct Element {
  int l, r;
};
int a[1000005];
vector<Element> g[300005];
int nxt[300005];
int vis[300005];
int preWork(int n) {
  std::sort(a + 1, a + 1 + n);
  int p = 1, size = 0;
  while (p <= n) {
    int np = p;
    while (np + 1 <= n && a[np + 1] == a[p]) np++;
    a[++size] = a[p];
    p = np + 1;
  }
  return size;
}
int getID(int u, int n) {
  int L = 1, R = n;
  int res = -1;
  while (L <= R) {
    int M = (L + R) / 2;
    if (a[M] <= u) {
      res = M;
      L = M + 1;
    } else
      R = M - 1;
  }
  return res;
}
int max(int a, int b) { return a > b ? a : b; }
void build(int p, int l, int r) {
  t[p].l = l, t[p].r = r;
  t[p].c.val = t[p].c.pos = 0;
  if (l == r)
    t[p].d.val = t[p].d.pos = 0;
  else {
    int m = (l + r) / 2;
    build(2 * p, l, m);
    build(2 * p + 1, m + 1, r);
    t[p].d = max(t[2 * p].d, t[2 * p + 1].d);
  }
}
void spread(int p) {
  if (t[p].c.val != 0) {
    op c = t[p].c;
    t[p].c.val = t[p].c.pos = 0;
    t[2 * p].d = max(t[2 * p].d, c);
    t[2 * p].c = max(t[2 * p].c, c);
    t[2 * p + 1].d = max(t[2 * p + 1].d, c);
    t[2 * p + 1].c = max(t[2 * p + 1].c, c);
  }
}
void change(int p, int l, int r, op v) {
  if (l <= t[p].l && r >= t[p].r) {
    t[p].d = max(t[p].d, v);
    t[p].c = max(t[p].c, v);
  } else {
    spread(p);
    int m = (t[p].l + t[p].r) / 2;
    if (l <= m) change(2 * p, l, r, v);
    if (r >= m + 1) change(2 * p + 1, l, r, v);
    t[p].d = max(t[2 * p].d, t[2 * p + 1].d);
  }
}
op ask(int p, int l, int r) {
  if (l <= t[p].l && r >= t[p].r)
    return t[p].d;
  else {
    spread(p);
    op res;
    res.val = res.pos = 0;
    int m = (t[p].l + t[p].r) / 2;
    if (l <= m) res = max(res, ask(2 * p, l, r));
    if (r >= m + 1) res = max(res, ask(2 * p + 1, l, r));
    return res;
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int size = 0;
  for (int i = 0; i < m; i++) {
    int r, x, y;
    scanf("%d%d%d", &r, &x, &y);
    a[++size] = x;
    a[++size] = y + 1;
    g[r].push_back(Element{x, y});
  }
  size = preWork(size);
  build(1, 1, size);
  int ans = 1, id = 1;
  for (int i = n; i >= 1; i--) {
    int val = 1;
    nxt[i] = 0;
    for (Element e : g[i]) {
      int l = e.l, r = e.r;
      int x = getID(l, size);
      int y = getID(r, size);
      op offer = ask(1, x, y);
      if (val < offer.val + 1) {
        val = offer.val + 1;
        nxt[i] = offer.pos;
      }
    }
    if (ans < val) {
      ans = val;
      id = i;
    }
    for (Element e : g[i]) {
      int l = e.l, r = e.r;
      int x = getID(l, size);
      int y = getID(r, size);
      op now;
      now.val = val, now.pos = i;
      change(1, x, y, now);
    }
  }
  int p = id;
  while (p != 0) {
    vis[p] = 1;
    p = nxt[p];
  }
  printf("%d\n", n - ans);
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) printf("%d ", i);
  }
  printf("\n");
  return 0;
}

### Prompt

Construct a cpp code solution to the problem outlined:

Moamen was drawing a grid of n rows and 10^9 columns containing only digits 0 and 1. Ezzat noticed what Moamen was drawing and became interested in the minimum number of rows one needs to remove to make the grid beautiful.

A grid is beautiful if and only if for every two consecutive rows there is at least one column containing 1 in these two rows.

Ezzat will give you the number of rows n, and m segments of the grid that contain digits 1. Every segment is represented with three integers i, l, and r, where i represents the row number, and l and r represent the first and the last column of the segment in that row.

For example, if n = 3, m = 6, and the segments are (1,1,1), (1,7,8), (2,7,7), (2,15,15), (3,1,1), (3,15,15), then the grid is:

<image>

Your task is to tell Ezzat the minimum number of rows that should be removed to make the grid beautiful.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 3⋅10^5).

Each of the next m lines contains three integers i, l, and r (1 ≤ i ≤ n, 1 ≤ l ≤ r ≤ 10^9). Each of these m lines means that row number i contains digits 1 in columns from l to r, inclusive.

Note that the segments may overlap.

Output

In the first line, print a single integer k — the minimum number of rows that should be removed.

In the second line print k distinct integers r_1, r_2, …, r_k, representing the rows that should be removed (1 ≤ r_i ≤ n), in any order.

If there are multiple answers, print any.

Examples

Input


3 6
1 1 1
1 7 8
2 7 7
2 15 15
3 1 1
3 15 15


Output


0


Input


5 4
1 2 3
2 4 6
3 3 5
5 1 1


Output


3
2 4 5

Note

In the first test case, the grid is the one explained in the problem statement. The grid has the following properties: 

  1. The 1-st row and the 2-nd row have a common 1 in the column 7. 
  2. The 2-nd row and the 3-rd row have a common 1 in the column 15. 

As a result, this grid is beautiful and we do not need to remove any row.

In the second test case, the given grid is as follows: 

<image>

### Response

```cpp
#include <bits/stdc++.h>
using std::vector;
struct op {
  int val;
  int pos;
  op() { val = pos = 0; }
};
op max(op u, op v) {
  if (u.val > v.val)
    return u;
  else
    return v;
}
struct SegmentT {
  int l, r;
  op d;
  op c;
};
SegmentT t[4000005];
struct Element {
  int l, r;
};
int a[1000005];
vector<Element> g[300005];
int nxt[300005];
int vis[300005];
int preWork(int n) {
  std::sort(a + 1, a + 1 + n);
  int p = 1, size = 0;
  while (p <= n) {
    int np = p;
    while (np + 1 <= n && a[np + 1] == a[p]) np++;
    a[++size] = a[p];
    p = np + 1;
  }
  return size;
}
int getID(int u, int n) {
  int L = 1, R = n;
  int res = -1;
  while (L <= R) {
    int M = (L + R) / 2;
    if (a[M] <= u) {
      res = M;
      L = M + 1;
    } else
      R = M - 1;
  }
  return res;
}
int max(int a, int b) { return a > b ? a : b; }
void build(int p, int l, int r) {
  t[p].l = l, t[p].r = r;
  t[p].c.val = t[p].c.pos = 0;
  if (l == r)
    t[p].d.val = t[p].d.pos = 0;
  else {
    int m = (l + r) / 2;
    build(2 * p, l, m);
    build(2 * p + 1, m + 1, r);
    t[p].d = max(t[2 * p].d, t[2 * p + 1].d);
  }
}
void spread(int p) {
  if (t[p].c.val != 0) {
    op c = t[p].c;
    t[p].c.val = t[p].c.pos = 0;
    t[2 * p].d = max(t[2 * p].d, c);
    t[2 * p].c = max(t[2 * p].c, c);
    t[2 * p + 1].d = max(t[2 * p + 1].d, c);
    t[2 * p + 1].c = max(t[2 * p + 1].c, c);
  }
}
void change(int p, int l, int r, op v) {
  if (l <= t[p].l && r >= t[p].r) {
    t[p].d = max(t[p].d, v);
    t[p].c = max(t[p].c, v);
  } else {
    spread(p);
    int m = (t[p].l + t[p].r) / 2;
    if (l <= m) change(2 * p, l, r, v);
    if (r >= m + 1) change(2 * p + 1, l, r, v);
    t[p].d = max(t[2 * p].d, t[2 * p + 1].d);
  }
}
op ask(int p, int l, int r) {
  if (l <= t[p].l && r >= t[p].r)
    return t[p].d;
  else {
    spread(p);
    op res;
    res.val = res.pos = 0;
    int m = (t[p].l + t[p].r) / 2;
    if (l <= m) res = max(res, ask(2 * p, l, r));
    if (r >= m + 1) res = max(res, ask(2 * p + 1, l, r));
    return res;
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int size = 0;
  for (int i = 0; i < m; i++) {
    int r, x, y;
    scanf("%d%d%d", &r, &x, &y);
    a[++size] = x;
    a[++size] = y + 1;
    g[r].push_back(Element{x, y});
  }
  size = preWork(size);
  build(1, 1, size);
  int ans = 1, id = 1;
  for (int i = n; i >= 1; i--) {
    int val = 1;
    nxt[i] = 0;
    for (Element e : g[i]) {
      int l = e.l, r = e.r;
      int x = getID(l, size);
      int y = getID(r, size);
      op offer = ask(1, x, y);
      if (val < offer.val + 1) {
        val = offer.val + 1;
        nxt[i] = offer.pos;
      }
    }
    if (ans < val) {
      ans = val;
      id = i;
    }
    for (Element e : g[i]) {
      int l = e.l, r = e.r;
      int x = getID(l, size);
      int y = getID(r, size);
      op now;
      now.val = val, now.pos = i;
      change(1, x, y, now);
    }
  }
  int p = id;
  while (p != 0) {
    vis[p] = 1;
    p = nxt[p];
  }
  printf("%d\n", n - ans);
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) printf("%d ", i);
  }
  printf("\n");
  return 0;
}

```