#include <bits/stdc++.h>
using namespace std;
const int N = 8001010;
pair<int, int> s[N], tmp;
int v[N], n, m, i, a, b, pre[N], cnt, id[N], ans[N];
pair<int, int> min(pair<int, int> a, pair<int, int> b) {
  if (a.first == 0)
    return b;
  else if (b.first == 0)
    return a;
  else if (a.first < b.first)
    return a;
  else
    return b;
}
void build(int x, int a, int b) {
  if (b - a == 1) {
    s[x].first = v[b];
    s[x].second = b;
  } else {
    int m = (a + b) >> 1;
    build(2 * x, a, m);
    build(2 * x + 1, m, b);
    s[x] = min(s[2 * x], s[2 * x + 1]);
  }
}
void query(int x, int a, int b, int l, int r) {
  int m;
  if ((a <= l) && (r <= b)) {
    tmp = min(tmp, s[x]);
    return;
  }
  m = (l + r) >> 1;
  if (a < m) query(2 * x, a, b, l, m);
  if (m < b) query(2 * x + 1, a, b, m, r);
}
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &a, &b);
    if (v[a + b - 1] == 0) {
      v[a + b - 1] = a;
      id[a + b - 1] = i;
    } else if (a < v[a + b - 1]) {
      v[a + b - 1] = a;
      id[a + b - 1] = i;
    }
  }
  build(1, 0, n);
  for (i = 1; i <= n; i++)
    if (v[i]) {
      tmp.first = 0;
      tmp.second = 0;
      query(1, max(0, v[i] - 2), i, 0, n);
      pre[i] = tmp.second;
    }
  for (i = n; i >= 1;)
    if (pre[i] == 0)
      i--;
    else {
      ans[id[i]] = 1;
      if (pre[i] == i)
        i = v[i] - 1, cnt++;
      else
        i = pre[i], cnt++;
    }
  printf("%d\n", m - cnt);
  for (i = 1; i <= m; i++)
    if (ans[i] == 0) printf("%d ", i);
}
