#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > sportowiec;
int main() {
  int n, m;
  map<pair<int, int>, int> M;
  scanf("%d%d", &n, &m);
  set<pair<int, int> > S;
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    M[make_pair(a, b)] = i + 1;
    sportowiec.push_back(make_pair(n - b + 1, a));
  }
  vector<int> wybrani;
  auto j = sportowiec.begin();
  sort(sportowiec.begin(), sportowiec.end());
  for (int i = 1; i <= n; i++) {
    while (j != sportowiec.end() && j->first == i) {
      S.insert(make_pair(j->second, j->first));
      j++;
    }
    while (!S.empty() && S.begin()->first < i) S.erase(S.begin());
    if (!S.empty()) {
      pair<int, int> aktualny = *S.begin();
      wybrani.push_back(M[make_pair(aktualny.first, n - aktualny.second + 1)]);
      S.erase(S.begin());
    }
  }
  int wynik = wybrani.size();
  printf("%d\n", wynik);
  for (auto i : wybrani) printf("%d ", i);
}
