#include <bits/stdc++.h>
using namespace std;
const int MaxN = 100005;
int n, m;
struct Node {
  int x, y, i;
} p[MaxN];
bool cmp(Node p1, Node p2) {
  if (p1.y != p2.y) return p1.y < p2.y;
  return p1.x < p2.x;
}
int tr[MaxN];
int read(int k) {
  int ret = 0;
  while (k > 0) {
    ret += tr[k];
    k -= k & -k;
  }
  return ret;
}
void update(int k, int v) {
  while (k < MaxN) {
    tr[k] += v;
    k += k & -k;
  }
}
int ans[MaxN];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    y -= (n - x);
    p[i].x = x - y + 1;
    p[i].y = x;
    p[i].i = i;
  }
  sort(p, p + m, cmp);
  int ret = 0;
  for (int i = 0; i < m; i++) {
    int lo = p[i].x - 1, hi = p[i].y;
    if (read(hi) - read(lo) == (hi - lo)) continue;
    int x = read(lo), y = lo;
    while (lo + 1 < hi) {
      int mid = (lo + hi) / 2;
      if (read(mid) - x == (mid - y))
        lo = mid;
      else
        hi = mid;
    }
    update(hi, 1);
    ans[ret++] = p[i].i;
  }
  printf("%d\n", ret);
  for (int i = 0; i < ret; i++)
    printf("%d%c", ans[i] + 1, i == ret - 1 ? '\n' : ' ');
  return 0;
}
