#include <bits/stdc++.h>
using namespace std;
struct node {
  int l, r, id, u;
} s[100005];
int n, m;
int tr[100005];
int cmp(node a, node b) { return a.r < b.r; }
int read(int idx) {
  int res = 0;
  while (idx) {
    res += tr[idx];
    idx -= idx & (-idx);
  }
  return res;
}
void update(int idx, int val) {
  while (idx <= n) {
    tr[idx] += val;
    idx += idx & (-idx);
  }
}
int main() {
  int i, j, k, x, y;
  while (scanf("%d%d", &n, &m) != EOF) {
    for (i = 0; i < m; i++) {
      scanf("%d%d", &x, &y);
      s[i].l = n + 1 - x;
      s[i].r = y;
      s[i].id = i;
      s[i].u = 0;
    }
    sort(s, s + m, cmp);
    memset(tr, 0, sizeof(tr));
    int res = 0;
    for (i = 0; i < m; i++) {
      int x = read(s[i].l - 1), y = read(s[i].r);
      if (y - x == s[i].r - s[i].l + 1) continue;
      int l = s[i].l - 1, r = s[i].r + 1, mid;
      while (l + 1 < r) {
        mid = (l + r) >> 1;
        if (read(mid) - x == mid - s[i].l + 1)
          l = mid;
        else
          r = mid;
      }
      update(r, 1);
      res++;
      s[i].u = 1;
    }
    printf("%d\n", res);
    for (i = j = 0; i < m; i++) {
      if (s[i].u) {
        j++;
        printf("%d", s[i].id + 1);
        if (j == res)
          puts("");
        else
          putchar(' ');
      }
    }
  }
  return 0;
}
