#include <bits/stdc++.h>
using namespace std;
struct point {
  int x, y, id;
  bool operator<(const point &b) const { return x < b.x; }
} a[100010];
int f[100010];
struct node {
  int y, id;
  bool operator<(const node &b) const { return y > b.y; }
} temp;
priority_queue<node> q;
int main() {
  int n, m, ans = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &a[i].x, &a[i].y);
    a[i].x = n + 1 - a[i].x;
    a[i].id = i;
  }
  sort(a + 1, a + 1 + m);
  int now = 1;
  for (int i = 1; i <= n; i++) {
    while (now <= m && a[now].x <= i) {
      temp.id = a[now].id;
      temp.y = a[now].y;
      now++;
      q.push(temp);
    }
    while (!q.empty()) {
      temp = q.top();
      if (temp.y >= i) break;
      q.pop();
    }
    if (!q.empty()) {
      temp = q.top();
      f[++ans] = temp.id;
      q.pop();
    }
  }
  printf("%d\n", ans);
  for (int i = 1; i <= ans; i++) printf("%d ", f[i]);
  printf("\n");
  return 0;
}
