#include <bits/stdc++.h>
using namespace std;
struct Element {
  int beg, end, i;
  Element() {}
  Element(int beg, int end, int i) : beg(beg), end(end), i(i) {}
};
bool operator<(const Element &A, const Element &B) {
  return A.beg < B.beg || A.beg == B.beg && A.end < B.end;
}
int main() {
  for (int n, m; ~scanf("%d%d", &n, &m);) {
    int r, c;
    vector<Element> vt;
    for (int i = 1; i <= m; i++) {
      scanf("%d%d", &r, &c);
      vt.push_back(Element(n - c + 1, r, i));
    }
    sort(vt.begin(), vt.end());
    vector<int> ans;
    priority_queue<pair<int, int> > pq;
    vector<Element>::iterator it = vt.begin();
    for (int i = 1; i <= n; i++) {
      while (it != vt.end() && it->beg <= i) {
        pq.push(pair<int, int>(-it->end, it->i));
        it++;
      }
      while (!pq.empty() && -pq.top().first < i) {
        pq.pop();
      }
      if (!pq.empty()) {
        ans.push_back(pq.top().second);
        pq.pop();
      }
    }
    printf("%d\n", ans.size());
    for (vector<int>::iterator it = ans.begin(); it != ans.end(); it++) {
      printf("%d ", *it);
    }
    puts("");
  }
  return 0;
}
