#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
const int LEN = 300;
const int MAX = (100000 + LEN - 1) / LEN;
int n;
int m;
int was[100000], x[100000], y[100000];
int l[MAX], r[MAX], w[MAX];
vector<pair<pair<int, int>, int> > v;
vector<int> res;
int get(int a, int b) {
  int A = a / LEN;
  int B = b / LEN;
  if (abs(A - B) <= 1) {
    for (int i = a; i <= b; i++)
      if (!was[i]) return i;
  } else {
    for (int i = a; i <= r[A]; i++)
      if (!was[i]) return i;
    for (int i = A + 1; i < B; i++)
      if (w[i] > 0) {
        for (int j = l[i]; j <= r[i]; j++)
          if (!was[j]) return j;
      }
    for (int i = l[B]; i <= b; i++)
      if (!was[i]) return i;
  }
  return -1;
}
int add(int x) {
  was[x] = 1;
  int y = x / LEN;
  w[y]--;
  return 0;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &x[i], &y[i]);
    x[i]--;
    y[i]--;
    v.push_back(make_pair(make_pair(x[i], y[i]), i));
  }
  int NUM = (n + LEN - 1) / LEN;
  for (int i = 0; i < NUM; i++) {
    l[i] = i * LEN;
    r[i] = min((i + 1) * LEN, n) - 1;
    w[i] = r[i] - l[i] + 1;
  }
  sort((v).begin(), (v).end());
  for (int i = 0; i < m; i++) {
    int j = v[i].second;
    int a = n - y[j] - 1;
    int b = x[j];
    int c = get(a, b);
    if (c != -1) {
      res.push_back(j + 1);
      add(c);
    }
  }
  sort((res).begin(), (res).end());
  printf("%d\n", ((int)(res).size()));
  for (int i = 0; i < ((int)(res).size()); i++) printf("%d ", res[i]);
  printf("\n");
  return 0;
}
