#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
int n, m, ls[maxn * 3], pos, dp[maxn], last[maxn];
bool vis[maxn];
int madoka[maxn];
struct Node {
  int l, r;
  Node() {}
  Node(int l, int r) : l(l), r(r) {}
};
struct node {
  int l, r, id;
  int val;
} fbk[maxn << 4];
struct LLL {
  int id;
  int w;
} lazy[maxn << 4];
void pushup(int x) {
  if (fbk[x << 1].val >= fbk[x << 1 | 1].val)
    fbk[x].id = fbk[x << 1].id;
  else
    fbk[x].id = fbk[x << 1 | 1].id;
  fbk[x].val = max(fbk[x << 1].val, fbk[x << 1 | 1].val);
  return;
}
void pushdown(int x) {
  if (lazy[x].w) {
    int w = lazy[x].w;
    int id = lazy[x].id;
    lazy[x].w = lazy[x].id = 0;
    if (w > lazy[x << 1].w) {
      lazy[x << 1].w = w;
      lazy[x << 1].id = id;
    }
    if (w > lazy[x << 1 | 1].w) {
      lazy[x << 1 | 1].w = w;
      lazy[x << 1 | 1].id = id;
    }
    if (w > fbk[x << 1].val) {
      fbk[x << 1].val = w;
      fbk[x << 1].id = id;
    }
    if (w > fbk[x << 1 | 1].val) {
      fbk[x << 1 | 1].val = w;
      fbk[x << 1 | 1].id = id;
    }
  }
  return;
}
void build(int l, int r, int x) {
  fbk[x].l = l;
  fbk[x].r = r;
  fbk[x].val = fbk[x].id = 0;
  lazy[x].id = lazy[x].w = 0;
  if (l == r) return;
  int mid = (l + r) >> 1;
  build(l, mid, x << 1);
  build(mid + 1, r, x << 1 | 1);
  return;
}
node query(int L, int R, int x) {
  int l = fbk[x].l;
  int r = fbk[x].r;
  if (l >= L && r <= R) return fbk[x];
  pushdown(x);
  int mid = (l + r) >> 1;
  if (L > mid)
    return query(L, R, x << 1 | 1);
  else if (R <= mid)
    return query(L, R, x << 1);
  else {
    node a = query(L, mid, x << 1);
    node b = query(mid + 1, R, x << 1 | 1);
    if (a.val > b.val)
      return a;
    else
      return b;
  }
}
void update(int L, int R, int x, int Max, int idx) {
  int l = fbk[x].l;
  int r = fbk[x].r;
  if (l >= L && r <= R) {
    if (Max > lazy[x].w) {
      lazy[x].w = Max;
      lazy[x].id = idx;
    }
    if (Max > fbk[x].val) {
      fbk[x].val = Max;
      fbk[x].id = idx;
    }
    return;
  }
  pushdown(x);
  int mid = (l + r) >> 1;
  if (L > mid)
    update(L, R, x << 1 | 1, Max, idx);
  else if (R <= mid)
    update(L, R, x << 1, Max, idx);
  else {
    update(L, mid, x << 1, Max, idx);
    update(mid + 1, R, x << 1 | 1, Max, idx);
  }
  pushup(x);
  return;
}
vector<Node> E[maxn];
int main() {
  cin >> n >> m;
  int i, j, k, x, l, r;
  for (i = 1; i <= m; i++) {
    scanf("%d%d%d", &x, &l, &r);
    E[x].push_back(Node(l, r));
    ls[++pos] = l;
    ls[++pos] = r;
  }
  sort(ls + 1, ls + pos + 1);
  pos = unique(ls + 1, ls + pos + 1) - ls - 1;
  for (i = 1; i <= n; i++) {
    for (j = 0; j < E[i].size(); j++) {
      l = E[i][j].l;
      r = E[i][j].r;
      E[i][j].l = lower_bound(ls + 1, ls + pos + 1, l) - ls;
      E[i][j].r = lower_bound(ls + 1, ls + pos + 1, r) - ls;
    }
  }
  int ans = 0;
  build(1, pos, 1);
  for (i = 1; i <= n; i++) {
    node t;
    t.id = 0;
    t.val = 1;
    for (j = 0; j < E[i].size(); j++) {
      l = E[i][j].l;
      r = E[i][j].r;
      node tt = query(l, r, 1);
      if (t.val < tt.val + 1) {
        t = tt;
        t.val++;
      }
    }
    dp[i] = t.val;
    last[i] = t.id;
    for (j = 0; j < E[i].size(); j++) {
      l = E[i][j].l;
      r = E[i][j].r;
      update(l, r, 1, dp[i], i);
    }
    ans = max(ans, dp[i]);
  }
  int root = 0;
  for (i = 1; i <= n; i++) {
    if (ans == dp[i]) {
      root = i;
      break;
    }
  }
  while (root != 0) {
    vis[root] = 1;
    root = last[root];
  }
  int len = 0;
  for (i = 1; i <= n; i++) {
    if (!vis[i]) madoka[++len] = i;
  }
  cout << len << endl;
  for (i = 1; i <= len; i++) printf(i == len ? "%d\n" : "%d ", madoka[i]);
  return 0;
}

### Prompt

Develop a solution in CPP to the problem described below:

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 namespace std;
const int maxn = 3e5 + 10;
int n, m, ls[maxn * 3], pos, dp[maxn], last[maxn];
bool vis[maxn];
int madoka[maxn];
struct Node {
  int l, r;
  Node() {}
  Node(int l, int r) : l(l), r(r) {}
};
struct node {
  int l, r, id;
  int val;
} fbk[maxn << 4];
struct LLL {
  int id;
  int w;
} lazy[maxn << 4];
void pushup(int x) {
  if (fbk[x << 1].val >= fbk[x << 1 | 1].val)
    fbk[x].id = fbk[x << 1].id;
  else
    fbk[x].id = fbk[x << 1 | 1].id;
  fbk[x].val = max(fbk[x << 1].val, fbk[x << 1 | 1].val);
  return;
}
void pushdown(int x) {
  if (lazy[x].w) {
    int w = lazy[x].w;
    int id = lazy[x].id;
    lazy[x].w = lazy[x].id = 0;
    if (w > lazy[x << 1].w) {
      lazy[x << 1].w = w;
      lazy[x << 1].id = id;
    }
    if (w > lazy[x << 1 | 1].w) {
      lazy[x << 1 | 1].w = w;
      lazy[x << 1 | 1].id = id;
    }
    if (w > fbk[x << 1].val) {
      fbk[x << 1].val = w;
      fbk[x << 1].id = id;
    }
    if (w > fbk[x << 1 | 1].val) {
      fbk[x << 1 | 1].val = w;
      fbk[x << 1 | 1].id = id;
    }
  }
  return;
}
void build(int l, int r, int x) {
  fbk[x].l = l;
  fbk[x].r = r;
  fbk[x].val = fbk[x].id = 0;
  lazy[x].id = lazy[x].w = 0;
  if (l == r) return;
  int mid = (l + r) >> 1;
  build(l, mid, x << 1);
  build(mid + 1, r, x << 1 | 1);
  return;
}
node query(int L, int R, int x) {
  int l = fbk[x].l;
  int r = fbk[x].r;
  if (l >= L && r <= R) return fbk[x];
  pushdown(x);
  int mid = (l + r) >> 1;
  if (L > mid)
    return query(L, R, x << 1 | 1);
  else if (R <= mid)
    return query(L, R, x << 1);
  else {
    node a = query(L, mid, x << 1);
    node b = query(mid + 1, R, x << 1 | 1);
    if (a.val > b.val)
      return a;
    else
      return b;
  }
}
void update(int L, int R, int x, int Max, int idx) {
  int l = fbk[x].l;
  int r = fbk[x].r;
  if (l >= L && r <= R) {
    if (Max > lazy[x].w) {
      lazy[x].w = Max;
      lazy[x].id = idx;
    }
    if (Max > fbk[x].val) {
      fbk[x].val = Max;
      fbk[x].id = idx;
    }
    return;
  }
  pushdown(x);
  int mid = (l + r) >> 1;
  if (L > mid)
    update(L, R, x << 1 | 1, Max, idx);
  else if (R <= mid)
    update(L, R, x << 1, Max, idx);
  else {
    update(L, mid, x << 1, Max, idx);
    update(mid + 1, R, x << 1 | 1, Max, idx);
  }
  pushup(x);
  return;
}
vector<Node> E[maxn];
int main() {
  cin >> n >> m;
  int i, j, k, x, l, r;
  for (i = 1; i <= m; i++) {
    scanf("%d%d%d", &x, &l, &r);
    E[x].push_back(Node(l, r));
    ls[++pos] = l;
    ls[++pos] = r;
  }
  sort(ls + 1, ls + pos + 1);
  pos = unique(ls + 1, ls + pos + 1) - ls - 1;
  for (i = 1; i <= n; i++) {
    for (j = 0; j < E[i].size(); j++) {
      l = E[i][j].l;
      r = E[i][j].r;
      E[i][j].l = lower_bound(ls + 1, ls + pos + 1, l) - ls;
      E[i][j].r = lower_bound(ls + 1, ls + pos + 1, r) - ls;
    }
  }
  int ans = 0;
  build(1, pos, 1);
  for (i = 1; i <= n; i++) {
    node t;
    t.id = 0;
    t.val = 1;
    for (j = 0; j < E[i].size(); j++) {
      l = E[i][j].l;
      r = E[i][j].r;
      node tt = query(l, r, 1);
      if (t.val < tt.val + 1) {
        t = tt;
        t.val++;
      }
    }
    dp[i] = t.val;
    last[i] = t.id;
    for (j = 0; j < E[i].size(); j++) {
      l = E[i][j].l;
      r = E[i][j].r;
      update(l, r, 1, dp[i], i);
    }
    ans = max(ans, dp[i]);
  }
  int root = 0;
  for (i = 1; i <= n; i++) {
    if (ans == dp[i]) {
      root = i;
      break;
    }
  }
  while (root != 0) {
    vis[root] = 1;
    root = last[root];
  }
  int len = 0;
  for (i = 1; i <= n; i++) {
    if (!vis[i]) madoka[++len] = i;
  }
  cout << len << endl;
  for (i = 1; i <= len; i++) printf(i == len ? "%d\n" : "%d ", madoka[i]);
  return 0;
}

```