#include <bits/stdc++.h>
using namespace std;
priority_queue<pair<int, int> > q;
struct node {
  int l, r, id;
} p[100010];
int n, m;
int x, y;
int cmp(const void* a, const void* b) { return ((node*)a)->l - ((node*)b)->l; }
int ans[100010];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    p[i].l = n + 1 - y;
    p[i].r = x;
    p[i].id = i;
  }
  qsort(p + 1, m, sizeof(node), cmp);
  int j = 1;
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    while (j <= m && p[j].l <= i) {
      q.push(make_pair(-p[j].r, p[j].id));
      j++;
    }
    while (!q.empty()) {
      pair<int, int> t = q.top();
      q.pop();
      if (-t.first >= i) {
        cnt++;
        ans[cnt] = t.second;
        break;
      }
    }
  }
  printf("%d\n", cnt);
  for (int i = 1; i <= cnt; i++) {
    printf("%d ", ans[i]);
  }
}
