#include <bits/stdc++.h>
using namespace std;
struct man {
  int l, r, id;
  bool operator<(const man &t) const {
    if (r != t.r) return r < t.r;
    return l < t.l;
  }
};
const int nmax = 1e5 + 5;
int par[nmax];
int get_par(int u) {
  if (par[par[u]] == par[u]) return par[u];
  return par[u] = get_par(par[u]);
}
void unite(int u, int v) {
  u = get_par(u), v = get_par(v);
  par[u] = v;
}
int main() {
  for (int i = 0; i < nmax; ++i) par[i] = i;
  int n, m;
  scanf("%d %d", &n, &m);
  vector<man> men(m);
  for (int i = 0; i < m; ++i) {
    int r, c;
    scanf("%d %d", &r, &c);
    men[i].id = i + 1;
    men[i].r = r;
    men[i].l = n - c + 1;
  }
  sort(men.begin(), men.end());
  vector<int> answer;
  for (int i = 0; i < m; ++i) {
    int next_open = get_par(men[i].l);
    if (next_open <= men[i].r) {
      answer.push_back(men[i].id);
      par[next_open] = next_open + 1;
    }
  }
  printf("%d\n", (int)answer.size());
  for (int i = 0; i < answer.size(); ++i) {
    printf("%d", answer[i]);
    if (i < answer.size() - 1)
      printf(" ");
    else
      printf("\n");
  }
}
