#include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, int> id;
set<int> columns[123456];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int r, c;
    scanf("%d %d", &r, &c);
    id[make_pair(r, c)] = i;
    columns[c].insert(r);
  }
  vector<int> answer;
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      available;
  for (int c = n; c >= 1; c--) {
    int goal = n - c + 1;
    while (!available.empty() && available.top().first < goal) available.pop();
    for (const auto& r : columns[c]) available.push(make_pair(r, c));
    if (!available.empty()) {
      auto location = available.top();
      available.pop();
      answer.push_back(id[location]);
    }
  }
  printf("%d\n", answer.size());
  for (const auto& i : answer) {
    printf("%d ", i);
  }
  printf("\n");
  return 0;
}
