#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  while (2 == scanf("%d%d", &N, &M)) {
    vector<pair<pair<int, int>, int> > itvs(M);
    for (int i = 0; i < (int)(M); i++) {
      int r, c;
      scanf("%d%d", &r, &c);
      int d = (r + c) - (N + 1);
      itvs[i].first = make_pair(r + 1, r - d);
      itvs[i].second = i;
    }
    sort((itvs).begin(), (itvs).end());
    set<int> se;
    for (int i = 1; i <= N; ++i) se.insert(i);
    vector<int> ans;
    for (int i = 0; i < (int)(M); i++) {
      int b = itvs[i].first.second;
      int e = itvs[i].first.first;
      __typeof((se).begin()) ite = se.lower_bound(b);
      if (ite == se.end() || e <= *ite) continue;
      se.erase(ite);
      ans.push_back(itvs[i].second);
    }
    printf("%d\n", (int)ans.size());
    for (int i = 0; i < (int)(ans.size()); i++)
      printf("%d%c", ans[i] + 1, i + 1 == ans.size() ? '\n' : ' ');
  }
  return 0;
}
