#include <bits/stdc++.h>
using namespace std;
struct pt {
  int x, y;
  int id;
  pt() : x(0), y(0) {}
  bool operator<(const pt &p2) const {
    if (y != p2.y) return y > p2.y;
    return x < p2.x;
  }
};
int main() {
  int n, m;
  while (scanf("%d%d", &n, &m) >= 1) {
    vector<pt> pts(m);
    for (int i = 0; i < m; i++)
      scanf("%d%d", &pts[i].x, &pts[i].y), pts[i].x--, pts[i].y--,
          pts[i].id = i;
    sort(pts.begin(), pts.end());
    vector<int> res;
    int ptr = 0;
    set<pair<pair<int, int>, int> > xs;
    for (int y = n - 1; y >= 0; y--) {
      int x = n - 1 - y;
      while (ptr < ((int)(pts).size()) && pts[ptr].y >= y)
        xs.insert(make_pair(make_pair(pts[ptr].x, -pts[ptr].y), ptr)), ptr++;
      set<pair<pair<int, int>, int> >::iterator it =
          xs.lower_bound(make_pair(make_pair(x, -1e9), -1));
      if (it == xs.end()) continue;
      int i = it->second;
      xs.erase(it);
      res.push_back(pts[i].id);
    }
    printf("%d\n", ((int)(res).size()));
    for (int i = 0; i < ((int)(res).size()); i++)
      printf("%d%c", res[i] + 1, "\n "[i + 1 < ((int)(res).size())]);
  }
  return 0;
}
